From a685c60606cd11ef12b150372e06a3a306d62a2f Mon Sep 17 00:00:00 2001 From: rocky Date: Sat, 5 Nov 2016 21:01:59 -0400 Subject: [PATCH] Make parse 3.0 be its own thing --- uncompyle6/parser.py | 5 +++-- uncompyle6/parsers/parse30.py | 23 +++++++++++++++++++++++ 2 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 uncompyle6/parsers/parse30.py diff --git a/uncompyle6/parser.py b/uncompyle6/parser.py index d096e409..2f2ba996 100644 --- a/uncompyle6/parser.py +++ b/uncompyle6/parser.py @@ -622,10 +622,11 @@ def get_python_parser( else: import uncompyle6.parsers.parse3 as parse3 if version == 3.0: + import uncompyle6.parsers.parse30 as parse30 if compile_mode == 'exec': - p = parse3.Python30Parser(debug_parser) + p = parse30.Python30Parser(debug_parser) else: - p = parse3.Python30ParserSingle(debug_parser) + p = parse30.Python30ParserSingle(debug_parser) elif version == 3.1: import uncompyle6.parsers.parse31 as parse31 if compile_mode == 'exec': diff --git a/uncompyle6/parsers/parse30.py b/uncompyle6/parsers/parse30.py new file mode 100644 index 00000000..1315a688 --- /dev/null +++ b/uncompyle6/parsers/parse30.py @@ -0,0 +1,23 @@ +# Copyright (c) 2016 Rocky Bernstein +""" +spark grammar differences over Python 3.1 for Python 3.0. +""" +from __future__ import print_function + +from uncompyle6.parser import PythonParserSingle +from uncompyle6.parsers.parse31 import Python31Parser + +class Python30Parser(Python31Parser): + + def p_30(self, args): + """ + # Store locals is only in Python 3.0 to 3.3 + stmt ::= store_locals + store_locals ::= LOAD_FAST STORE_LOCALS + + jmp_true ::= JUMP_IF_TRUE_OR_POP POP_TOP + _ifstmts_jump ::= c_stmts_opt JUMP_FORWARD POP_TOP COME_FROM + """ + +class Python31ParserSingle(Python31Parser, PythonParserSingle): + pass