You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-02 16:44:46 +08:00
BUILD_MAP_UNPACK'ing of dictionaries in 3.5
This commit is contained in:
Binary file not shown.
@@ -5,3 +5,5 @@
|
||||
# {'c': 1, {'d': 2}, **{'e': 3}}
|
||||
[*[]]
|
||||
{**{0:0 for a in b}}
|
||||
## {**{}, **{}}
|
||||
## {**{}, **{}, **{}}
|
||||
|
@@ -35,6 +35,8 @@ class PythonParser(GenericASTBuilder):
|
||||
'exprlist', 'kvlist', 'kwargs', 'come_froms', '_come_from',
|
||||
# Python < 3
|
||||
'print_items',
|
||||
# Python 3.5+
|
||||
# 'unmap_dict',
|
||||
# PyPy:
|
||||
'kvlist_n'])
|
||||
|
||||
|
@@ -663,14 +663,16 @@ class Python3Parser(PythonParser):
|
||||
rule = 'kvlist_n ::='
|
||||
self.add_unique_rule(rule, 'kvlist_n', 1, customize)
|
||||
rule = "mapexpr ::= BUILD_MAP_n kvlist_n"
|
||||
elif self.version >= 3.5:
|
||||
elif self.version == 3.5:
|
||||
if opname != 'BUILD_MAP_WITH_CALL':
|
||||
rule = kvlist_n + ' ::= ' + 'expr ' * (token.attr*2)
|
||||
if opname == 'BUILD_MAP_UNPACK':
|
||||
lhs = 'unmap_dict'
|
||||
else:
|
||||
lhs = kvlist_n
|
||||
rule = lhs + ' ::= ' + 'expr ' * (token.attr*2)
|
||||
self.add_unique_rule(rule, opname, token.attr, customize)
|
||||
lhs = 'unmapexpr' if opname == 'BUILD_MAP_UNPACK' else' mapexpr'
|
||||
rule = "%s ::= %s %s" % (lhs, kvlist_n, opname)
|
||||
# print("XXX", rule)
|
||||
|
||||
else:
|
||||
rule = kvlist_n + ' ::= ' + 'expr expr STORE_MAP ' * token.attr
|
||||
self.add_unique_rule(rule, opname, token.attr, customize)
|
||||
|
@@ -33,7 +33,12 @@ class Python35Parser(Python34Parser):
|
||||
stmt ::= await_stmt
|
||||
await_stmt ::= await_expr POP_TOP
|
||||
|
||||
expr ::= unmap_dict
|
||||
expr ::= unmapexpr
|
||||
|
||||
unmap_dict ::= mapexpr BUILD_MAP_UNPACK
|
||||
unmap_dict ::= mapexpr unmap_dict
|
||||
|
||||
build_list ::= expr BUILD_MAP_UNPACK
|
||||
|
||||
# Python 3.5+ has WITH_CLEANUP_START/FINISH
|
||||
@@ -132,9 +137,6 @@ class Python35Parser(Python34Parser):
|
||||
# differently than 3.3, 3.4
|
||||
|
||||
yield_from ::= expr GET_YIELD_FROM_ITER LOAD_CONST YIELD_FROM
|
||||
|
||||
expr ::= unmap_dict
|
||||
expr ::= unmapexpr
|
||||
"""
|
||||
|
||||
def add_custom_rules(self, tokens, customize):
|
||||
|
Reference in New Issue
Block a user