You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-02 16:44:46 +08:00
Isolaate kv, kv2 and kv3 better
This commit is contained in:
BIN
test/bytecode_3.2/03_map.pyc
Normal file
BIN
test/bytecode_3.2/03_map.pyc
Normal file
Binary file not shown.
BIN
test/bytecode_3.3/03_map.pyc
Normal file
BIN
test/bytecode_3.3/03_map.pyc
Normal file
Binary file not shown.
BIN
test/bytecode_3.5/03_map.pyc
Normal file
BIN
test/bytecode_3.5/03_map.pyc
Normal file
Binary file not shown.
@@ -516,13 +516,9 @@ class PythonParser(GenericASTBuilder):
|
||||
|
||||
mapexpr ::= BUILD_MAP kvlist
|
||||
|
||||
kvlist ::= kvlist kv2
|
||||
kvlist ::= kvlist kv3
|
||||
# Non-null kvlist items are broken out in the indiviual grammars
|
||||
kvlist ::=
|
||||
|
||||
kv2 ::= DUP_TOP expr expr ROT_THREE STORE_SUBSCR
|
||||
kv3 ::= expr expr STORE_MAP
|
||||
|
||||
exprlist ::= exprlist expr
|
||||
exprlist ::= expr
|
||||
|
||||
|
@@ -18,11 +18,14 @@ class Python22Parser(Python23Parser):
|
||||
COME_FROM POP_TOP COME_FROM
|
||||
list_for ::= expr _for designator list_iter CONTINUE JUMP_FORWARD
|
||||
COME_FROM POP_TOP COME_FROM
|
||||
|
||||
kvlist ::= kvlist kv
|
||||
kv ::= DUP_TOP expr ROT_TWO expr STORE_SUBSCR
|
||||
'''
|
||||
|
||||
def add_custom_rules(self, tokens, customize):
|
||||
super(Python22Parser, self).add_custom_rules(tokens, customize)
|
||||
self.remove_rules("""
|
||||
kvlist ::= kvlist kv2
|
||||
""")
|
||||
|
||||
class Python22ParserSingle(Python23Parser, PythonParserSingle):
|
||||
pass
|
||||
|
||||
|
@@ -47,9 +47,18 @@ class Python24Parser(Python25Parser):
|
||||
|
||||
# Python 2.5+ adds POP_TOP at the end
|
||||
gen_comp_body ::= expr YIELD_VALUE
|
||||
|
||||
# Python 2.4
|
||||
# Python 2.6, 2.7 and 3.3+ use kv3
|
||||
# Python 2.3- use kv
|
||||
kvlist ::= kvlist kv2
|
||||
kv2 ::= DUP_TOP expr expr ROT_THREE STORE_SUBSCR
|
||||
'''
|
||||
|
||||
def add_custom_rules(self, tokens, customize):
|
||||
self.remove_rules("""
|
||||
kvlist ::= kvlist kv3
|
||||
""")
|
||||
super(Python24Parser, self).add_custom_rules(tokens, customize)
|
||||
if self.version == 2.4:
|
||||
self.check_reduce['nop_stmt'] = 'tokens'
|
||||
|
@@ -43,6 +43,10 @@ class Python25Parser(Python26Parser):
|
||||
|
||||
with_cleanup ::= LOAD_FAST DELETE_FAST WITH_CLEANUP END_FINALLY
|
||||
with_cleanup ::= LOAD_NAME DELETE_NAME WITH_CLEANUP END_FINALLY
|
||||
|
||||
|
||||
kvlist ::= kvlist kv
|
||||
kv ::= DUP_TOP expr ROT_TWO expr STORE_SUBSCR
|
||||
"""
|
||||
|
||||
def add_custom_rules(self, tokens, customize):
|
||||
|
@@ -254,6 +254,8 @@ class Python26Parser(Python2Parser):
|
||||
return_if_lambda ::= RETURN_END_IF_LAMBDA POP_TOP
|
||||
conditional_lambda ::= expr jmp_false_then expr return_if_lambda
|
||||
return_stmt_lambda LAMBDA_MARKER
|
||||
kvlist ::= kvlist kv3
|
||||
kv3 ::= expr expr STORE_MAP
|
||||
"""
|
||||
|
||||
def add_custom_rules(self, tokens, customize):
|
||||
|
@@ -115,6 +115,8 @@ class Python27Parser(Python2Parser):
|
||||
return_if_lambda ::= RETURN_END_IF_LAMBDA COME_FROM
|
||||
conditional_lambda ::= expr jmp_false expr return_if_lambda
|
||||
return_stmt_lambda LAMBDA_MARKER
|
||||
kvlist ::= kvlist kv3
|
||||
kv3 ::= expr expr STORE_MAP
|
||||
"""
|
||||
|
||||
def add_custom_rules(self, tokens, customize):
|
||||
|
@@ -49,6 +49,7 @@ class Python32Parser(Python3Parser):
|
||||
|
||||
stmt ::= del_deref_stmt
|
||||
del_deref_stmt ::= DELETE_DEREF
|
||||
kv3 ::= expr expr STORE_MAP
|
||||
"""
|
||||
pass
|
||||
|
||||
|
Reference in New Issue
Block a user