You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-04 01:09:52 +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
|
mapexpr ::= BUILD_MAP kvlist
|
||||||
|
|
||||||
kvlist ::= kvlist kv2
|
# Non-null kvlist items are broken out in the indiviual grammars
|
||||||
kvlist ::= kvlist kv3
|
|
||||||
kvlist ::=
|
kvlist ::=
|
||||||
|
|
||||||
kv2 ::= DUP_TOP expr expr ROT_THREE STORE_SUBSCR
|
|
||||||
kv3 ::= expr expr STORE_MAP
|
|
||||||
|
|
||||||
exprlist ::= exprlist expr
|
exprlist ::= exprlist expr
|
||||||
exprlist ::= expr
|
exprlist ::= expr
|
||||||
|
|
||||||
|
@@ -18,11 +18,14 @@ class Python22Parser(Python23Parser):
|
|||||||
COME_FROM POP_TOP COME_FROM
|
COME_FROM POP_TOP COME_FROM
|
||||||
list_for ::= expr _for designator list_iter CONTINUE JUMP_FORWARD
|
list_for ::= expr _for designator list_iter CONTINUE JUMP_FORWARD
|
||||||
COME_FROM POP_TOP COME_FROM
|
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):
|
class Python22ParserSingle(Python23Parser, PythonParserSingle):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@@ -47,9 +47,18 @@ class Python24Parser(Python25Parser):
|
|||||||
|
|
||||||
# Python 2.5+ adds POP_TOP at the end
|
# Python 2.5+ adds POP_TOP at the end
|
||||||
gen_comp_body ::= expr YIELD_VALUE
|
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):
|
def add_custom_rules(self, tokens, customize):
|
||||||
|
self.remove_rules("""
|
||||||
|
kvlist ::= kvlist kv3
|
||||||
|
""")
|
||||||
super(Python24Parser, self).add_custom_rules(tokens, customize)
|
super(Python24Parser, self).add_custom_rules(tokens, customize)
|
||||||
if self.version == 2.4:
|
if self.version == 2.4:
|
||||||
self.check_reduce['nop_stmt'] = 'tokens'
|
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_FAST DELETE_FAST WITH_CLEANUP END_FINALLY
|
||||||
with_cleanup ::= LOAD_NAME DELETE_NAME 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):
|
def add_custom_rules(self, tokens, customize):
|
||||||
|
@@ -254,6 +254,8 @@ class Python26Parser(Python2Parser):
|
|||||||
return_if_lambda ::= RETURN_END_IF_LAMBDA POP_TOP
|
return_if_lambda ::= RETURN_END_IF_LAMBDA POP_TOP
|
||||||
conditional_lambda ::= expr jmp_false_then expr return_if_lambda
|
conditional_lambda ::= expr jmp_false_then expr return_if_lambda
|
||||||
return_stmt_lambda LAMBDA_MARKER
|
return_stmt_lambda LAMBDA_MARKER
|
||||||
|
kvlist ::= kvlist kv3
|
||||||
|
kv3 ::= expr expr STORE_MAP
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def add_custom_rules(self, tokens, customize):
|
def add_custom_rules(self, tokens, customize):
|
||||||
|
@@ -115,6 +115,8 @@ class Python27Parser(Python2Parser):
|
|||||||
return_if_lambda ::= RETURN_END_IF_LAMBDA COME_FROM
|
return_if_lambda ::= RETURN_END_IF_LAMBDA COME_FROM
|
||||||
conditional_lambda ::= expr jmp_false expr return_if_lambda
|
conditional_lambda ::= expr jmp_false expr return_if_lambda
|
||||||
return_stmt_lambda LAMBDA_MARKER
|
return_stmt_lambda LAMBDA_MARKER
|
||||||
|
kvlist ::= kvlist kv3
|
||||||
|
kv3 ::= expr expr STORE_MAP
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def add_custom_rules(self, tokens, customize):
|
def add_custom_rules(self, tokens, customize):
|
||||||
|
@@ -49,6 +49,7 @@ class Python32Parser(Python3Parser):
|
|||||||
|
|
||||||
stmt ::= del_deref_stmt
|
stmt ::= del_deref_stmt
|
||||||
del_deref_stmt ::= DELETE_DEREF
|
del_deref_stmt ::= DELETE_DEREF
|
||||||
|
kv3 ::= expr expr STORE_MAP
|
||||||
"""
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user