dict_unmap -> dict_unpack matches Python AST better

This commit is contained in:
rocky
2021-12-26 19:03:58 -05:00
parent 3234673422
commit 165115289a
6 changed files with 56 additions and 48 deletions

View File

@@ -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 dict_unmap, not dict.
# FIXME: start here. The LHS should be dict_unpack, 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 ::= dict_unmap
dict_unmap ::= %s%s
expr ::= dict_unpack
dict_unpack ::= %s%s
""" % (
"expr " * token.attr,
opname,

View File

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

View File

@@ -336,8 +336,8 @@ class Python37BaseParser(PythonParser):
if opname == "BUILD_MAP_UNPACK":
self.addRule(
"""
expr ::= dict_unmap
dict_unmap ::= dict_comp BUILD_MAP_UNPACK
expr ::= dict_unpack
dict_unpack ::= 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 dict_unmap, not dict.
# FIXME: start here. The LHS should be dict_unpack, 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 ::= dict_unmap
dict_unmap ::= %s%s
expr ::= dict_unpack
dict_unpack ::= %s%s
""" % (
"expr " * token.attr,
opname,