You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-04 01:09:52 +08:00
WIP - more 3.8 grammar stuff
This commit is contained in:
4
setup.py
4
setup.py
@@ -4,8 +4,8 @@ import sys
|
|||||||
"""Setup script for the 'uncompyle6' distribution."""
|
"""Setup script for the 'uncompyle6' distribution."""
|
||||||
|
|
||||||
SYS_VERSION = sys.version_info[0:2]
|
SYS_VERSION = sys.version_info[0:2]
|
||||||
if not ((2, 6) <= SYS_VERSION <= (3, 7)):
|
if not ((2, 6) <= SYS_VERSION <= (3, 8)):
|
||||||
mess = "Python Release 2.6 .. 3.7 are supported in this code branch."
|
mess = "Python Release 2.6 .. 3.8 are supported in this code branch."
|
||||||
if ((2, 4) <= SYS_VERSION <= (2, 7)):
|
if ((2, 4) <= SYS_VERSION <= (2, 7)):
|
||||||
mess += ("\nFor your Python, version %s, use the python-2.4 code/branch." %
|
mess += ("\nFor your Python, version %s, use the python-2.4 code/branch." %
|
||||||
sys.version[0:3])
|
sys.version[0:3])
|
||||||
|
@@ -72,9 +72,9 @@ def main_bin():
|
|||||||
if not (sys.version_info[0:2] in ((2, 6), (2, 7), (3, 0),
|
if not (sys.version_info[0:2] in ((2, 6), (2, 7), (3, 0),
|
||||||
(3, 1), (3, 2), (3, 3),
|
(3, 1), (3, 2), (3, 3),
|
||||||
(3, 4), (3, 5), (3, 6),
|
(3, 4), (3, 5), (3, 6),
|
||||||
(3, 7)
|
(3, 7), (3, 8)
|
||||||
)):
|
)):
|
||||||
print('Error: %s requires Python 2.6-3.7' % program,
|
print('Error: %s requires Python 2.6-3.8' % program,
|
||||||
file=sys.stderr)
|
file=sys.stderr)
|
||||||
sys.exit(-1)
|
sys.exit(-1)
|
||||||
|
|
||||||
|
@@ -23,10 +23,39 @@ from uncompyle6.parsers.parse37 import Python37Parser
|
|||||||
|
|
||||||
class Python38Parser(Python37Parser):
|
class Python38Parser(Python37Parser):
|
||||||
|
|
||||||
|
def p_38misc(self, args):
|
||||||
|
"""
|
||||||
|
for ::= expr get_iter store for_block JUMP_BACK
|
||||||
|
forelsestmt ::= expr for_iter store for_block POP_BLOCK else_suite
|
||||||
|
forelselaststmt ::= expr for_iter store for_block POP_BLOCK else_suitec
|
||||||
|
forelselaststmtl ::= expr for_iter store for_block POP_BLOCK else_suitel
|
||||||
|
whilestmt ::= testexpr l_stmts_opt COME_FROM JUMP_BACK POP_BLOCK
|
||||||
|
whilestmt ::= testexpr l_stmts_opt JUMP_BACK POP_BLOCK
|
||||||
|
whilestmt ::= testexpr returns POP_BLOCK
|
||||||
|
while1elsestmt ::= l_stmts JUMP_BACK
|
||||||
|
whileelsestmt ::= testexpr l_stmts_opt JUMP_BACK POP_BLOCK
|
||||||
|
whileTruestmt ::= l_stmts_opt JUMP_BACK POP_BLOCK
|
||||||
|
while1stmt ::= l_stmts COME_FROM_LOOP
|
||||||
|
while1stmt ::= l_stmts COME_FROM JUMP_BACK COME_FROM_LOOP
|
||||||
|
while1elsestmt ::= l_stmts JUMP_BACK
|
||||||
|
whileTruestmt ::= l_stmts_opt JUMP_BACK NOP
|
||||||
|
whileTruestmt ::= l_stmts_opt JUMP_BACK POP_BLOCK NOP
|
||||||
|
"""
|
||||||
|
|
||||||
def __init__(self, debug_parser=PARSER_DEFAULT_DEBUG):
|
def __init__(self, debug_parser=PARSER_DEFAULT_DEBUG):
|
||||||
super(Python38Parser, self).__init__(debug_parser)
|
super(Python38Parser, self).__init__(debug_parser)
|
||||||
self.customized = {}
|
self.customized = {}
|
||||||
|
|
||||||
|
def customize_grammar_rules(self, tokens, customize):
|
||||||
|
from trepan.api import debug; debug()
|
||||||
|
self.remove_rules("""
|
||||||
|
for ::= SETUP_LOOP expr for_iter store for_block POP_BLOCK
|
||||||
|
forelsestmt ::= SETUP_LOOP expr for_iter store for_block POP_BLOCK else_suite
|
||||||
|
forelselaststmt ::= SETUP_LOOP expr for_iter store for_block POP_BLOCK else_suitec
|
||||||
|
forelselaststmtl ::= SETUP_LOOP expr for_iter store for_block POP_BLOCK else_suitel
|
||||||
|
for ::= SETUP_LOOP expr for_iter store for_block POP_BLOCK NOP
|
||||||
|
""")
|
||||||
|
super(Python37Parser, self).customize_grammar_rules(tokens, customize)
|
||||||
|
|
||||||
class Python38ParserSingle(Python38Parser, PythonParserSingle):
|
class Python38ParserSingle(Python38Parser, PythonParserSingle):
|
||||||
pass
|
pass
|
||||||
|
Reference in New Issue
Block a user