diff --git a/test/stdlib/runtests.sh b/test/stdlib/runtests.sh index aee3cb7f..59d754e0 100755 --- a/test/stdlib/runtests.sh +++ b/test/stdlib/runtests.sh @@ -6,6 +6,9 @@ FULLVERSION=$(pyenv local) PYVERSION=${FULLVERSION%.*} MINOR=${FULLVERSION##?.?.} +# DECOMPILER=uncompyle2 +DECOMPILER="$fulldir/../../bin/uncompyle6" + typeset -i STOP_ONERROR=1 typeset -A SKIP_TESTS @@ -162,7 +165,7 @@ for file in $files; do $fulldir/compile-file.py $file && \ mv $file{,.orig} && \ echo ========== $(date +%X) Decompiling $file =========== - $fulldir/../../bin/uncompyle6 $decompiled_file > $file + $DECOMPILER $decompiled_file > $file rc=$? if (( rc == 0 )) ; then echo ========== $(date +%X) Running $file =========== diff --git a/uncompyle6/parser.py b/uncompyle6/parser.py index 030cd1f3..46ce61a1 100644 --- a/uncompyle6/parser.py +++ b/uncompyle6/parser.py @@ -551,7 +551,7 @@ class PythonParser(GenericASTBuilder): def parse(p, tokens, customize): - p.add_custom_rules(tokens, customize) + p.customize_grammar_rules(tokens, customize) ast = p.parse(tokens) # p.cleanup() return ast diff --git a/uncompyle6/parsers/parse2.py b/uncompyle6/parsers/parse2.py index 9eab50c8..6796d4a0 100644 --- a/uncompyle6/parsers/parse2.py +++ b/uncompyle6/parsers/parse2.py @@ -218,7 +218,7 @@ class Python2Parser(PythonParser): binary_op ::= BINARY_DIVIDE """ - def add_custom_rules(self, tokens, customize): + def customize_grammar_rules(self, tokens, customize): """The base grammar we start out for a Python version even with the subclassing is, well, is pretty base. And we want it that way: lean and mean so that parsing will go faster. diff --git a/uncompyle6/parsers/parse22.py b/uncompyle6/parsers/parse22.py index 56d1136c..ad3c05ac 100644 --- a/uncompyle6/parsers/parse22.py +++ b/uncompyle6/parsers/parse22.py @@ -20,8 +20,8 @@ class Python22Parser(Python23Parser): COME_FROM POP_TOP COME_FROM ''' - def add_custom_rules(self, tokens, customize): - super(Python22Parser, self).add_custom_rules(tokens, customize) + def customize_grammar_rules(self, tokens, customize): + super(Python22Parser, self).customize_grammar_rules(tokens, customize) self.remove_rules(""" kvlist ::= kvlist kv2 """) diff --git a/uncompyle6/parsers/parse23.py b/uncompyle6/parsers/parse23.py index df7d53cb..da1a1f82 100644 --- a/uncompyle6/parsers/parse23.py +++ b/uncompyle6/parsers/parse23.py @@ -52,8 +52,8 @@ class Python23Parser(Python24Parser): conditional ::= expr jmp_false expr JUMP_FORWARD expr COME_FROM ''' - def add_custom_rules(self, tokens, customize): - super(Python23Parser, self).add_custom_rules(tokens, customize) + def customize_grammar_rules(self, tokens, customize): + super(Python23Parser, self).customize_grammar_rules(tokens, customize) def reduce_is_invalid(self, rule, ast, tokens, first, last): invalid = super(Python24Parser, diff --git a/uncompyle6/parsers/parse24.py b/uncompyle6/parsers/parse24.py index 39405301..02717072 100644 --- a/uncompyle6/parsers/parse24.py +++ b/uncompyle6/parsers/parse24.py @@ -52,7 +52,7 @@ class Python24Parser(Python25Parser): kv2 ::= DUP_TOP expr expr ROT_THREE STORE_SUBSCR ''' - def add_custom_rules(self, tokens, customize): + def customize_grammar_rules(self, tokens, customize): self.remove_rules(""" gen_comp_body ::= expr YIELD_VALUE POP_TOP kvlist ::= kvlist kv3 @@ -67,7 +67,7 @@ class Python24Parser(Python25Parser): stmt ::= withstmt stmt ::= withasstmt """) - super(Python24Parser, self).add_custom_rules(tokens, customize) + super(Python24Parser, self).customize_grammar_rules(tokens, customize) if self.version == 2.4: self.check_reduce['nop_stmt'] = 'tokens' diff --git a/uncompyle6/parsers/parse25.py b/uncompyle6/parsers/parse25.py index 8148f3d0..0632fb59 100644 --- a/uncompyle6/parsers/parse25.py +++ b/uncompyle6/parsers/parse25.py @@ -48,7 +48,7 @@ class Python25Parser(Python26Parser): kv ::= DUP_TOP expr ROT_TWO expr STORE_SUBSCR """ - def add_custom_rules(self, tokens, customize): + def customize_grammar_rules(self, tokens, customize): # Remove grammar rules inherited from Python 2.6 or Python 2 self.remove_rules(""" setupwith ::= DUP_TOP LOAD_ATTR ROT_TWO LOAD_ATTR CALL_FUNCTION_0 POP_TOP @@ -77,7 +77,7 @@ class Python25Parser(Python26Parser): conditional_lambda ::= expr jmp_false_then expr return_if_lambda return_stmt_lambda LAMBDA_MARKER """) - super(Python25Parser, self).add_custom_rules(tokens, customize) + super(Python25Parser, self).customize_grammar_rules(tokens, customize) if self.version == 2.5: self.check_reduce['tryelsestmt'] = 'tokens' diff --git a/uncompyle6/parsers/parse26.py b/uncompyle6/parsers/parse26.py index 2e8caa5a..5a29ccd0 100644 --- a/uncompyle6/parsers/parse26.py +++ b/uncompyle6/parsers/parse26.py @@ -298,13 +298,13 @@ class Python26Parser(Python2Parser): """ - def add_custom_rules(self, tokens, customize): + def customize_grammar_rules(self, tokens, customize): self.remove_rules(""" withasstmt ::= expr SETUP_WITH store suite_stmts_opt POP_BLOCK LOAD_CONST COME_FROM_WITH WITH_CLEANUP END_FINALLY """) - super(Python26Parser, self).add_custom_rules(tokens, customize) + super(Python26Parser, self).customize_grammar_rules(tokens, customize) self.check_reduce['and'] = 'AST' self.check_reduce['list_for'] = 'AST' diff --git a/uncompyle6/parsers/parse27.py b/uncompyle6/parsers/parse27.py index 30c3ebd2..8d22455e 100644 --- a/uncompyle6/parsers/parse27.py +++ b/uncompyle6/parsers/parse27.py @@ -138,14 +138,14 @@ class Python27Parser(Python2Parser): kv3 ::= expr expr STORE_MAP """ - def add_custom_rules(self, tokens, customize): + def customize_grammar_rules(self, tokens, customize): # 2.7 changes COME_FROM to COME_FROM_FINALLY self.remove_rules(""" while1stmt ::= SETUP_LOOP l_stmts JUMP_BACK COME_FROM while1elsestmt ::= SETUP_LOOP l_stmts JUMP_BACK else_suite COME_FROM tryfinallystmt ::= SETUP_FINALLY suite_stmts_opt POP_BLOCK LOAD_CONST COME_FROM suite_stmts_opt END_FINALLY """) - super(Python27Parser, self).add_custom_rules(tokens, customize) + super(Python27Parser, self).customize_grammar_rules(tokens, customize) self.check_reduce['and'] = 'AST' return diff --git a/uncompyle6/parsers/parse3.py b/uncompyle6/parsers/parse3.py index b828cead..7eb9b68a 100644 --- a/uncompyle6/parsers/parse3.py +++ b/uncompyle6/parsers/parse3.py @@ -528,7 +528,7 @@ class Python3Parser(PythonParser): return args_pos, args_kw - def add_custom_rules(self, tokens, customize): + def customize_grammar_rules(self, tokens, customize): """The base grammar we start out for a Python version even with the subclassing is, well, is pretty base. And we want it that way: lean and mean so that parsing will go faster. diff --git a/uncompyle6/parsers/parse30.py b/uncompyle6/parsers/parse30.py index 242bf963..d4efb7f3 100644 --- a/uncompyle6/parsers/parse30.py +++ b/uncompyle6/parsers/parse30.py @@ -44,8 +44,8 @@ class Python30Parser(Python31Parser): setup_finally ::= STORE_FAST SETUP_FINALLY LOAD_FAST DELETE_FAST """ - def add_custom_rules(self, tokens, customize): - super(Python30Parser, self).add_custom_rules(tokens, customize) + def customize_grammar_rules(self, tokens, customize): + super(Python30Parser, self).customize_grammar_rules(tokens, customize) return pass diff --git a/uncompyle6/parsers/parse31.py b/uncompyle6/parsers/parse31.py index 0d2a1b62..f36d7eb3 100644 --- a/uncompyle6/parsers/parse31.py +++ b/uncompyle6/parsers/parse31.py @@ -33,8 +33,8 @@ class Python31Parser(Python32Parser): load ::= LOAD_NAME """ - def add_custom_rules(self, tokens, customize): - super(Python31Parser, self).add_custom_rules(tokens, customize) + def customize_grammar_rules(self, tokens, customize): + super(Python31Parser, self).customize_grammar_rules(tokens, customize) return pass diff --git a/uncompyle6/parsers/parse32.py b/uncompyle6/parsers/parse32.py index 8b859fbe..790951ea 100644 --- a/uncompyle6/parsers/parse32.py +++ b/uncompyle6/parsers/parse32.py @@ -58,7 +58,7 @@ class Python32Parser(Python3Parser): """ pass - def add_custom_rules(self, tokens, customize): + def customize_grammar_rules(self, tokens, customize): self.remove_rules(""" except_handler ::= JUMP_FORWARD COME_FROM except_stmts END_FINALLY COME_FROM except_handler ::= JUMP_FORWARD COME_FROM except_stmts END_FINALLY COME_FROM_EXCEPT @@ -68,7 +68,7 @@ class Python32Parser(Python3Parser): whileTruestmt ::= SETUP_LOOP l_stmts_opt JUMP_BACK NOP COME_FROM_LOOP whileTruestmt ::= SETUP_LOOP l_stmts_opt JUMP_BACK POP_BLOCK NOP COME_FROM_LOOP """) - super(Python32Parser, self).add_custom_rules(tokens, customize) + super(Python32Parser, self).customize_grammar_rules(tokens, customize) for i, token in enumerate(tokens): opname = token.kind if opname.startswith('MAKE_FUNCTION_A'): diff --git a/uncompyle6/parsers/parse33.py b/uncompyle6/parsers/parse33.py index 76e54120..e7d0c14b 100644 --- a/uncompyle6/parsers/parse33.py +++ b/uncompyle6/parsers/parse33.py @@ -26,13 +26,13 @@ class Python33Parser(Python32Parser): jump_excepts come_from_except_clauses """ - def add_custom_rules(self, tokens, customize): + def customize_grammar_rules(self, tokens, customize): self.remove_rules(""" # 3.3+ adds POP_BLOCKS whileTruestmt ::= SETUP_LOOP l_stmts_opt JUMP_BACK NOP COME_FROM_LOOP whileTruestmt ::= SETUP_LOOP l_stmts_opt JUMP_BACK POP_BLOCK NOP COME_FROM_LOOP """) - super(Python33Parser, self).add_custom_rules(tokens, customize) + super(Python33Parser, self).customize_grammar_rules(tokens, customize) return class Python33ParserSingle(Python33Parser, PythonParserSingle): diff --git a/uncompyle6/parsers/parse34.py b/uncompyle6/parsers/parse34.py index 6f8065b5..4e98721c 100644 --- a/uncompyle6/parsers/parse34.py +++ b/uncompyle6/parsers/parse34.py @@ -29,10 +29,10 @@ class Python34Parser(Python33Parser): yield_from ::= expr GET_ITER LOAD_CONST YIELD_FROM """ - def add_custom_rules(self, tokens, customize): + def customize_grammar_rules(self, tokens, customize): # self.remove_rules(""" # """) - super(Python34Parser, self).add_custom_rules(tokens, customize) + super(Python34Parser, self).customize_grammar_rules(tokens, customize) return class Python34ParserSingle(Python34Parser, PythonParserSingle): diff --git a/uncompyle6/parsers/parse35.py b/uncompyle6/parsers/parse35.py index cf9778d7..36e9b7eb 100644 --- a/uncompyle6/parsers/parse35.py +++ b/uncompyle6/parsers/parse35.py @@ -114,7 +114,7 @@ class Python35Parser(Python34Parser): yield_from ::= expr GET_YIELD_FROM_ITER LOAD_CONST YIELD_FROM """ - def add_custom_rules(self, tokens, customize): + def customize_grammar_rules(self, tokens, customize): self.remove_rules(""" yield_from ::= expr GET_ITER LOAD_CONST YIELD_FROM yield_from ::= expr expr YIELD_FROM @@ -125,7 +125,7 @@ class Python35Parser(Python34Parser): POP_BLOCK LOAD_CONST COME_FROM_WITH WITH_CLEANUP END_FINALLY """) - super(Python35Parser, self).add_custom_rules(tokens, customize) + super(Python35Parser, self).customize_grammar_rules(tokens, customize) for i, token in enumerate(tokens): opname = token.kind if opname == 'BUILD_MAP_UNPACK_WITH_CALL': diff --git a/uncompyle6/parsers/parse36.py b/uncompyle6/parsers/parse36.py index 2e69d5f3..9d1e6ec1 100644 --- a/uncompyle6/parsers/parse36.py +++ b/uncompyle6/parsers/parse36.py @@ -52,8 +52,8 @@ class Python36Parser(Python35Parser): try_except36 ::= SETUP_EXCEPT return_stmts except_handler36 opt_come_from_except """ - def add_custom_rules(self, tokens, customize): - super(Python36Parser, self).add_custom_rules(tokens, customize) + def customize_grammar_rules(self, tokens, customize): + super(Python36Parser, self).customize_grammar_rules(tokens, customize) for i, token in enumerate(tokens): opname = token.kind