You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-02 16:44:46 +08:00
Grammar hell
This commit is contained in:
@@ -474,6 +474,7 @@ class PythonParser(GenericASTBuilder):
|
||||
_mklambda ::= mklambda
|
||||
|
||||
expr ::= conditional
|
||||
conditional ::= expr jmp_false expr JUMP_FORWARD expr COME_FROM
|
||||
|
||||
ret_expr ::= expr
|
||||
ret_expr ::= ret_and
|
||||
|
@@ -13,15 +13,16 @@ class Python21Parser(Python22Parser):
|
||||
|
||||
def p_forstmt21(self, args):
|
||||
"""
|
||||
_for ::= LOAD_CONST FOR_LOOP
|
||||
forstmt ::= SETUP_LOOP expr _for designator
|
||||
return_stmts
|
||||
POP_BLOCK COME_FROM
|
||||
forstmt ::= SETUP_LOOP expr _for designator
|
||||
l_stmts_opt _jump_back
|
||||
POP_BLOCK COME_FROM
|
||||
_for ::= LOAD_CONST FOR_LOOP
|
||||
forstmt ::= SETUP_LOOP expr _for designator
|
||||
return_stmts
|
||||
POP_BLOCK COME_FROM
|
||||
forstmt ::= SETUP_LOOP expr _for designator
|
||||
l_stmts_opt _jump_back
|
||||
POP_BLOCK COME_FROM
|
||||
|
||||
conditional ::= expr jmp_false expr JUMP_ABSOLUTE expr
|
||||
expr ::= conditional
|
||||
conditional ::= expr jmp_false expr JUMP_ABSOLUTE expr
|
||||
"""
|
||||
|
||||
def p_import21(self, args):
|
||||
|
@@ -93,7 +93,6 @@ class Python26Parser(Python2Parser):
|
||||
bp_come_from ::= POP_BLOCK COME_FROM
|
||||
jb_bp_come_from ::= JUMP_BACK bp_come_from
|
||||
|
||||
_ifstmts_jump ::= c_stmts_opt jf_pop COME_FROM
|
||||
_ifstmts_jump ::= c_stmts_opt JUMP_FORWARD COME_FROM POP_TOP
|
||||
_ifstmts_jump ::= c_stmts_opt JUMP_FORWARD come_froms POP_TOP COME_FROM
|
||||
|
||||
@@ -182,6 +181,7 @@ class Python26Parser(Python2Parser):
|
||||
jmp_true_then ::= JUMP_IF_TRUE THEN POP_TOP
|
||||
|
||||
while1stmt ::= SETUP_LOOP return_stmts COME_FROM
|
||||
for_block ::= return_stmts _come_from
|
||||
"""
|
||||
|
||||
def p_comp26(self, args):
|
||||
|
@@ -99,6 +99,7 @@ class Python27Parser(Python2Parser):
|
||||
# assert condition, expr
|
||||
assert2 ::= assert_expr jmp_true LOAD_ASSERT expr CALL_FUNCTION_1 RAISE_VARARGS_1
|
||||
|
||||
for_block ::= return_stmts _come_from
|
||||
del_stmt ::= expr expr DELETE_SLICE+1
|
||||
|
||||
withstmt ::= expr SETUP_WITH POP_TOP suite_stmts_opt
|
||||
@@ -118,6 +119,9 @@ class Python27Parser(Python2Parser):
|
||||
else_suite COME_FROM
|
||||
|
||||
ifstmt ::= testexpr return_if_stmts COME_FROM
|
||||
ifelsestmt ::= testexpr c_stmts_opt JUMP_FORWARD else_suite COME_FROM
|
||||
ifelsestmtc ::= testexpr c_stmts_opt JUMP_ABSOLUTE else_suitec
|
||||
ifelsestmtl ::= testexpr c_stmts_opt JUMP_BACK else_suitel
|
||||
|
||||
# Common with 2.6
|
||||
return_if_lambda ::= RETURN_END_IF_LAMBDA COME_FROM
|
||||
|
@@ -10,7 +10,8 @@ from uncompyle6.parsers.parse3 import Python3Parser
|
||||
class Python32Parser(Python3Parser):
|
||||
def p_32to35(self, args):
|
||||
"""
|
||||
conditional ::= expr jmp_false expr jump_forward_else expr COME_FROM
|
||||
expr ::= conditional
|
||||
conditional ::= expr jmp_false expr jump_forward_else expr COME_FROM
|
||||
|
||||
# compare_chained2 is used in a "chained_compare": x <= y <= z
|
||||
# used exclusively in compare_chained
|
||||
|
Reference in New Issue
Block a user