You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-04 01:09:52 +08:00
NT break_stmt, continue_stmt -> break, continue...
to match AST
This commit is contained in:
@@ -62,8 +62,8 @@ class Python2Parser(PythonParser):
|
|||||||
|
|
||||||
return_stmt_lambda ::= ret_expr RETURN_VALUE_LAMBDA
|
return_stmt_lambda ::= ret_expr RETURN_VALUE_LAMBDA
|
||||||
|
|
||||||
stmt ::= break_stmt
|
stmt ::= break
|
||||||
break_stmt ::= BREAK_LOOP
|
break ::= BREAK_LOOP
|
||||||
|
|
||||||
stmt ::= continue
|
stmt ::= continue
|
||||||
continue ::= CONTINUE
|
continue ::= CONTINUE
|
||||||
|
@@ -107,7 +107,7 @@ class Python26Parser(Python2Parser):
|
|||||||
assert ::= assert_expr jmp_true LOAD_ASSERT RAISE_VARARGS_1 come_froms_pop
|
assert ::= assert_expr jmp_true LOAD_ASSERT RAISE_VARARGS_1 come_froms_pop
|
||||||
assert2 ::= assert_expr jmp_true LOAD_ASSERT expr RAISE_VARARGS_2 come_froms_pop
|
assert2 ::= assert_expr jmp_true LOAD_ASSERT expr RAISE_VARARGS_2 come_froms_pop
|
||||||
|
|
||||||
break_stmt ::= BREAK_LOOP JUMP_BACK
|
break ::= BREAK_LOOP JUMP_BACK
|
||||||
|
|
||||||
# Semantic actions want else_suitel to be at index 3
|
# Semantic actions want else_suitel to be at index 3
|
||||||
ifelsestmtl ::= testexpr c_stmts_opt cf_jb_cf_pop else_suitel
|
ifelsestmtl ::= testexpr c_stmts_opt cf_jb_cf_pop else_suitel
|
||||||
|
@@ -88,8 +88,8 @@ class Python3Parser(PythonParser):
|
|||||||
return_if_stmts ::= _stmts return_if_stmt
|
return_if_stmts ::= _stmts return_if_stmt
|
||||||
return_if_stmt ::= ret_expr RETURN_END_IF
|
return_if_stmt ::= ret_expr RETURN_END_IF
|
||||||
|
|
||||||
stmt ::= break_stmt
|
stmt ::= break
|
||||||
break_stmt ::= BREAK_LOOP
|
break ::= BREAK_LOOP
|
||||||
|
|
||||||
stmt ::= continue
|
stmt ::= continue
|
||||||
continue ::= CONTINUE
|
continue ::= CONTINUE
|
||||||
|
@@ -20,7 +20,7 @@ def checker(ast, in_loop, errors):
|
|||||||
errors.append(error_text)
|
errors.append(error_text)
|
||||||
|
|
||||||
for node in ast:
|
for node in ast:
|
||||||
if not in_loop and node.kind in ('continue', 'break_stmt'):
|
if not in_loop and node.kind in ('continue', 'break'):
|
||||||
text = str(node)
|
text = str(node)
|
||||||
error_text = '\n# not in loop:\n#\t' + '\n# '.join(text.split("\n"))
|
error_text = '\n# not in loop:\n#\t' + '\n# '.join(text.split("\n"))
|
||||||
errors.append(error_text)
|
errors.append(error_text)
|
||||||
|
@@ -224,7 +224,7 @@ TABLE_DIRECT = {
|
|||||||
'print_to_items': ( '%C', (0, 2, ', ') ),
|
'print_to_items': ( '%C', (0, 2, ', ') ),
|
||||||
|
|
||||||
'call_stmt': ( '%|%p\n', (0, 200)),
|
'call_stmt': ( '%|%p\n', (0, 200)),
|
||||||
'break_stmt': ( '%|break\n', ),
|
'break': ( '%|break\n', ),
|
||||||
'continue': ( '%|continue\n', ),
|
'continue': ( '%|continue\n', ),
|
||||||
|
|
||||||
'raise_stmt0': ( '%|raise\n', ),
|
'raise_stmt0': ( '%|raise\n', ),
|
||||||
|
@@ -28,7 +28,7 @@ node 2 range information, it in %c, is copied to nodes 0 and 1.
|
|||||||
%r associates recursively location information for the string that follows
|
%r associates recursively location information for the string that follows
|
||||||
|
|
||||||
For example in:
|
For example in:
|
||||||
'break_stmt': ( '%|%rbreak\n', ),
|
'break': ( '%|%rbreak\n', ),
|
||||||
|
|
||||||
The node will be associated with the text break, excluding the trailing newline.
|
The node will be associated with the text break, excluding the trailing newline.
|
||||||
|
|
||||||
@@ -84,7 +84,7 @@ ExtractInfo = namedtuple("ExtractInfo",
|
|||||||
"lineNo lineStartOffset markerLine selectedLine selectedText nonterminal")
|
"lineNo lineStartOffset markerLine selectedLine selectedText nonterminal")
|
||||||
|
|
||||||
TABLE_DIRECT_FRAGMENT = {
|
TABLE_DIRECT_FRAGMENT = {
|
||||||
'break_stmt': ( '%|%rbreak\n', ),
|
'break': ( '%|%rbreak\n', ),
|
||||||
'continue ': ( '%|%rcontinue\n', ),
|
'continue ': ( '%|%rcontinue\n', ),
|
||||||
'passstmt': ( '%|%rpass\n', ),
|
'passstmt': ( '%|%rpass\n', ),
|
||||||
'raise_stmt0': ( '%|%rraise\n', ),
|
'raise_stmt0': ( '%|%rraise\n', ),
|
||||||
|
Reference in New Issue
Block a user