Grammar isolation

This commit is contained in:
rocky
2017-11-27 06:38:00 -05:00
parent 169e4681c3
commit f1a98e94da
4 changed files with 10 additions and 8 deletions

View File

@@ -361,7 +361,6 @@ class PythonParser(GenericASTBuilder):
_for ::= GET_ITER FOR_ITER
for_block ::= l_stmts_opt _come_from JUMP_BACK
for_block ::= return_stmts _come_from
forstmt ::= SETUP_LOOP expr _for designator
for_block POP_BLOCK _come_from
@@ -475,7 +474,6 @@ class PythonParser(GenericASTBuilder):
_mklambda ::= mklambda
expr ::= conditional
conditional ::= expr jmp_false expr JUMP_FORWARD expr COME_FROM
ret_expr ::= expr
ret_expr ::= ret_and

View File

@@ -123,7 +123,6 @@ class Python2Parser(PythonParser):
assert_expr_and ::= assert_expr jmp_false expr
ifstmt ::= testexpr _ifstmts_jump
ifstmt ::= testexpr return_if_stmts COME_FROM
testexpr ::= testfalse
testexpr ::= testtrue

View File

@@ -47,6 +47,8 @@ class Python23Parser(Python24Parser):
# so there is only the 2nd part to evaluate
expr ::= and2
and2 ::= _jump jmp_false COME_FROM expr COME_FROM
conditional ::= expr jmp_false expr JUMP_FORWARD expr COME_FROM
'''
def add_custom_rules(self, tokens, customize):

View File

@@ -97,13 +97,13 @@ class Python27Parser(Python2Parser):
assert ::= assert_expr jmp_true LOAD_ASSERT RAISE_VARARGS_1
# assert condition, expr
assert2 ::= assert_expr jmp_true LOAD_ASSERT expr CALL_FUNCTION_1 RAISE_VARARGS_1
assert2 ::= assert_expr jmp_true LOAD_ASSERT expr CALL_FUNCTION_1 RAISE_VARARGS_1
del_stmt ::= expr expr DELETE_SLICE+1
del_stmt ::= expr expr DELETE_SLICE+1
withstmt ::= expr SETUP_WITH POP_TOP suite_stmts_opt
POP_BLOCK LOAD_CONST COME_FROM_WITH
WITH_CLEANUP END_FINALLY
withstmt ::= expr SETUP_WITH POP_TOP suite_stmts_opt
POP_BLOCK LOAD_CONST COME_FROM_WITH
WITH_CLEANUP END_FINALLY
withasstmt ::= expr SETUP_WITH designator suite_stmts_opt
POP_BLOCK LOAD_CONST COME_FROM_WITH
@@ -117,10 +117,13 @@ class Python27Parser(Python2Parser):
whileelsestmt ::= SETUP_LOOP testexpr l_stmts_opt JUMP_BACK POP_BLOCK
else_suite COME_FROM
ifstmt ::= testexpr return_if_stmts COME_FROM
# Common with 2.6
return_if_lambda ::= RETURN_END_IF_LAMBDA COME_FROM
conditional_lambda ::= expr jmp_false expr return_if_lambda
return_stmt_lambda LAMBDA_MARKER
kv3 ::= expr expr STORE_MAP
"""