You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-03 00:45:53 +08:00
Fix "for ... if" bug introduced since 3.6.2...
However we've isolated and documented the 3.x grammar a little bit better
This commit is contained in:
@@ -141,18 +141,20 @@ class Python3Parser(PythonParser):
|
||||
assert_expr_or ::= assert_expr jmp_true expr
|
||||
assert_expr_and ::= assert_expr jmp_false expr
|
||||
|
||||
ifstmt ::= testexpr _ifstmts_jump
|
||||
ifstmt ::= testexpr _ifstmts_jump
|
||||
|
||||
testexpr ::= testfalse
|
||||
testexpr ::= testtrue
|
||||
testfalse ::= expr jmp_false
|
||||
testtrue ::= expr jmp_true
|
||||
|
||||
_ifstmts_jump ::= return_if_stmts
|
||||
_ifstmts_jump ::= c_stmts_opt come_froms
|
||||
_ifstmts_jump ::= return_if_stmts
|
||||
_ifstmts_jump ::= c_stmts_opt come_froms
|
||||
_ifstmts_jumpl ::= return_if_stmts
|
||||
|
||||
iflaststmt ::= testexpr c_stmts_opt JUMP_ABSOLUTE
|
||||
iflaststmtl ::= testexpr c_stmts_opt JUMP_BACK
|
||||
iflaststmtl ::= testexpr _ifstmts_jumpl
|
||||
|
||||
# These are used to keep parse tree indices the same
|
||||
jump_forward_else ::= JUMP_FORWARD ELSE
|
||||
@@ -330,6 +332,10 @@ class Python3Parser(PythonParser):
|
||||
def p_stmt3(self, args):
|
||||
"""
|
||||
stmt ::= if_expr_lambda
|
||||
|
||||
# If statement inside a loop:
|
||||
lastl_stmt ::= ifstmtl
|
||||
|
||||
stmt ::= conditional_not_lambda
|
||||
if_expr_lambda ::= expr jmp_false expr return_if_lambda
|
||||
return_stmt_lambda LAMBDA_MARKER
|
||||
|
@@ -952,6 +952,8 @@ class Python37Parser(Python37BaseParser):
|
||||
"""
|
||||
stmt ::= if_expr_lambda
|
||||
stmt ::= conditional_not_lambda
|
||||
|
||||
# If statement inside a loop:
|
||||
stmt ::= ifstmtl
|
||||
|
||||
if_expr_lambda ::= expr jmp_false expr return_if_lambda
|
||||
|
@@ -371,14 +371,13 @@ TABLE_DIRECT = {
|
||||
# 'return': ( '%|return %c\n', 0),
|
||||
'return_if_stmt': ( 'return %c\n', 0),
|
||||
|
||||
'ifstmt': ( '%|if %c:\n%+%c%-',
|
||||
"ifstmt": ( "%|if %c:\n%+%c%-",
|
||||
0, # "testexpr" or "testexpr_then"
|
||||
1, # "_ifstmts_jump" or "return_stmts"
|
||||
),
|
||||
|
||||
'iflaststmt': ( '%|if %c:\n%+%c%-', 0, 1 ),
|
||||
'iflaststmtl': ( '%|if %c:\n%+%c%-', 0, 1 ),
|
||||
'testtrue': ( 'not %p',
|
||||
'iflaststmt': ( "%|if %c:\n%+%c%-", 0, 1 ),
|
||||
'iflaststmtl': ( "%|if %c:\n%+%c%-", 0, 1 ),
|
||||
'testtrue': ( "not %p",
|
||||
(0, PRECEDENCE['unary_not']) ),
|
||||
|
||||
# Generally the args here are 0: (some sort of) "testexpr",
|
||||
|
Reference in New Issue
Block a user