Isolate listcomp rule in 2.7

This commit is contained in:
rocky
2017-11-30 10:30:08 -05:00
parent ac4d4d1da9
commit bf5a6237d8
3 changed files with 7 additions and 2 deletions

View File

@@ -29,7 +29,7 @@ def test_grammar():
expect_lhs.add('kv3')
unused_rhs = unused_rhs.union(set("""
except_pop_except generator_exp classdefdeco2 listcomp
except_pop_except generator_exp classdefdeco2
mapexpr
""".split()))
if 3.0 <= PYTHON_VERSION:

View File

@@ -351,6 +351,11 @@ class Python2Parser(PythonParser):
"LOAD_ASSERT expr CALL_FUNCTION_1 RAISE_VARARGS_1 COME_FROM",
], customize)
continue
elif opname == 'LOAD_LISTCOMP':
self.add_unique_rules([
"expr ::= listcomp",
], customize)
continue
elif opname == 'LOAD_SETCOMP':
self.add_unique_rules([
"expr ::= set_comp",

View File

@@ -260,7 +260,7 @@ class Scanner2(Scanner):
customize[op_name] = 0
elif op == self.opc.CONTINUE_LOOP:
customize[op_name] = 0
elif op_name == 'LOAD_SETCOMP':
elif op_name in frozenset(('LOAD_LISTCOMP', 'LOAD_SETCOMP')):
customize[op_name] = 0
elif op == self.opc.JUMP_ABSOLUTE:
# Further classify JUMP_ABSOLUTE into backward jumps