diff --git a/uncompyle6/parser.py b/uncompyle6/parser.py index 369ce13c..6cd51c57 100644 --- a/uncompyle6/parser.py +++ b/uncompyle6/parser.py @@ -414,7 +414,7 @@ class PythonParser(GenericASTBuilder): list_if_not ::= expr jmp_true list_iter """ - def p_setcomp(self, args): + def p_set_comp(self, args): """ comp_iter ::= comp_for comp_iter ::= comp_body diff --git a/uncompyle6/parsers/parse2.py b/uncompyle6/parsers/parse2.py index ee59d34a..6ad275fd 100644 --- a/uncompyle6/parsers/parse2.py +++ b/uncompyle6/parsers/parse2.py @@ -353,8 +353,8 @@ class Python2Parser(PythonParser): continue elif opname == 'LOAD_SETCOMP': self.add_unique_rules([ - "expr ::= setcomp", - "setcomp ::= LOAD_SETCOMP MAKE_FUNCTION_0 expr GET_ITER CALL_FUNCTION_1" + "expr ::= set_comp", + "set_comp ::= LOAD_SETCOMP MAKE_FUNCTION_0 expr GET_ITER CALL_FUNCTION_1" ], customize) continue elif opname == 'LOOKUP_METHOD': @@ -394,8 +394,8 @@ class Python2Parser(PythonParser): ('expr '*v, opname))], customize) elif prev_tok == 'LOAD_SETCOMP': self.add_unique_rules([ - "expr ::= setcomp", - ('setcomp ::= %s load_closure LOAD_SETCOMP %s expr' + "expr ::= set_comp", + ('set_comp ::= %s load_closure LOAD_SETCOMP %s expr' ' GET_ITER CALL_FUNCTION_1' % ('expr '*v, opname)) ], customize) diff --git a/uncompyle6/parsers/parse3.py b/uncompyle6/parsers/parse3.py index 12274618..a59a3932 100644 --- a/uncompyle6/parsers/parse3.py +++ b/uncompyle6/parsers/parse3.py @@ -603,12 +603,12 @@ class Python3Parser(PythonParser): # Is there something more general than this? adding pos_arg? # Is there something corresponding using MAKE_CLOSURE? For example: - # setcomp ::= {pos_arg}^n LOAD_SETCOMP [LOAD_CONST] MAKE_CLOSURE_n + # set_comp ::= {pos_arg}^n LOAD_SETCOMP [LOAD_CONST] MAKE_CLOSURE_n GET_ITER CALL_FUNCTION_1 - setcomp ::= LOAD_SETCOMP [LOAD_CONST] MAKE_FUNCTION_0 expr + set_comp ::= LOAD_SETCOMP [LOAD_CONST] MAKE_FUNCTION_0 expr GET_ITER CALL_FUNCTION_1 - setcomp ::= {pos_arg}^n load_closure LOAD_SETCOMP [LOAD_CONST] + set_comp ::= {pos_arg}^n load_closure LOAD_SETCOMP [LOAD_CONST] MAKE_CLOSURE_n expr GET_ITER CALL_FUNCTION_1 mkfunc ::= {pos_arg}^n load_closure [LOAD_CONST] MAKE_FUNCTION_n @@ -803,9 +803,9 @@ class Python3Parser(PythonParser): elif opname == 'LOAD_SETCOMP': # Should this be generalized and put under MAKE_FUNCTION? if has_get_iter_call_function1: - self.add_unique_rule("expr ::= setcomp", + self.add_unique_rule("expr ::= set_comp", opname, token.attr, customize) - rule_pat = ("setcomp ::= LOAD_SETCOMP %sMAKE_FUNCTION_0 expr " + rule_pat = ("set_comp ::= LOAD_SETCOMP %sMAKE_FUNCTION_0 expr " "GET_ITER CALL_FUNCTION_1") self.add_make_function_rule(rule_pat, opname, token.attr, customize) elif opname == 'LOOKUP_METHOD': @@ -841,7 +841,7 @@ class Python3Parser(PythonParser): 'GET_ITER CALL_FUNCTION_1' % ('pos_arg ' * args_pos, opname)) self.add_make_function_rule(rule_pat, opname, token.attr, customize) if (is_pypy or (i >= j and tokens[i-j] == 'LOAD_SETCOMP')): - rule_pat = ('setcomp ::= %sload_closure LOAD_SETCOMP %%s%s expr ' + rule_pat = ('set_comp ::= %sload_closure LOAD_SETCOMP %%s%s expr ' 'GET_ITER CALL_FUNCTION_1' % ('pos_arg ' * args_pos, opname)) self.add_make_function_rule(rule_pat, opname, token.attr, customize) if (is_pypy or (i >= j and tokens[i-j] == 'LOAD_DICTCOMP')): diff --git a/uncompyle6/semantics/consts.py b/uncompyle6/semantics/consts.py index 841a93d2..af28c065 100644 --- a/uncompyle6/semantics/consts.py +++ b/uncompyle6/semantics/consts.py @@ -302,7 +302,7 @@ PRECEDENCE = { 'mapexpr': 0, 'unary_convert': 0, 'dictcomp': 0, - 'setcomp': 0, + 'set_comp': 0, 'list_comp': 0, 'generator_exp': 0, diff --git a/uncompyle6/semantics/fragments.py b/uncompyle6/semantics/fragments.py index 23c3f8d6..3e8827b3 100644 --- a/uncompyle6/semantics/fragments.py +++ b/uncompyle6/semantics/fragments.py @@ -778,7 +778,7 @@ class FragmentsWalker(pysource.SourceWalker, object): self.set_pos_info(node, start, len(self.f.getvalue())) self.prune() - def n_setcomp(self, node): + def n_set_comp(self, node): start = len(self.f.getvalue()) self.write('{') if node[0] in ['LOAD_SETCOMP', 'LOAD_DICTCOMP']: diff --git a/uncompyle6/semantics/pysource.py b/uncompyle6/semantics/pysource.py index c2cc1d54..7f58488e 100644 --- a/uncompyle6/semantics/pysource.py +++ b/uncompyle6/semantics/pysource.py @@ -1226,7 +1226,7 @@ class SourceWalker(GenericASTTraversal, object): self.write(')') self.prune() - def n_setcomp(self, node): + def n_set_comp(self, node): self.write('{') if node[0] in ['LOAD_SETCOMP', 'LOAD_DICTCOMP']: self.comprehension_walk3(node, 1, 0) @@ -1329,7 +1329,7 @@ class SourceWalker(GenericASTTraversal, object): code = Code(node[1].attr, self.scanner, self.currentclass) ast = self.build_ast(code._tokens, code._customize) self.customize(code._customize) - if node == 'setcomp': + if node == 'set_comp': ast = ast[0][0][0] else: ast = ast[0][0][0][0][0] @@ -1375,7 +1375,7 @@ class SourceWalker(GenericASTTraversal, object): self.write(']') self.prune() - n_dictcomp = n_setcomp + n_dictcomp = n_set_comp def setcomprehension_walk3(self, node, collection_index): """List comprehensions the way they are done in Python3.