From 19a95be3efa20449afaf69640e5697131e4a6792 Mon Sep 17 00:00:00 2001 From: rocky Date: Sat, 30 Mar 2019 00:27:48 -0400 Subject: [PATCH] WIP - more 3.8 grammar stuff --- setup.py | 4 ++-- uncompyle6/bin/uncompile.py | 4 ++-- uncompyle6/parsers/parse38.py | 29 +++++++++++++++++++++++++++++ 3 files changed, 33 insertions(+), 4 deletions(-) diff --git a/setup.py b/setup.py index 59953230..dc120134 100755 --- a/setup.py +++ b/setup.py @@ -4,8 +4,8 @@ import sys """Setup script for the 'uncompyle6' distribution.""" SYS_VERSION = sys.version_info[0:2] -if not ((2, 6) <= SYS_VERSION <= (3, 7)): - mess = "Python Release 2.6 .. 3.7 are supported in this code branch." +if not ((2, 6) <= SYS_VERSION <= (3, 8)): + mess = "Python Release 2.6 .. 3.8 are supported in this code branch." if ((2, 4) <= SYS_VERSION <= (2, 7)): mess += ("\nFor your Python, version %s, use the python-2.4 code/branch." % sys.version[0:3]) diff --git a/uncompyle6/bin/uncompile.py b/uncompyle6/bin/uncompile.py index 1151520a..c482bcbd 100755 --- a/uncompyle6/bin/uncompile.py +++ b/uncompyle6/bin/uncompile.py @@ -72,9 +72,9 @@ def main_bin(): if not (sys.version_info[0:2] in ((2, 6), (2, 7), (3, 0), (3, 1), (3, 2), (3, 3), (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) sys.exit(-1) diff --git a/uncompyle6/parsers/parse38.py b/uncompyle6/parsers/parse38.py index 2b6ea9b8..f2d34b28 100644 --- a/uncompyle6/parsers/parse38.py +++ b/uncompyle6/parsers/parse38.py @@ -23,10 +23,39 @@ from uncompyle6.parsers.parse37 import 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): super(Python38Parser, self).__init__(debug_parser) 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): pass