diff --git a/uncompyle6/parser.py b/uncompyle6/parser.py index 9ac28d64..271d3d89 100644 --- a/uncompyle6/parser.py +++ b/uncompyle6/parser.py @@ -361,15 +361,11 @@ class PythonParser(GenericASTBuilder): setcomp ::= LOAD_SETCOMP MAKE_FUNCTION_0 expr GET_ITER CALL_FUNCTION_1 - stmt ::= setcomp_func - comp_iter ::= comp_if comp_iter ::= comp_ifnot comp_iter ::= comp_for comp_iter ::= comp_body - comp_body ::= set_comp_body comp_body ::= gen_comp_body - comp_body ::= dict_comp_body gen_comp_body ::= expr YIELD_VALUE POP_TOP comp_if ::= expr jmp_false comp_iter diff --git a/uncompyle6/parsers/parse2.py b/uncompyle6/parsers/parse2.py index ae992e66..3e222ead 100644 --- a/uncompyle6/parsers/parse2.py +++ b/uncompyle6/parsers/parse2.py @@ -190,7 +190,6 @@ class Python2Parser(PythonParser): except_stmts ::= except_stmt except_stmt ::= except_cond1 except_suite - except_stmt ::= except_cond2 except_suite except_stmt ::= except except_suite ::= c_stmts_opt JUMP_FORWARD diff --git a/uncompyle6/parsers/parse26.py b/uncompyle6/parsers/parse26.py index b162c68f..c6bd47b4 100644 --- a/uncompyle6/parsers/parse26.py +++ b/uncompyle6/parsers/parse26.py @@ -179,6 +179,7 @@ class Python26Parser(Python2Parser): 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 setup_loop_lf ::= SETUP_LOOP LOAD_FAST diff --git a/uncompyle6/parsers/parse27.py b/uncompyle6/parsers/parse27.py index 91decb80..e20f5a95 100644 --- a/uncompyle6/parsers/parse27.py +++ b/uncompyle6/parsers/parse27.py @@ -16,9 +16,13 @@ class Python27Parser(Python2Parser): """ list_for ::= expr _for designator list_iter JUMP_BACK + stmt ::= setcomp_func + setcomp_func ::= BUILD_SET_0 LOAD_FAST FOR_ITER designator comp_iter JUMP_BACK RETURN_VALUE RETURN_LAST + comp_body ::= dict_comp_body + comp_body ::= set_comp_body dict_comp_body ::= expr expr MAP_ADD set_comp_body ::= expr SET_ADD @@ -30,6 +34,8 @@ class Python27Parser(Python2Parser): tryelsestmt ::= SETUP_EXCEPT suite_stmts_opt POP_BLOCK try_middle else_suite COME_FROM + except_stmt ::= except_cond2 except_suite + except_cond1 ::= DUP_TOP expr COMPARE_OP jmp_false POP_TOP POP_TOP POP_TOP diff --git a/uncompyle6/parsers/parse3.py b/uncompyle6/parsers/parse3.py index 03b39248..a114e8b2 100644 --- a/uncompyle6/parsers/parse3.py +++ b/uncompyle6/parsers/parse3.py @@ -47,8 +47,13 @@ class Python3Parser(PythonParser): jb_or_c ::= JUMP_BACK jb_or_c ::= CONTINUE + stmt ::= setcomp_func + setcomp_func ::= BUILD_SET_0 LOAD_FAST FOR_ITER designator comp_iter JUMP_BACK RETURN_VALUE RETURN_LAST + + comp_body ::= dict_comp_body + comp_body ::= set_comp_body dict_comp_body ::= expr expr MAP_ADD set_comp_body ::= expr SET_ADD diff --git a/uncompyle6/scanners/tok.py b/uncompyle6/scanners/tok.py index d7fe29f2..f9879334 100644 --- a/uncompyle6/scanners/tok.py +++ b/uncompyle6/scanners/tok.py @@ -61,7 +61,14 @@ class Token: if self.pattr: pattr = self.pattr 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): pattr = self.opc.cmp_op[self.attr] # And so on. See xdis/bytecode.py get_instructions_bytes