Grammar isolation fixes

This commit is contained in:
rocky
2017-11-27 05:16:08 -05:00
parent fab6870710
commit c241b12308
5 changed files with 9 additions and 11 deletions

View File

@@ -37,12 +37,6 @@ def test_grammar():
else:
expect_lhs.add('kwarg')
# FIXME: grammar remove_rule on
# kv3 ::= expr expr STORE_MAP
# doesn't currently work in grammar, so we have this extraneous kv3 around.
if 3.3 <= PYTHON_VERSION <= 3.4:
expect_lhs.add('kv3')
assert expect_lhs == set(lhs)
assert unused_rhs == set(rhs)
assert expect_right_recursive == right_recursive

View File

@@ -400,7 +400,6 @@ class PythonParser(GenericASTBuilder):
def p_list_comprehension(self, args):
"""
expr ::= list_compr
list_compr ::= BUILD_LIST_0 list_iter
list_iter ::= list_for
list_iter ::= list_if
@@ -409,8 +408,6 @@ class PythonParser(GenericASTBuilder):
list_if ::= expr jmp_false list_iter
list_if_not ::= expr jmp_true list_iter
lc_body ::= expr LIST_APPEND
"""
def p_setcomp(self, args):

View File

@@ -15,6 +15,8 @@ class Python27Parser(Python2Parser):
def p_comprehension27(self, args):
"""
list_for ::= expr _for designator list_iter JUMP_BACK
list_compr ::= BUILD_LIST_0 list_iter
lc_body ::= expr LIST_APPEND
stmt ::= setcomp_func

View File

@@ -49,7 +49,12 @@ class Python32Parser(Python3Parser):
stmt ::= del_deref_stmt
del_deref_stmt ::= DELETE_DEREF
kv3 ::= expr expr STORE_MAP
list_compr ::= BUILD_LIST_0 list_iter
lc_body ::= expr LIST_APPEND
kvlist ::= kvlist kv3
kv3 ::= expr expr STORE_MAP
"""
pass

View File

@@ -27,7 +27,7 @@ class Python33Parser(Python32Parser):
trystmt ::= SETUP_EXCEPT suite_stmts_opt POP_BLOCK
try_middle
jump_excepts come_from_except_clauses
kvlist ::= kvlist kv3
mapexpr ::= BUILD_MAP kvlist
"""
def add_custom_rules(self, tokens, customize):