From 23551ea70f6d34c30153f35d207cfed1820a6d25 Mon Sep 17 00:00:00 2001 From: rocky Date: Thu, 23 Dec 2021 22:24:45 -0500 Subject: [PATCH] unmap_dict -> dict_doublestar ... This matches Python's AST (Dict) better. Variations or specializations of an AST name, e.g. "unmap" should come at the end, not the beginning. --- uncompyle6/parsers/parse3.py | 6 +++--- uncompyle6/parsers/parse35.py | 4 ++-- uncompyle6/parsers/parse37base.py | 10 +++++----- uncompyle6/semantics/customize35.py | 2 +- uncompyle6/semantics/customize36.py | 2 +- uncompyle6/semantics/customize37.py | 3 +-- 6 files changed, 13 insertions(+), 14 deletions(-) diff --git a/uncompyle6/parsers/parse3.py b/uncompyle6/parsers/parse3.py index bac6ae8e..75e7b4eb 100644 --- a/uncompyle6/parsers/parse3.py +++ b/uncompyle6/parsers/parse3.py @@ -775,7 +775,7 @@ class Python3Parser(PythonParser): # FIXME: Use the attr # so this doesn't run into exponential parsing time. if opname.startswith("BUILD_MAP_UNPACK"): - # FIXME: start here. The LHS should be unmap_dict, not dict. + # FIXME: start here. The LHS should be dict_unmap, not dict. # FIXME: really we need a combination of dict_entry-like things. # It just so happens the most common case is not to mix # dictionary comphensions with dictionary, elements @@ -786,8 +786,8 @@ class Python3Parser(PythonParser): ) self.addRule(rule, nop_func) rule = """ - expr ::= unmap_dict - unmap_dict ::= %s%s + expr ::= dict_unmap + dict_unmap ::= %s%s """ % ( "expr " * token.attr, opname, diff --git a/uncompyle6/parsers/parse35.py b/uncompyle6/parsers/parse35.py index 4ca8d2c7..edfc4f92 100644 --- a/uncompyle6/parsers/parse35.py +++ b/uncompyle6/parsers/parse35.py @@ -201,8 +201,8 @@ class Python35Parser(Python34Parser): self.addRule(rules_str, nop_func) elif opname == 'BUILD_MAP_UNPACK': self.addRule(""" - expr ::= unmap_dict - unmap_dict ::= dict_comp BUILD_MAP_UNPACK + expr ::= dict_unmap + dict_unmap ::= dict_comp BUILD_MAP_UNPACK """, nop_func) elif opname == 'SETUP_WITH': diff --git a/uncompyle6/parsers/parse37base.py b/uncompyle6/parsers/parse37base.py index 5d45b33e..75ffb34f 100644 --- a/uncompyle6/parsers/parse37base.py +++ b/uncompyle6/parsers/parse37base.py @@ -336,8 +336,8 @@ class Python37BaseParser(PythonParser): if opname == "BUILD_MAP_UNPACK": self.addRule( """ - expr ::= unmap_dict - unmap_dict ::= dict_comp BUILD_MAP_UNPACK + expr ::= dict_unmap + dict_unmap ::= dict_comp BUILD_MAP_UNPACK """, nop_func, ) @@ -367,7 +367,7 @@ class Python37BaseParser(PythonParser): # FIXME: Use the attr # so this doesn't run into exponential parsing time. if opname.startswith("BUILD_MAP_UNPACK"): - # FIXME: start here. The LHS should be unmap_dict, not dict. + # FIXME: start here. The LHS should be dict_unmap, not dict. # FIXME: really we need a combination of dict_entry-like things. # It just so happens the most common case is not to mix # dictionary comphensions with dictionary, elements @@ -375,8 +375,8 @@ class Python37BaseParser(PythonParser): rule = "dict ::= %s%s" % ("dict_comp " * token.attr, opname) self.addRule(rule, nop_func) rule = """ - expr ::= unmap_dict - unmap_dict ::= %s%s + expr ::= dict_unmap + dict_unmap ::= %s%s """ % ( "expr " * token.attr, opname, diff --git a/uncompyle6/semantics/customize35.py b/uncompyle6/semantics/customize35.py index 04c13aff..02709b8e 100644 --- a/uncompyle6/semantics/customize35.py +++ b/uncompyle6/semantics/customize35.py @@ -51,7 +51,7 @@ def customize_for_version35(self, version): (2, "store"), 3, ), - "unmap_dict": ("{**%C}", (0, -1, ", **")), + "dict_unmap": ("{**%C}", (0, -1, ", **")), # "unmapexpr": ( "{**%c}", 0), # done by n_unmapexpr } ) diff --git a/uncompyle6/semantics/customize36.py b/uncompyle6/semantics/customize36.py index e8741144..7c60f1d0 100644 --- a/uncompyle6/semantics/customize36.py +++ b/uncompyle6/semantics/customize36.py @@ -44,7 +44,7 @@ def customize_for_version36(self, version): PRECEDENCE["call_ex_kw2"] = 1 PRECEDENCE["call_ex_kw3"] = 1 PRECEDENCE["call_ex_kw4"] = 1 - PRECEDENCE["unmap_dict"] = 0 + PRECEDENCE["dict_unmap"] = 0 # **{ ... } PRECEDENCE["formatted_value1"] = 100 TABLE_DIRECT.update( diff --git a/uncompyle6/semantics/customize37.py b/uncompyle6/semantics/customize37.py index 91d25032..81d18782 100644 --- a/uncompyle6/semantics/customize37.py +++ b/uncompyle6/semantics/customize37.py @@ -38,7 +38,6 @@ def customize_for_version37(self, version): PRECEDENCE["formatted_value1"] = 100 PRECEDENCE["if_exp_37a"] = 28 PRECEDENCE["if_exp_37b"] = 28 - PRECEDENCE["unmap_dict"] = 0 TABLE_DIRECT.update( { @@ -161,7 +160,7 @@ def customize_for_version37(self, version): "testfalsel": ("not %c", (0, "expr")), "try_except36": ("%|try:\n%+%c%-%c\n\n", 1, -2), "tryfinally36": ("%|try:\n%+%c%-%|finally:\n%+%c%-\n\n", (1, "returns"), 3), - "unmap_dict": ("{**%C}", (0, -1, ", **")), + "dict_unmap": ("{**%C}", (0, -1, ", **")), "unpack_list": ("*%c", (0, "list")), "yield_from": ("yield from %c", (0, "expr")), }