Berry python compat for ranges

This commit is contained in:
Stephan Hadinger 2021-10-20 22:59:16 +02:00
parent 9b8f4e2a16
commit 13e8287554
3 changed files with 11 additions and 2 deletions

View File

@ -1074,7 +1074,11 @@ static void sub_expr(bparser *parser, bexpdesc *e, int prio)
be_code_prebinop(finfo, op, e); /* and or */
init_exp(&e2, ETVOID, 0);
sub_expr(parser, &e2, binary_op_prio(op)); /* parse right side */
check_var(parser, &e2); /* check if valid */
if ((e2.type == ETVOID) && (op == OptConnect)) {
init_exp(&e2, ETINT, -1);
} else {
check_var(parser, &e2); /* check if valid */
}
be_code_binop(finfo, op, e, &e2, -1); /* encode binary op */
op = get_binop(parser); /* is there a following binop? */
}

View File

@ -38,7 +38,7 @@ check(45.e+2, 4500)
test_source('x = 5; 0...x;', 'unexpected symbol near \'.\'')
test_source('x = 5; 0...x;', 'unexpected symbol near \'.\'')
test_source('45..', 'unexpected symbol near \'EOS\'')
# test_source('45..', 'unexpected symbol near \'EOS\'')
test_source('0xg', 'invalid hexadecimal number')
test_source('"\\x5g"', 'invalid hexadecimal number')
test_source('0x5g', 'malformed number')

View File

@ -34,3 +34,8 @@ assert(s.format("%i%%", 12) == "12%")
assert(s.format("%i%%%i", 12, 13) == "12%13")
assert(s.format("%s%%", "foo") == "foo%")
assert(s.format("%.1f%%", 3.5) == "3.5%")
s="azerty"
assert(s[1..2] == "ze")
assert(s[1..] == "zerty")
assert(s[1..-1] == "zerty")