From 21da5e787ecd38b17bcbe096aca1a06eb36fc14a Mon Sep 17 00:00:00 2001 From: rocky Date: Sat, 9 Jul 2016 21:08:53 -0400 Subject: [PATCH] Start splitting off 3.4 grammar from rest --- test/bytecode_3.4/09_yield_from.pyc | Bin 485 -> 0 bytes uncompyle6/parser.py | 5 ++-- uncompyle6/parsers/parse3.py | 6 ----- uncompyle6/parsers/parse34.py | 35 ++++++++++++++++++++++++++++ 4 files changed, 38 insertions(+), 8 deletions(-) delete mode 100644 test/bytecode_3.4/09_yield_from.pyc create mode 100644 uncompyle6/parsers/parse34.py diff --git a/test/bytecode_3.4/09_yield_from.pyc b/test/bytecode_3.4/09_yield_from.pyc deleted file mode 100644 index 12e5ef2497ed35e3cee37d6f15435f4674fcca93..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 485 zcmZ8cJxc>Y6r6W=QS;$PWw5fax+bv_1QCmXu?dJ^Bp}Oiy9bwCOx(R-0+%Z3E&LV! z4FATp_SRzM+Z9AycHWzL>|16&8r!wE&tdseY{L<%ER%DW9 zN)!L^3SHs$6`FKB&6F^cnT}Ok&8J!!lTIGm$ERYEs!WPRPsXk3LUS6_8O9Qj)3M_$ zt-TtEmTUHE#&ixUV9tsaDVCkda)WE0;-L(9c9-H9X@ALHf&LyHA zX9;AKM`2I~MrFxh=PFk^%Gu@REYh;vOmj8XDk%d;Y%rHjZ!jyjgy69jVxN_ijqUZv7i#bYK(! diff --git a/uncompyle6/parser.py b/uncompyle6/parser.py index 5f80fb19..efc69f68 100644 --- a/uncompyle6/parser.py +++ b/uncompyle6/parser.py @@ -637,10 +637,11 @@ def get_python_parser(version, debug_parser, compile_mode='exec'): else: p = parse3.Python33ParserSingle(debug_parser) elif version == 3.4: + import uncompyle6.parsers.parse34 as parse34 if compile_mode == 'exec': - p = parse3.Python34Parser(debug_parser) + p = parse34.Python34Parser(debug_parser) else: - p = parse3.Python34ParserSingle(debug_parser) + p = parse34.Python34ParserSingle(debug_parser) elif version >= 3.5: if compile_mode == 'exec': p = parse3.Python35onParser(debug_parser) diff --git a/uncompyle6/parsers/parse3.py b/uncompyle6/parsers/parse3.py index 43e17dce..cadb23c1 100644 --- a/uncompyle6/parsers/parse3.py +++ b/uncompyle6/parsers/parse3.py @@ -625,10 +625,6 @@ class Python32ParserSingle(Python32Parser, PythonParserSingle): class Python33ParserSingle(Python33Parser, PythonParserSingle): pass -class Python34ParserSingle(Python34Parser, PythonParserSingle): - pass - - class Python35onParserSingle(Python35onParser, PythonParserSingle): pass @@ -641,8 +637,6 @@ def info(args): arg = args[0] if arg == '3.5': p = Python35onParser() - elif arg == '3.4': - p = Python34Parser() elif arg == '3.3': p = Python33Parser() elif arg == '3.2': diff --git a/uncompyle6/parsers/parse34.py b/uncompyle6/parsers/parse34.py new file mode 100644 index 00000000..917c8baf --- /dev/null +++ b/uncompyle6/parsers/parse34.py @@ -0,0 +1,35 @@ +# Copyright (c) 2016 Rocky Bernstein +""" +spark grammar differences over Python3 for Python 3.4.2. +""" + +from uncompyle6.parser import PythonParserSingle +from spark_parser import DEFAULT_DEBUG as PARSER_DEFAULT_DEBUG +from uncompyle6.parsers.parse3 import Python3Parser + +class Python34Parser(Python3Parser): + + def __init__(self, debug_parser=PARSER_DEFAULT_DEBUG): + super(Python34Parser, self).__init__(debug_parser) + self.customized = {} + + def p_misc34(self, args): + """ + # Python 3.5+ optimizes the trailing two JUMPS away + for_block ::= l_stmts_opt JUMP_ABSOLUTE + """ + +class Python34ParserSingle(Python34Parser, PythonParserSingle): + pass + + +def info(args): + # Check grammar + # Should also add a way to dump grammar + p = Python34Parser() + p.checkGrammar() + + +if __name__ == '__main__': + import sys + info(sys.argv)