Grammar isolation

This commit is contained in:
rocky
2017-11-27 05:26:43 -05:00
parent c241b12308
commit 169e4681c3
4 changed files with 10 additions and 5 deletions

View File

@@ -419,7 +419,6 @@ class PythonParser(GenericASTBuilder):
gen_comp_body ::= expr YIELD_VALUE POP_TOP
comp_if ::= expr jmp_false comp_iter
comp_for ::= expr _for designator comp_iter JUMP_BACK
"""
def p_expr(self, args):
@@ -478,9 +477,6 @@ class PythonParser(GenericASTBuilder):
expr ::= conditional
conditional ::= expr jmp_false expr JUMP_FORWARD expr COME_FROM
expr ::= conditionalTrue
conditionalTrue ::= expr JUMP_FORWARD expr COME_FROM
ret_expr ::= expr
ret_expr ::= ret_and
ret_expr ::= ret_or

View File

@@ -90,7 +90,6 @@ class Python2Parser(PythonParser):
stmt ::= exec_stmt
del_stmt ::= expr DELETE_SLICE+0
del_stmt ::= expr expr DELETE_SLICE+1
del_stmt ::= expr expr DELETE_SLICE+2
del_stmt ::= expr expr expr DELETE_SLICE+3
del_stmt ::= delete_subscr

View File

@@ -33,6 +33,8 @@ class Python27Parser(Python2Parser):
comp_body ::= dict_comp_body
comp_body ::= set_comp_body
comp_for ::= expr _for designator comp_iter JUMP_BACK
dict_comp_body ::= expr expr MAP_ADD
set_comp_body ::= expr SET_ADD
@@ -84,6 +86,9 @@ 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
expr ::= conditionalTrue
conditionalTrue ::= expr JUMP_FORWARD expr COME_FROM
"""
def p_stmt27(self, args):
@@ -94,6 +99,7 @@ class Python27Parser(Python2Parser):
# assert condition, expr
assert2 ::= assert_expr jmp_true LOAD_ASSERT expr CALL_FUNCTION_1 RAISE_VARARGS_1
del_stmt ::= expr expr DELETE_SLICE+1
withstmt ::= expr SETUP_WITH POP_TOP suite_stmts_opt
POP_BLOCK LOAD_CONST COME_FROM_WITH

View File

@@ -42,6 +42,7 @@ class Python3Parser(PythonParser):
# as a CONTINUE. The two are kind of the same in a comprehension.
comp_for ::= expr _for designator comp_iter CONTINUE
comp_for ::= expr _for designator comp_iter JUMP_BACK
list_for ::= expr FOR_ITER designator list_iter jb_or_c
@@ -279,6 +280,9 @@ class Python3Parser(PythonParser):
for_block ::= l_stmts_opt opt_come_from_loop JUMP_BACK
for_block ::= l_stmts
iflaststmtl ::= testexpr c_stmts_opt
expr ::= conditionalTrue
conditionalTrue ::= expr JUMP_FORWARD expr COME_FROM
"""
def p_def_annotations3(self, args):