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