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.
This commit is contained in:
rocky
2021-12-23 22:24:45 -05:00
parent 30aad42aae
commit 23551ea70f
6 changed files with 13 additions and 14 deletions

View File

@@ -775,7 +775,7 @@ class Python3Parser(PythonParser):
# FIXME: Use the attr # FIXME: Use the attr
# so this doesn't run into exponential parsing time. # so this doesn't run into exponential parsing time.
if opname.startswith("BUILD_MAP_UNPACK"): 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. # FIXME: really we need a combination of dict_entry-like things.
# It just so happens the most common case is not to mix # It just so happens the most common case is not to mix
# dictionary comphensions with dictionary, elements # dictionary comphensions with dictionary, elements
@@ -786,8 +786,8 @@ class Python3Parser(PythonParser):
) )
self.addRule(rule, nop_func) self.addRule(rule, nop_func)
rule = """ rule = """
expr ::= unmap_dict expr ::= dict_unmap
unmap_dict ::= %s%s dict_unmap ::= %s%s
""" % ( """ % (
"expr " * token.attr, "expr " * token.attr,
opname, opname,

View File

@@ -201,8 +201,8 @@ class Python35Parser(Python34Parser):
self.addRule(rules_str, nop_func) self.addRule(rules_str, nop_func)
elif opname == 'BUILD_MAP_UNPACK': elif opname == 'BUILD_MAP_UNPACK':
self.addRule(""" self.addRule("""
expr ::= unmap_dict expr ::= dict_unmap
unmap_dict ::= dict_comp BUILD_MAP_UNPACK dict_unmap ::= dict_comp BUILD_MAP_UNPACK
""", nop_func) """, nop_func)
elif opname == 'SETUP_WITH': elif opname == 'SETUP_WITH':

View File

@@ -336,8 +336,8 @@ class Python37BaseParser(PythonParser):
if opname == "BUILD_MAP_UNPACK": if opname == "BUILD_MAP_UNPACK":
self.addRule( self.addRule(
""" """
expr ::= unmap_dict expr ::= dict_unmap
unmap_dict ::= dict_comp BUILD_MAP_UNPACK dict_unmap ::= dict_comp BUILD_MAP_UNPACK
""", """,
nop_func, nop_func,
) )
@@ -367,7 +367,7 @@ class Python37BaseParser(PythonParser):
# FIXME: Use the attr # FIXME: Use the attr
# so this doesn't run into exponential parsing time. # so this doesn't run into exponential parsing time.
if opname.startswith("BUILD_MAP_UNPACK"): 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. # FIXME: really we need a combination of dict_entry-like things.
# It just so happens the most common case is not to mix # It just so happens the most common case is not to mix
# dictionary comphensions with dictionary, elements # dictionary comphensions with dictionary, elements
@@ -375,8 +375,8 @@ class Python37BaseParser(PythonParser):
rule = "dict ::= %s%s" % ("dict_comp " * token.attr, opname) rule = "dict ::= %s%s" % ("dict_comp " * token.attr, opname)
self.addRule(rule, nop_func) self.addRule(rule, nop_func)
rule = """ rule = """
expr ::= unmap_dict expr ::= dict_unmap
unmap_dict ::= %s%s dict_unmap ::= %s%s
""" % ( """ % (
"expr " * token.attr, "expr " * token.attr,
opname, opname,

View File

@@ -51,7 +51,7 @@ def customize_for_version35(self, version):
(2, "store"), (2, "store"),
3, 3,
), ),
"unmap_dict": ("{**%C}", (0, -1, ", **")), "dict_unmap": ("{**%C}", (0, -1, ", **")),
# "unmapexpr": ( "{**%c}", 0), # done by n_unmapexpr # "unmapexpr": ( "{**%c}", 0), # done by n_unmapexpr
} }
) )

View File

@@ -44,7 +44,7 @@ def customize_for_version36(self, version):
PRECEDENCE["call_ex_kw2"] = 1 PRECEDENCE["call_ex_kw2"] = 1
PRECEDENCE["call_ex_kw3"] = 1 PRECEDENCE["call_ex_kw3"] = 1
PRECEDENCE["call_ex_kw4"] = 1 PRECEDENCE["call_ex_kw4"] = 1
PRECEDENCE["unmap_dict"] = 0 PRECEDENCE["dict_unmap"] = 0 # **{ ... }
PRECEDENCE["formatted_value1"] = 100 PRECEDENCE["formatted_value1"] = 100
TABLE_DIRECT.update( TABLE_DIRECT.update(

View File

@@ -38,7 +38,6 @@ def customize_for_version37(self, version):
PRECEDENCE["formatted_value1"] = 100 PRECEDENCE["formatted_value1"] = 100
PRECEDENCE["if_exp_37a"] = 28 PRECEDENCE["if_exp_37a"] = 28
PRECEDENCE["if_exp_37b"] = 28 PRECEDENCE["if_exp_37b"] = 28
PRECEDENCE["unmap_dict"] = 0
TABLE_DIRECT.update( TABLE_DIRECT.update(
{ {
@@ -161,7 +160,7 @@ def customize_for_version37(self, version):
"testfalsel": ("not %c", (0, "expr")), "testfalsel": ("not %c", (0, "expr")),
"try_except36": ("%|try:\n%+%c%-%c\n\n", 1, -2), "try_except36": ("%|try:\n%+%c%-%c\n\n", 1, -2),
"tryfinally36": ("%|try:\n%+%c%-%|finally:\n%+%c%-\n\n", (1, "returns"), 3), "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")), "unpack_list": ("*%c", (0, "list")),
"yield_from": ("yield from %c", (0, "expr")), "yield_from": ("yield from %c", (0, "expr")),
} }