You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-04 09:22:40 +08:00
WIP Python-2.6 but don't remove opcodes
The scheme for turning 2.6 bytecode into 2.7 psuedo bytecode I think is a lose. I won't work for fragment handling. Instead, change the grammar and syntax rules This also has the benefits: * We see how code generation changed over releases by looking at grammar and semantic rules rather than arbitrary code * We can better assocate with what's running (in a sense this is a restatement of broken fragment handling) * With the right structure in place we are in a better position to handle 2.5, 2.4, etc. That is, after a while, the incremental changes to get say from python 2.3 bytecode to python 2.7 are great. Conflicts: uncompyle6/parsers/astnode.py
This commit is contained in:
40
uncompyle6/parsers/parse27.py
Normal file
40
uncompyle6/parsers/parse27.py
Normal file
@@ -0,0 +1,40 @@
|
||||
from uncompyle6.parser import PythonParserSingle
|
||||
from spark_parser import DEFAULT_DEBUG as PARSER_DEFAULT_DEBUG
|
||||
from uncompyle6.parsers.parse2 import Python2Parser
|
||||
|
||||
class Python27Parser(Python2Parser):
|
||||
|
||||
def __init__(self, debug_parser=PARSER_DEFAULT_DEBUG):
|
||||
super(Python27Parser, self).__init__(debug_parser)
|
||||
self.customized = {}
|
||||
|
||||
def p_try27(self, args):
|
||||
"""
|
||||
trystmt ::= SETUP_EXCEPT suite_stmts_opt POP_BLOCK
|
||||
try_middle COME_FROM
|
||||
|
||||
try_middle ::= JUMP_FORWARD COME_FROM except_stmts
|
||||
END_FINALLY COME_FROM
|
||||
try_middle ::= jmp_abs COME_FROM except_stmts
|
||||
END_FINALLY
|
||||
|
||||
except_cond1 ::= DUP_TOP expr COMPARE_OP
|
||||
jmp_false POP_TOP POP_TOP POP_TOP
|
||||
|
||||
except_cond2 ::= DUP_TOP expr COMPARE_OP
|
||||
jmp_false POP_TOP designator POP_TOP
|
||||
"""
|
||||
|
||||
def p_misc27(self, args):
|
||||
"""
|
||||
assert ::= assert_expr jmp_true LOAD_ASSERT RAISE_VARARGS_1
|
||||
_ifstmts_jump ::= c_stmts_opt JUMP_FORWARD COME_FROM
|
||||
"""
|
||||
|
||||
class Python26ParserSingle(Python2Parser, PythonParserSingle):
|
||||
pass
|
||||
|
||||
if __name__ == '__main__':
|
||||
# Check grammar
|
||||
p = Python27Parser()
|
||||
p.checkGrammar()
|
Reference in New Issue
Block a user