mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2024-11-23 05:00:07 +00:00
Simpilfy grammar via ending_return
This commit is contained in:
parent
b3ddf95d7a
commit
c0957d956f
@ -304,6 +304,9 @@ class PythonParser(GenericASTBuilder):
|
||||
c_stmts ::= lastc_stmt
|
||||
c_stmts ::= continues
|
||||
|
||||
ending_return ::= RETURN_VALUE RETURN_LAST
|
||||
ending_return ::= RETURN_VALUE_LAMBDA LAMBDA_MARKER
|
||||
|
||||
lastc_stmt ::= iflaststmt
|
||||
lastc_stmt ::= forelselaststmt
|
||||
lastc_stmt ::= ifelsestmtc
|
||||
|
@ -39,14 +39,10 @@ class Python27Parser(Python2Parser):
|
||||
stmt ::= dict_comp_func
|
||||
|
||||
dict_comp_func ::= BUILD_MAP_0 LOAD_FAST FOR_ITER store
|
||||
comp_iter JUMP_BACK RETURN_VALUE RETURN_LAST
|
||||
dict_comp_func ::= BUILD_MAP_0 LOAD_FAST FOR_ITER store
|
||||
comp_iter JUMP_BACK RETURN_VALUE_LAMBDA LAMBDA_MARKER
|
||||
comp_iter JUMP_BACK ending_return
|
||||
|
||||
set_comp_func ::= BUILD_SET_0 LOAD_FAST FOR_ITER store comp_iter
|
||||
JUMP_BACK RETURN_VALUE RETURN_LAST
|
||||
set_comp_func ::= BUILD_SET_0 LOAD_FAST FOR_ITER store comp_iter
|
||||
JUMP_BACK RETURN_VALUE_LAMBDA LAMBDA_MARKER
|
||||
JUMP_BACK ending_return
|
||||
|
||||
comp_iter ::= comp_if_not
|
||||
comp_if_not ::= expr jmp_true comp_iter
|
||||
|
@ -79,19 +79,13 @@ class Python3Parser(PythonParser):
|
||||
|
||||
stmt ::= set_comp_func
|
||||
|
||||
# TODO this can be simplified
|
||||
set_comp_func ::= BUILD_SET_0 LOAD_ARG FOR_ITER store comp_iter
|
||||
JUMP_BACK RETURN_VALUE RETURN_LAST
|
||||
set_comp_func ::= BUILD_SET_0 LOAD_ARG FOR_ITER store comp_iter
|
||||
JUMP_BACK RETURN_VALUE_LAMBDA LAMBDA_MARKER
|
||||
JUMP_BACK ending_return
|
||||
set_comp_func ::= BUILD_SET_0 LOAD_FAST FOR_ITER store comp_iter
|
||||
JUMP_BACK RETURN_VALUE RETURN_LAST
|
||||
set_comp_func ::= BUILD_SET_0 LOAD_FAST FOR_ITER store comp_iter
|
||||
JUMP_BACK RETURN_VALUE_LAMBDA LAMBDA_MARKER
|
||||
|
||||
JUMP_BACK ending_return
|
||||
set_comp_func ::= BUILD_SET_0 LOAD_ARG FOR_ITER store comp_iter
|
||||
COME_FROM JUMP_BACK RETURN_VALUE RETURN_LAST
|
||||
set_comp_func ::= BUILD_SET_0 LOAD_ARG FOR_ITER store comp_iter
|
||||
COME_FROM JUMP_BACK RETURN_VALUE_LAMBDA LAMBDA_MARKER
|
||||
COME_FROM JUMP_BACK ending_return
|
||||
|
||||
comp_body ::= dict_comp_body
|
||||
comp_body ::= set_comp_body
|
||||
|
@ -77,12 +77,8 @@ class Python30Parser(Python31Parser):
|
||||
|
||||
set_comp_func ::= set_comp_header
|
||||
LOAD_ARG FOR_ITER store comp_iter
|
||||
JUMP_BACK
|
||||
JUMP_BACK ending_return
|
||||
RETURN_VALUE RETURN_LAST
|
||||
set_comp_func ::= set_comp_header
|
||||
LOAD_ARG FOR_ITER store comp_iter
|
||||
JUMP_BACK
|
||||
RETURN_VALUE_LAMBDA LAMBDA_MARKER
|
||||
|
||||
list_comp_header ::= BUILD_LIST_0 DUP_TOP STORE_FAST
|
||||
list_comp ::= list_comp_header
|
||||
@ -112,11 +108,7 @@ class Python30Parser(Python31Parser):
|
||||
dict_comp_func ::= BUILD_MAP_0
|
||||
DUP_TOP STORE_FAST
|
||||
LOAD_ARG FOR_ITER store
|
||||
dict_comp_iter JUMP_BACK RETURN_VALUE RETURN_LAST
|
||||
dict_comp_func ::= BUILD_MAP_0
|
||||
DUP_TOP STORE_FAST
|
||||
LOAD_ARG FOR_ITER store
|
||||
dict_comp_iter JUMP_BACK RETURN_VALUE_LAMBDA LAMBDA_MARKER
|
||||
dict_comp_iter JUMP_BACK ending_return
|
||||
|
||||
stmt ::= try_except30
|
||||
try_except30 ::= SETUP_EXCEPT suite_stmts_opt
|
||||
|
@ -62,6 +62,9 @@ class Python37Parser(Python37BaseParser):
|
||||
c_stmts ::= lastc_stmt
|
||||
c_stmts ::= continues
|
||||
|
||||
ending_return ::= RETURN_VALUE RETURN_LAST
|
||||
ending_return ::= RETURN_VALUE_LAMBDA LAMBDA_MARKER
|
||||
|
||||
lastc_stmt ::= iflaststmt
|
||||
lastc_stmt ::= forelselaststmt
|
||||
lastc_stmt ::= ifelsestmtc
|
||||
@ -739,15 +742,11 @@ class Python37Parser(Python37BaseParser):
|
||||
|
||||
stmt ::= set_comp_func
|
||||
|
||||
# TODO: simplify this
|
||||
set_comp_func ::= BUILD_SET_0 LOAD_ARG for_iter store comp_iter
|
||||
JUMP_BACK RETURN_VALUE RETURN_LAST
|
||||
JUMP_BACK ending_return
|
||||
set_comp_func ::= BUILD_SET_0 LOAD_ARG for_iter store comp_iter
|
||||
JUMP_BACK RETURN_VALUE_LAMBDA LAMBDA_MARKER
|
||||
|
||||
set_comp_func ::= BUILD_SET_0 LOAD_ARG for_iter store comp_iter
|
||||
COME_FROM JUMP_BACK RETURN_VALUE RETURN_LAST
|
||||
set_comp_func ::= BUILD_SET_0 LOAD_ARG for_iter store comp_iter
|
||||
COME_FROM JUMP_BACK RETURN_VALUE_LAMBDA LAMBDA_MARKER
|
||||
COME_FROM JUMP_BACK ending_return
|
||||
|
||||
comp_body ::= dict_comp_body
|
||||
comp_body ::= set_comp_body
|
||||
@ -763,9 +762,7 @@ class Python37Parser(Python37BaseParser):
|
||||
stmt ::= dict_comp_func
|
||||
|
||||
dict_comp_func ::= BUILD_MAP_0 LOAD_ARG for_iter store
|
||||
comp_iter JUMP_BACK RETURN_VALUE RETURN_LAST
|
||||
dict_comp_func ::= BUILD_MAP_0 LOAD_ARG for_iter store
|
||||
comp_iter JUMP_BACK RETURN_VALUE_LAMBDA LAMBDA_MARKER
|
||||
comp_iter JUMP_BACK ending_return
|
||||
|
||||
comp_iter ::= comp_if
|
||||
comp_iter ::= comp_if_not
|
||||
|
@ -121,7 +121,8 @@ class Python38Parser(Python37Parser):
|
||||
for38 ::= expr get_for_iter store for_block
|
||||
|
||||
forelsestmt38 ::= expr get_for_iter store for_block POP_BLOCK else_suite
|
||||
forelsestmt38 ::= expr get_for_iter store for_block JUMP_BACK _come_froms else_suite
|
||||
forelsestmt38 ::= expr get_for_iter store for_block JUMP_BACK _come_froms
|
||||
else_suite
|
||||
|
||||
forelselaststmt38 ::= expr get_for_iter store for_block POP_BLOCK else_suitec
|
||||
forelselaststmtl38 ::= expr get_for_iter store for_block POP_BLOCK else_suitel
|
||||
@ -130,7 +131,8 @@ class Python38Parser(Python37Parser):
|
||||
except_return_value ::= POP_BLOCK return
|
||||
except_return_value ::= expr POP_BLOCK RETURN_VALUE
|
||||
|
||||
whilestmt38 ::= _come_froms testexpr l_stmts_opt COME_FROM JUMP_BACK POP_BLOCK
|
||||
whilestmt38 ::= _come_froms testexpr l_stmts_opt COME_FROM JUMP_BACK
|
||||
POP_BLOCK
|
||||
whilestmt38 ::= _come_froms testexpr l_stmts_opt JUMP_BACK POP_BLOCK
|
||||
whilestmt38 ::= _come_froms testexpr l_stmts_opt JUMP_BACK come_froms
|
||||
whilestmt38 ::= _come_froms testexpr returns POP_BLOCK
|
||||
|
Loading…
Reference in New Issue
Block a user