You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-03 00:45:53 +08:00
More spark-parser 2.7.0 compatabilithy changes
This commit is contained in:
@@ -11,12 +11,12 @@ def test_grammar():
|
||||
remain_tokens = set([re.sub('_CONT$','', t) for t in remain_tokens])
|
||||
remain_tokens = set(remain_tokens) - opcode_set
|
||||
assert remain_tokens == set([]), \
|
||||
"Remaining tokens %s\n====\n%s" % (remain_tokens, p.dumpGrammar())
|
||||
"Remaining tokens %s\n====\n%s" % (remain_tokens, p.dump_grammar())
|
||||
|
||||
p = get_python_parser(PYTHON_VERSION, is_pypy=IS_PYPY)
|
||||
lhs, rhs, tokens, right_recursive = p.check_sets()
|
||||
expect_lhs = set(['expr1024', 'pos_arg'])
|
||||
unused_rhs = frozenset(['build_list', 'call_function', 'mkfunc',
|
||||
unused_rhs = set(['build_list', 'call_function', 'mkfunc',
|
||||
'mklambda',
|
||||
'unpack', 'unpack_list'])
|
||||
expect_right_recursive = frozenset([('designList',
|
||||
|
@@ -733,7 +733,7 @@ def get_python_parser(
|
||||
else:
|
||||
p = parse3.Python3ParserSingle(debug_parser)
|
||||
p.version = version
|
||||
# p.dumpGrammar() # debug
|
||||
# p.dump_grammar() # debug
|
||||
return p
|
||||
|
||||
class PythonParserSingle(PythonParser):
|
||||
|
@@ -29,8 +29,8 @@ class Python15ParserSingle(Python21Parser, PythonParserSingle):
|
||||
if __name__ == '__main__':
|
||||
# Check grammar
|
||||
p = Python15Parser()
|
||||
p.checkGrammar()
|
||||
p.dumpGrammar()
|
||||
p.check_grammar()
|
||||
p.dump_grammar()
|
||||
|
||||
# local variables:
|
||||
# tab-width: 4
|
||||
|
@@ -417,4 +417,4 @@ class Python2ParserSingle(Python2Parser, PythonParserSingle):
|
||||
if __name__ == '__main__':
|
||||
# Check grammar
|
||||
p = Python2Parser()
|
||||
p.checkGrammar()
|
||||
p.check_grammar()
|
||||
|
@@ -33,8 +33,8 @@ class Python21ParserSingle(Python22Parser, PythonParserSingle):
|
||||
if __name__ == '__main__':
|
||||
# Check grammar
|
||||
p = Python21Parser()
|
||||
p.checkGrammar()
|
||||
p.dumpGrammar()
|
||||
p.check_grammar()
|
||||
p.dump_grammar()
|
||||
|
||||
# local variables:
|
||||
# tab-width: 4
|
||||
|
@@ -26,8 +26,8 @@ class Python22ParserSingle(Python23Parser, PythonParserSingle):
|
||||
if __name__ == '__main__':
|
||||
# Check grammar
|
||||
p = Python22Parser()
|
||||
p.checkGrammar()
|
||||
p.dumpGrammar()
|
||||
p.check_grammar()
|
||||
p.dump_grammar()
|
||||
|
||||
# local variables:
|
||||
# tab-width: 4
|
||||
|
@@ -67,8 +67,8 @@ class Python23ParserSingle(Python23Parser, PythonParserSingle):
|
||||
if __name__ == '__main__':
|
||||
# Check grammar
|
||||
p = Python23Parser()
|
||||
p.checkGrammar()
|
||||
p.dumpGrammar()
|
||||
p.check_grammar()
|
||||
p.dump_grammar()
|
||||
|
||||
# local variables:
|
||||
# tab-width: 4
|
||||
|
@@ -71,4 +71,4 @@ class Python24ParserSingle(Python24Parser, PythonParserSingle):
|
||||
if __name__ == '__main__':
|
||||
# Check grammar
|
||||
p = Python24Parser()
|
||||
p.checkGrammar()
|
||||
p.check_grammar()
|
||||
|
@@ -60,4 +60,4 @@ class Python25ParserSingle(Python26Parser, PythonParserSingle):
|
||||
if __name__ == '__main__':
|
||||
# Check grammar
|
||||
p = Python25Parser()
|
||||
p.checkGrammar()
|
||||
p.check_grammar()
|
||||
|
@@ -276,7 +276,7 @@ class Python26ParserSingle(Python2Parser, PythonParserSingle):
|
||||
if __name__ == '__main__':
|
||||
# Check grammar
|
||||
p = Python26Parser()
|
||||
p.checkGrammar()
|
||||
p.check_grammar()
|
||||
from uncompyle6 import PYTHON_VERSION, IS_PYPY
|
||||
if PYTHON_VERSION == 2.6:
|
||||
lhs, rhs, tokens, right_recursive = p.check_sets()
|
||||
|
@@ -129,7 +129,7 @@ class Python27ParserSingle(Python27Parser, PythonParserSingle):
|
||||
if __name__ == '__main__':
|
||||
# Check grammar
|
||||
p = Python27Parser()
|
||||
p.checkGrammar()
|
||||
p.check_grammar()
|
||||
from uncompyle6 import PYTHON_VERSION, IS_PYPY
|
||||
if PYTHON_VERSION == 2.7:
|
||||
lhs, rhs, tokens, right_recursive = p.check_sets()
|
||||
@@ -148,4 +148,4 @@ if __name__ == '__main__':
|
||||
for t in remain_tokens])
|
||||
remain_tokens = set(remain_tokens) - opcode_set
|
||||
print(remain_tokens)
|
||||
# p.dumpGrammar()
|
||||
# p.dump_grammar()
|
||||
|
@@ -955,10 +955,10 @@ def info(args):
|
||||
p = Python32Parser()
|
||||
elif arg == '3.0':
|
||||
p = Python30Parser()
|
||||
p.checkGrammar()
|
||||
p.check_grammar()
|
||||
if len(sys.argv) > 1 and sys.argv[1] == 'dump':
|
||||
print('-' * 50)
|
||||
p.dumpGrammar()
|
||||
p.dump_grammar()
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys
|
||||
|
@@ -29,7 +29,7 @@ class Python34ParserSingle(Python34Parser, PythonParserSingle):
|
||||
if __name__ == '__main__':
|
||||
# Check grammar
|
||||
p = Python34Parser()
|
||||
p.checkGrammar()
|
||||
p.check_grammar()
|
||||
from uncompyle6 import PYTHON_VERSION, IS_PYPY
|
||||
if PYTHON_VERSION == 3.4:
|
||||
lhs, rhs, tokens, right_recursive = p.check_sets()
|
||||
|
@@ -165,7 +165,7 @@ class Python35ParserSingle(Python35Parser, PythonParserSingle):
|
||||
if __name__ == '__main__':
|
||||
# Check grammar
|
||||
p = Python35Parser()
|
||||
p.checkGrammar()
|
||||
p.check_grammar()
|
||||
from uncompyle6 import PYTHON_VERSION, IS_PYPY
|
||||
if PYTHON_VERSION == 3.5:
|
||||
lhs, rhs, tokens, right_recursive = p.check_sets()
|
||||
|
@@ -79,7 +79,7 @@ class Python36ParserSingle(Python36Parser, PythonParserSingle):
|
||||
if __name__ == '__main__':
|
||||
# Check grammar
|
||||
p = Python36Parser()
|
||||
p.checkGrammar()
|
||||
p.check_grammar()
|
||||
from uncompyle6 import PYTHON_VERSION, IS_PYPY
|
||||
if PYTHON_VERSION == 3.6:
|
||||
lhs, rhs, tokens, right_recursive = p.check_sets()
|
||||
|
@@ -21,7 +21,7 @@ class Python37ParserSingle(Python37Parser, PythonParserSingle):
|
||||
if __name__ == '__main__':
|
||||
# Check grammar
|
||||
p = Python37Parser()
|
||||
p.checkGrammar()
|
||||
p.check_grammar()
|
||||
from uncompyle6 import PYTHON_VERSION, IS_PYPY
|
||||
if PYTHON_VERSION == 3.7:
|
||||
lhs, rhs, tokens, right_recursive = p.check_sets()
|
||||
|
@@ -175,10 +175,9 @@ TABLE_DIRECT = {
|
||||
'ret_cond_not': ( '%p if not %p else %p', (2, 27), (0, 22), (-1, 27) ),
|
||||
'conditional_lambda': ( '%c if %c else %c', 2, 0, 4),
|
||||
|
||||
# The semicolon is because Python 3.x can have be dead code as a result of its
|
||||
# optimization. We don't Python's remove dead code (yet) anymore than Python does.
|
||||
# So without that we would have "return 2return3" rather than "return 2;return 3"
|
||||
'return_lambda': ('return %c;', 0),
|
||||
# Sometiems a semicolon is neede because Python 3.x can have be
|
||||
# dead code as a result of its optimization?
|
||||
'return_lambda': ('%c', 0),
|
||||
|
||||
'compare': ( '%p %[-1]{pattr.replace("-", " ")} %p', (0, 19), (1, 19) ),
|
||||
'cmp_list': ( '%p %p', (0, 29), (1, 30)),
|
||||
|
Reference in New Issue
Block a user