diff --git a/uncompyle6/parser.py b/uncompyle6/parser.py index 6cd51c57..196625e5 100644 --- a/uncompyle6/parser.py +++ b/uncompyle6/parser.py @@ -437,7 +437,7 @@ class PythonParser(GenericASTBuilder): expr ::= binary_expr expr ::= build_list expr ::= compare - expr ::= mapexpr + expr ::= dict expr ::= and expr ::= or expr ::= unary_expr diff --git a/uncompyle6/parsers/parse2.py b/uncompyle6/parsers/parse2.py index b3199d41..ce1a4adf 100644 --- a/uncompyle6/parsers/parse2.py +++ b/uncompyle6/parsers/parse2.py @@ -102,7 +102,7 @@ class Python2Parser(PythonParser): kvlist ::= kvlist kv3 kv3 ::= expr expr STORE_MAP - mapexpr ::= BUILD_MAP kvlist + dict ::= BUILD_MAP kvlist classdef ::= buildclass store @@ -285,7 +285,7 @@ class Python2Parser(PythonParser): self.add_unique_rules([ 'kvlist_n ::= kvlist_n kv3', 'kvlist_n ::=', - 'mapexpr ::= BUILD_MAP_n kvlist_n', + 'dict ::= BUILD_MAP_n kvlist_n', ], customize) if self.version >= 2.7: self.add_unique_rule( @@ -297,7 +297,7 @@ class Python2Parser(PythonParser): kvlist_n = "kvlist_%s" % v self.add_unique_rules([ (kvlist_n + " ::=" + ' kv3' * v), - "mapexpr ::= %s %s" % (opname, kvlist_n) + "dict ::= %s %s" % (opname, kvlist_n) ], customize) continue elif opname_base == 'BUILD_SLICE': diff --git a/uncompyle6/parsers/parse3.py b/uncompyle6/parsers/parse3.py index bafea25d..bf833732 100644 --- a/uncompyle6/parsers/parse3.py +++ b/uncompyle6/parsers/parse3.py @@ -655,7 +655,7 @@ class Python3Parser(PythonParser): if opname_base == 'BUILD_CONST_KEY_MAP': # This is in 3.6+ kvlist_n = 'expr ' * (token.attr) - rule = "mapexpr ::= %sLOAD_CONST %s" % (kvlist_n, opname) + rule = "dict ::= %sLOAD_CONST %s" % (kvlist_n, opname) self.add_unique_rule(rule, opname, token.attr, customize) elif opname.startswith('BUILD_LIST_UNPACK'): v = token.attr @@ -678,27 +678,27 @@ class Python3Parser(PythonParser): self.add_unique_rule(rule, 'kvlist_n', 0, customize) rule = 'kvlist_n ::=' self.add_unique_rule(rule, 'kvlist_n', 1, customize) - rule = "mapexpr ::= BUILD_MAP_n kvlist_n" + rule = "dict ::= BUILD_MAP_n kvlist_n" elif self.version >= 3.5: if opname != 'BUILD_MAP_WITH_CALL': if opname == 'BUILD_MAP_UNPACK': rule = kvlist_n + ' ::= ' + 'expr ' * (token.attr*2) self.add_unique_rule(rule, opname, token.attr, customize) - rule = 'dict ::= ' + 'expr ' * (token.attr*2) + rule = 'dict_entry ::= ' + 'expr ' * (token.attr*2) self.add_unique_rule(rule, opname, token.attr, customize) - rule = 'mapexpr ::= ' + 'dict ' * token.attr + rule = 'dict ::= ' + 'dict_entry ' * token.attr self.add_unique_rule(rule, opname, token.attr, customize) rule = ('unmap_dict ::= ' + - ('mapexpr ' * token.attr) + + ('dict ' * token.attr) + 'BUILD_MAP_UNPACK') else: rule = kvlist_n + ' ::= ' + 'expr ' * (token.attr*2) self.add_unique_rule(rule, opname, token.attr, customize) - rule = "mapexpr ::= %s %s" % (kvlist_n, opname) + rule = "dict ::= %s %s" % (kvlist_n, opname) else: rule = kvlist_n + ' ::= ' + 'expr expr STORE_MAP ' * token.attr self.add_unique_rule(rule, opname, token.attr, customize) - rule = "mapexpr ::= %s %s" % (opname, kvlist_n) + rule = "dict ::= %s %s" % (opname, kvlist_n) self.add_unique_rule(rule, opname, token.attr, customize) elif opname.startswith('BUILD_MAP_UNPACK_WITH_CALL'): v = token.attr diff --git a/uncompyle6/semantics/consts.py b/uncompyle6/semantics/consts.py index f65f1457..c55355ed 100644 --- a/uncompyle6/semantics/consts.py +++ b/uncompyle6/semantics/consts.py @@ -270,14 +270,13 @@ TABLE_DIRECT = { 'except_suite_finalize': ( '%+%c%-%C', 1, (3, maxint, '') ), 'passstmt': ( '%|pass\n', ), 'STORE_FAST': ( '%{pattr}', ), - 'kv': ( '%c: %c', 3, 1 ), - 'kv2': ( '%c: %c', 1, 2 ), - 'mapexpr': ( '{%[1]C}', (0, maxint, ', ') ), - 'import': ( '%|import %c\n', 2), - 'importlist': ( '%C', (0, maxint, ', ') ), - 'importfrom': ( '%|from %[2]{pattr} import %c\n', - (3, 'importlist') ), - 'importstar': ( '%|from %[2]{pattr} import *\n', ), + 'kv': ( '%c: %c', 3, 1 ), + 'kv2': ( '%c: %c', 1, 2 ), + 'import': ( '%|import %c\n', 2), + 'importlist': ( '%C', (0, maxint, ', ') ), + 'importfrom': ( '%|from %[2]{pattr} import %c\n', + (3, 'importlist') ), + 'importstar': ( '%|from %[2]{pattr} import *\n', ), } @@ -299,7 +298,7 @@ MAP = { # for a list. PRECEDENCE = { 'build_list': 0, - 'mapexpr': 0, + 'dict': 0, 'unary_convert': 0, 'dict_comp': 0, 'set_comp': 0, diff --git a/uncompyle6/semantics/fragments.py b/uncompyle6/semantics/fragments.py index 95164bb0..362909c0 100644 --- a/uncompyle6/semantics/fragments.py +++ b/uncompyle6/semantics/fragments.py @@ -1308,10 +1308,10 @@ class FragmentsWalker(pysource.SourceWalker, object): self.write(')') self.set_pos_info(node, start, len(self.f.getvalue())) - def n_mapexpr(self, node): + def n_dict(self, node): """ - prettyprint a mapexpr - 'mapexpr' is something like k = {'a': 1, 'b': 42 }" + prettyprint a dict + 'dict' is something like k = {'a': 1, 'b': 42 }" """ p = self.prec self.prec = 100 @@ -1324,7 +1324,7 @@ class FragmentsWalker(pysource.SourceWalker, object): if self.version > 3.0: if node[0].kind.startswith('kvlist'): - # Python 3.5+ style key/value list in mapexpr + # Python 3.5+ style key/value list in dict kv_node = node[0] l = list(kv_node) i = 0 @@ -1339,7 +1339,7 @@ class FragmentsWalker(pysource.SourceWalker, object): pass pass elif node[1].kind.startswith('kvlist'): - # Python 3.0..3.4 style key/value list in mapexpr + # Python 3.0..3.4 style key/value list in dict kv_node = node[1] l = list(kv_node) if len(l) > 0 and l[0].kind == 'kv3': diff --git a/uncompyle6/semantics/pysource.py b/uncompyle6/semantics/pysource.py index 04149643..412f0173 100644 --- a/uncompyle6/semantics/pysource.py +++ b/uncompyle6/semantics/pysource.py @@ -1586,10 +1586,10 @@ class SourceWalker(GenericASTTraversal, object): self.write(')') - def n_mapexpr(self, node): + def n_dict(self, node): """ - prettyprint a mapexpr - 'mapexpr' is something like k = {'a': 1, 'b': 42}" + prettyprint a dict + 'dict' is something like k = {'a': 1, 'b': 42}" We will source-code use line breaks to guide us when to break. """ p = self.prec @@ -1602,7 +1602,7 @@ class SourceWalker(GenericASTTraversal, object): if self.version >= 3.0 and not self.is_pypy: if node[0].kind.startswith('kvlist'): - # Python 3.5+ style key/value list in mapexpr + # Python 3.5+ style key/value list in dict kv_node = node[0] l = list(kv_node) i = 0 @@ -1625,7 +1625,7 @@ class SourceWalker(GenericASTTraversal, object): pass pass elif len(node) > 1 and node[1].kind.startswith('kvlist'): - # Python 3.0..3.4 style key/value list in mapexpr + # Python 3.0..3.4 style key/value list in dict kv_node = node[1] l = list(kv_node) if len(l) > 0 and l[0].kind == 'kv3': @@ -2055,7 +2055,7 @@ class SourceWalker(GenericASTTraversal, object): TABLE_R[k] = entry pass - # handled by n_mapexpr: + # handled by n_dict: # if op == 'BUILD_SLICE': TABLE_R[k] = ('%C' , (0,-1,':')) # handled by n_build_list: # if op == 'BUILD_LIST': TABLE_R[k] = ('[%C]' , (0,-1,', '))