You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-04 01:09:52 +08:00
Fix some Test failures
Fix py.test pytest/test_grammar.py - Comprehension sorts of things removed from parser that don't exist in earlier pythons scanners/tok.py Add back in "to" when needed
This commit is contained in:
@@ -361,15 +361,11 @@ class PythonParser(GenericASTBuilder):
|
|||||||
|
|
||||||
setcomp ::= LOAD_SETCOMP MAKE_FUNCTION_0 expr GET_ITER CALL_FUNCTION_1
|
setcomp ::= LOAD_SETCOMP MAKE_FUNCTION_0 expr GET_ITER CALL_FUNCTION_1
|
||||||
|
|
||||||
stmt ::= setcomp_func
|
|
||||||
|
|
||||||
comp_iter ::= comp_if
|
comp_iter ::= comp_if
|
||||||
comp_iter ::= comp_ifnot
|
comp_iter ::= comp_ifnot
|
||||||
comp_iter ::= comp_for
|
comp_iter ::= comp_for
|
||||||
comp_iter ::= comp_body
|
comp_iter ::= comp_body
|
||||||
comp_body ::= set_comp_body
|
|
||||||
comp_body ::= gen_comp_body
|
comp_body ::= gen_comp_body
|
||||||
comp_body ::= dict_comp_body
|
|
||||||
gen_comp_body ::= expr YIELD_VALUE POP_TOP
|
gen_comp_body ::= expr YIELD_VALUE POP_TOP
|
||||||
|
|
||||||
comp_if ::= expr jmp_false comp_iter
|
comp_if ::= expr jmp_false comp_iter
|
||||||
|
@@ -190,7 +190,6 @@ class Python2Parser(PythonParser):
|
|||||||
except_stmts ::= except_stmt
|
except_stmts ::= except_stmt
|
||||||
|
|
||||||
except_stmt ::= except_cond1 except_suite
|
except_stmt ::= except_cond1 except_suite
|
||||||
except_stmt ::= except_cond2 except_suite
|
|
||||||
except_stmt ::= except
|
except_stmt ::= except
|
||||||
|
|
||||||
except_suite ::= c_stmts_opt JUMP_FORWARD
|
except_suite ::= c_stmts_opt JUMP_FORWARD
|
||||||
|
@@ -179,6 +179,7 @@ class Python26Parser(Python2Parser):
|
|||||||
|
|
||||||
comp_for ::= SETUP_LOOP expr _for designator comp_iter jb_bp_come_from
|
comp_for ::= SETUP_LOOP expr _for designator comp_iter jb_bp_come_from
|
||||||
|
|
||||||
|
comp_body ::= gen_comp_body
|
||||||
|
|
||||||
# Make sure we keep indices the same as 2.7
|
# Make sure we keep indices the same as 2.7
|
||||||
setup_loop_lf ::= SETUP_LOOP LOAD_FAST
|
setup_loop_lf ::= SETUP_LOOP LOAD_FAST
|
||||||
|
@@ -16,9 +16,13 @@ class Python27Parser(Python2Parser):
|
|||||||
"""
|
"""
|
||||||
list_for ::= expr _for designator list_iter JUMP_BACK
|
list_for ::= expr _for designator list_iter JUMP_BACK
|
||||||
|
|
||||||
|
stmt ::= setcomp_func
|
||||||
|
|
||||||
setcomp_func ::= BUILD_SET_0 LOAD_FAST FOR_ITER designator comp_iter
|
setcomp_func ::= BUILD_SET_0 LOAD_FAST FOR_ITER designator comp_iter
|
||||||
JUMP_BACK RETURN_VALUE RETURN_LAST
|
JUMP_BACK RETURN_VALUE RETURN_LAST
|
||||||
|
|
||||||
|
comp_body ::= dict_comp_body
|
||||||
|
comp_body ::= set_comp_body
|
||||||
dict_comp_body ::= expr expr MAP_ADD
|
dict_comp_body ::= expr expr MAP_ADD
|
||||||
set_comp_body ::= expr SET_ADD
|
set_comp_body ::= expr SET_ADD
|
||||||
|
|
||||||
@@ -30,6 +34,8 @@ class Python27Parser(Python2Parser):
|
|||||||
tryelsestmt ::= SETUP_EXCEPT suite_stmts_opt POP_BLOCK
|
tryelsestmt ::= SETUP_EXCEPT suite_stmts_opt POP_BLOCK
|
||||||
try_middle else_suite COME_FROM
|
try_middle else_suite COME_FROM
|
||||||
|
|
||||||
|
except_stmt ::= except_cond2 except_suite
|
||||||
|
|
||||||
except_cond1 ::= DUP_TOP expr COMPARE_OP
|
except_cond1 ::= DUP_TOP expr COMPARE_OP
|
||||||
jmp_false POP_TOP POP_TOP POP_TOP
|
jmp_false POP_TOP POP_TOP POP_TOP
|
||||||
|
|
||||||
|
@@ -47,8 +47,13 @@ class Python3Parser(PythonParser):
|
|||||||
jb_or_c ::= JUMP_BACK
|
jb_or_c ::= JUMP_BACK
|
||||||
jb_or_c ::= CONTINUE
|
jb_or_c ::= CONTINUE
|
||||||
|
|
||||||
|
stmt ::= setcomp_func
|
||||||
|
|
||||||
setcomp_func ::= BUILD_SET_0 LOAD_FAST FOR_ITER designator comp_iter
|
setcomp_func ::= BUILD_SET_0 LOAD_FAST FOR_ITER designator comp_iter
|
||||||
JUMP_BACK RETURN_VALUE RETURN_LAST
|
JUMP_BACK RETURN_VALUE RETURN_LAST
|
||||||
|
|
||||||
|
comp_body ::= dict_comp_body
|
||||||
|
comp_body ::= set_comp_body
|
||||||
dict_comp_body ::= expr expr MAP_ADD
|
dict_comp_body ::= expr expr MAP_ADD
|
||||||
set_comp_body ::= expr SET_ADD
|
set_comp_body ::= expr SET_ADD
|
||||||
|
|
||||||
|
@@ -61,7 +61,14 @@ class Token:
|
|||||||
if self.pattr:
|
if self.pattr:
|
||||||
pattr = self.pattr
|
pattr = self.pattr
|
||||||
if self.opc:
|
if self.opc:
|
||||||
if self.op in self.opc.hascompare:
|
if self.op in self.opc.hasjrel:
|
||||||
|
pattr = "to " + self.pattr
|
||||||
|
elif self.op in self.opc.hasjabs:
|
||||||
|
self.pattr= str(self.pattr)
|
||||||
|
if not self.pattr.startswith('to '):
|
||||||
|
pattr = "to " + str(self.pattr)
|
||||||
|
pass
|
||||||
|
elif self.op in self.opc.hascompare:
|
||||||
if isinstance(self.attr, int):
|
if isinstance(self.attr, int):
|
||||||
pattr = self.opc.cmp_op[self.attr]
|
pattr = self.opc.cmp_op[self.attr]
|
||||||
# And so on. See xdis/bytecode.py get_instructions_bytes
|
# And so on. See xdis/bytecode.py get_instructions_bytes
|
||||||
|
Reference in New Issue
Block a user