2.x Grammar reduction/isolation

This commit is contained in:
rocky
2017-11-22 19:13:21 -05:00
parent b00c59bdd7
commit b8f74c23f4
7 changed files with 12 additions and 15 deletions

Binary file not shown.

Binary file not shown.

View File

@@ -1,3 +1,4 @@
# Tests BINARY_TRUE_DIVIDE
# Tests BINARY_TRUE_DIVIDE and INPLACE_TRUE_DIVIDE
from __future__ import division # needed on 2.6 and 2.7
x = len(__file__) / 1
x /= 1

View File

@@ -40,10 +40,6 @@ class Python2Parser(PythonParser):
def p_stmt2(self, args):
"""
# Note: these are removed in 2.7
while1stmt ::= SETUP_LOOP l_stmts JUMP_BACK COME_FROM
while1elsestmt ::= SETUP_LOOP l_stmts JUMP_BACK else_suite COME_FROM
exec_stmt ::= expr exprlist DUP_TOP EXEC_STMT
exec_stmt ::= expr exprlist EXEC_STMT

View File

@@ -53,7 +53,6 @@ class Python25Parser(Python26Parser):
POP_BLOCK LOAD_CONST COME_FROM WITH_CLEANUP END_FINALLY
withasstmt ::= expr setupwithas designator suite_stmts_opt
POP_BLOCK LOAD_CONST COME_FROM WITH_CLEANUP END_FINALLY
whilestmt ::= SETUP_LOOP testexpr return_stmts come_froms POP_TOP bp_come_from
assert2 ::= assert_expr jmp_true LOAD_ASSERT expr CALL_FUNCTION_1 RAISE_VARARGS_1
""")
super(Python25Parser, self).add_custom_rules(tokens, customize)

View File

@@ -126,20 +126,19 @@ class Python26Parser(Python2Parser):
POP_BLOCK LOAD_CONST COME_FROM WITH_CLEANUP END_FINALLY
# Semantic actions want designator to be at index 2
# Rule is possibly 2.6 only
withasstmt ::= expr setupwithas designator suite_stmts_opt
POP_BLOCK LOAD_CONST COME_FROM WITH_CLEANUP END_FINALLY
# This is truly weird. 2.7 does this (not including POP_TOP) with
# opcode SETUP_WITH
setupwith ::= DUP_TOP LOAD_ATTR ROT_TWO LOAD_ATTR CALL_FUNCTION_0 POP_TOP
# Possibly 2.6 only
setupwith ::= DUP_TOP LOAD_ATTR ROT_TWO LOAD_ATTR CALL_FUNCTION_0 POP_TOP
setupwithas ::= DUP_TOP LOAD_ATTR ROT_TWO LOAD_ATTR CALL_FUNCTION_0 setup_finally
setup_finally ::= STORE_FAST SETUP_FINALLY LOAD_FAST DELETE_FAST
setup_finally ::= STORE_NAME SETUP_FINALLY LOAD_NAME DELETE_NAME
while1stmt ::= SETUP_LOOP l_stmts JUMP_BACK COME_FROM
whilestmt ::= SETUP_LOOP testexpr l_stmts_opt jb_pop POP_BLOCK _come_from
whilestmt ::= SETUP_LOOP testexpr l_stmts_opt jb_cf_pop bp_come_from
@@ -147,6 +146,7 @@ class Python26Parser(Python2Parser):
whileelsestmt ::= SETUP_LOOP testexpr l_stmts_opt jb_pop POP_BLOCK
else_suite COME_FROM
while1elsestmt ::= SETUP_LOOP l_stmts JUMP_BACK else_suite COME_FROM
return_stmt ::= ret_expr RETURN_END_IF POP_TOP
return_stmt ::= ret_expr RETURN_VALUE POP_TOP

View File

@@ -105,6 +105,7 @@ class Python27Parser(Python2Parser):
while1stmt ::= SETUP_LOOP return_stmts bp_come_from
while1elsestmt ::= SETUP_LOOP l_stmts JUMP_BACK POP_BLOCK else_suite COME_FROM
while1stmt ::= SETUP_LOOP l_stmts_opt JUMP_BACK POP_BLOCK COME_FROM
whilestmt ::= SETUP_LOOP testexpr l_stmts_opt JUMP_BACK POP_BLOCK _come_from
# Common with 2.6
return_if_lambda ::= RETURN_END_IF_LAMBDA COME_FROM