Fix 2.7 lambda with chained compare...

More work needs to be done for 2.6-
This commit is contained in:
rocky 2017-12-12 13:13:30 -05:00
parent 84b4ac1c51
commit 832734ccb4
6 changed files with 12 additions and 1 deletions

View File

@ -14,3 +14,7 @@ g()
h = lambda: 1 if False else 3
h()
# From 2.7 test_builtin
def test_filter(self):
self.assertEqual(filter(lambda c: 'a' <= c <= 'z', 'Hello World'), 'elloorld')

View File

@ -51,6 +51,7 @@ case $PYVERSION in
2.6)
SKIP_TESTS=(
[test_binop.py]=1 # need to fix tryelse
# [test_builtin.py]=1 # Syntax error on 2.6, look at and fix like 2.7.14
[test_cmath.py]=1 # Control flow?
[test_codecs.py]=1 # need to fix tryelse
[test_coercion.py]=1 # Control flow?
@ -69,7 +70,6 @@ case $PYVERSION in
;;
2.7)
SKIP_TESTS=(
[test_builtin.py]=1 # Syntax error, look at
[test_dis.py]=1 # We change line numbers - duh!
[test_grammar.py]=1 # Too many stmts. Handle large stmts
[test_ioctl.py]=1 # Test takes too long to run

View File

@ -263,6 +263,12 @@ class Python26Parser(Python2Parser):
jmp_false compare_chained1 _come_froms
compare_chained1 ::= expr DUP_TOP ROT_THREE COMPARE_OP
jmp_false compare_chained2 _come_froms
# FIXME: start here
compare_chained2 ::= expr COMPARE_OP RETURN_VALUE
compare_chained2 ::= expr COMPARE_OP RETURN_END_IF_LAMBDA
compare_chained2 ::= expr COMPARE_OP RETURN_VALUE_LAMBDA
return_if_lambda ::= RETURN_END_IF_LAMBDA POP_TOP
stmt ::= conditional_lambda
conditional_lambda ::= expr jmp_false_then expr return_if_lambda

View File

@ -83,6 +83,7 @@ class Python27Parser(Python2Parser):
compare_chained1 ::= expr DUP_TOP ROT_THREE COMPARE_OP JUMP_IF_FALSE_OR_POP
compare_chained2 COME_FROM
compare_chained2 ::= expr COMPARE_OP RETURN_VALUE
compare_chained2 ::= expr COMPARE_OP RETURN_VALUE_LAMBDA
# conditional_true are for conditions which always evaluate true
# There is dead or non-optional remnants of the condition code though,