Fix 2.6- chained compare in lambda

This commit is contained in:
rocky 2017-12-12 14:29:47 -05:00
parent 832734ccb4
commit 733e0ebf9d
6 changed files with 14 additions and 10 deletions

Binary file not shown.

View File

@ -16,5 +16,4 @@ 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')
lambda c: 'a' <= c <= 'z', 'Hello World'

View File

@ -260,14 +260,15 @@ class Python26Parser(Python2Parser):
# compare_chained is like x <= y <= z
compare_chained ::= expr compare_chained1 ROT_TWO COME_FROM POP_TOP _come_froms
compare_chained1 ::= expr DUP_TOP ROT_THREE COMPARE_OP
jmp_false compare_chained1 _come_froms
jmp_false_then compare_chained1 _come_froms
compare_chained1 ::= expr DUP_TOP ROT_THREE COMPARE_OP
jmp_false compare_chained2 _come_froms
jmp_false_then 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_lambda ::= RETURN_VALUE
return_lambda ::= RETURN_END_IF_LAMBDA
return_lambda ::= RETURN_VALUE_LAMBDA
compare_chained2 ::= expr COMPARE_OP return_lambda
return_if_lambda ::= RETURN_END_IF_LAMBDA POP_TOP
stmt ::= conditional_lambda

View File

@ -82,8 +82,12 @@ class Python27Parser(Python2Parser):
compare_chained1 COME_FROM
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
return_lambda ::= RETURN_VALUE
return_lambda ::= RETURN_VALUE_LAMBDA
compare_chained2 ::= expr COMPARE_OP return_lambda
compare_chained2 ::= expr COMPARE_OP return_lambda
# conditional_true are for conditions which always evaluate true
# There is dead or non-optional remnants of the condition code though,