Files
python-uncompyle6/uncompyle6/parsers/parse27.py
rocky fa7d8f955a 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
2016-06-24 18:15:59 -04:00

41 lines
1.3 KiB
Python

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()