You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-03 00:45:53 +08:00
Use external spark now.
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -3,6 +3,8 @@
|
|||||||
/.cache
|
/.cache
|
||||||
/.eggs
|
/.eggs
|
||||||
/.python-version
|
/.python-version
|
||||||
|
/.tox
|
||||||
|
/README
|
||||||
/__pkginfo__.pyc
|
/__pkginfo__.pyc
|
||||||
/dist
|
/dist
|
||||||
/how-to-make-a-release.txt
|
/how-to-make-a-release.txt
|
||||||
|
@@ -48,6 +48,7 @@ This uses setup.py, so it follows the standard Python routine:
|
|||||||
|
|
||||||
::
|
::
|
||||||
|
|
||||||
|
pip install -r requirements.txt
|
||||||
python setup.py install # may need sudo
|
python setup.py install # may need sudo
|
||||||
# or if you have pyenv:
|
# or if you have pyenv:
|
||||||
python setup.py develop
|
python setup.py develop
|
||||||
|
1
requirements.txt
Normal file
1
requirements.txt
Normal file
@@ -0,0 +1 @@
|
|||||||
|
spark_parser >= 1.0.1
|
@@ -3,7 +3,7 @@
|
|||||||
# Copyright (c) 2000-2002 by hartmut Goebel <h.goebel@crazy-compilers.com>
|
# Copyright (c) 2000-2002 by hartmut Goebel <h.goebel@crazy-compilers.com>
|
||||||
# Copyright (c) 1999 John Aycock
|
# Copyright (c) 1999 John Aycock
|
||||||
"""
|
"""
|
||||||
Common spark parser routines Python.
|
Common uncompyle parser routines.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
@@ -11,7 +11,7 @@ from __future__ import print_function
|
|||||||
import sys
|
import sys
|
||||||
|
|
||||||
from uncompyle6.code import iscode
|
from uncompyle6.code import iscode
|
||||||
from uncompyle6.parsers.spark import GenericASTBuilder, DEFAULT_DEBUG as PARSER_DEFAULT_DEBUG
|
from spark import GenericASTBuilder, DEFAULT_DEBUG as PARSER_DEFAULT_DEBUG
|
||||||
|
|
||||||
class ParserError(Exception):
|
class ParserError(Exception):
|
||||||
def __init__(self, token, offset):
|
def __init__(self, token, offset):
|
||||||
@@ -239,7 +239,7 @@ def python_parser(version, co, out=sys.stdout, showasm=False,
|
|||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
def parse_test(co):
|
def parse_test(co):
|
||||||
from uncompyl6 import PYTHON_VERSION
|
from uncompyle6 import PYTHON_VERSION
|
||||||
ast = python_parser(PYTHON_VERSION, co, showasm=True)
|
ast = python_parser(PYTHON_VERSION, co, showasm=True)
|
||||||
print(ast)
|
print(ast)
|
||||||
return
|
return
|
||||||
|
@@ -10,8 +10,8 @@ else:
|
|||||||
|
|
||||||
|
|
||||||
class AST(UserList):
|
class AST(UserList):
|
||||||
def __init__(self, type, kids=[]):
|
def __init__(self, kind, kids=[]):
|
||||||
self.type = intern(type)
|
self.type = intern(kind)
|
||||||
UserList.__init__(self, kids)
|
UserList.__init__(self, kids)
|
||||||
|
|
||||||
def isNone(self):
|
def isNone(self):
|
||||||
|
@@ -19,12 +19,16 @@ from __future__ import print_function
|
|||||||
|
|
||||||
from uncompyle6.parser import PythonParser, nop_func
|
from uncompyle6.parser import PythonParser, nop_func
|
||||||
from uncompyle6.parsers.astnode import AST
|
from uncompyle6.parsers.astnode import AST
|
||||||
from uncompyle6.parsers.spark import GenericASTBuilder, DEFAULT_DEBUG as PARSER_DEFAULT_DEBUG
|
from spark import GenericASTBuilder, DEFAULT_DEBUG as PARSER_DEFAULT_DEBUG
|
||||||
|
from uncompyle6 import PYTHON3
|
||||||
|
|
||||||
class Python2Parser(PythonParser):
|
class Python2Parser(PythonParser):
|
||||||
|
|
||||||
def __init__(self, debug_parser=PARSER_DEFAULT_DEBUG):
|
def __init__(self, debug_parser=PARSER_DEFAULT_DEBUG):
|
||||||
GenericASTBuilder.__init__(self, AST, 'stmts', debug=debug_parser)
|
if PYTHON3:
|
||||||
|
super().__init__(AST, 'stmts', debug=debug_parser)
|
||||||
|
else:
|
||||||
|
super(Python2Parser, self).__init__(AST, 'stmts', debug=debug_parser)
|
||||||
self.customized = {}
|
self.customized = {}
|
||||||
|
|
||||||
def p_list_comprehension(self, args):
|
def p_list_comprehension(self, args):
|
||||||
|
@@ -19,13 +19,17 @@ from __future__ import print_function
|
|||||||
|
|
||||||
from uncompyle6.parser import PythonParser, nop_func
|
from uncompyle6.parser import PythonParser, nop_func
|
||||||
from uncompyle6.parsers.astnode import AST
|
from uncompyle6.parsers.astnode import AST
|
||||||
from uncompyle6.parsers.spark import GenericASTBuilder, DEFAULT_DEBUG as PARSER_DEFAULT_DEBUG
|
from spark import GenericASTBuilder, DEFAULT_DEBUG as PARSER_DEFAULT_DEBUG
|
||||||
|
from uncompyle6 import PYTHON3
|
||||||
|
|
||||||
class Python3Parser(PythonParser):
|
class Python3Parser(PythonParser):
|
||||||
|
|
||||||
def __init__(self, debug_parser=PARSER_DEFAULT_DEBUG):
|
def __init__(self, debug_parser=PARSER_DEFAULT_DEBUG):
|
||||||
self.added_rules = set()
|
self.added_rules = set()
|
||||||
GenericASTBuilder.__init__(self, AST, 'stmts', debug=debug_parser)
|
if PYTHON3:
|
||||||
|
super().__init__(AST, 'stmts', debug=debug_parser)
|
||||||
|
else:
|
||||||
|
super(Python3Parser, self).__init__(AST, 'stmts', debug=debug_parser)
|
||||||
self.new_rules = set()
|
self.new_rules = set()
|
||||||
|
|
||||||
def add_unique_rule(self, rule, opname, count, customize):
|
def add_unique_rule(self, rule, opname, count, customize):
|
||||||
|
@@ -46,7 +46,7 @@ else:
|
|||||||
from StringIO import StringIO
|
from StringIO import StringIO
|
||||||
|
|
||||||
|
|
||||||
from uncompyle6.parsers.spark import GenericASTTraversal, GenericASTTraversalPruningException, \
|
from spark import GenericASTTraversal, GenericASTTraversalPruningException, \
|
||||||
DEFAULT_DEBUG as PARSER_DEFAULT_DEBUG
|
DEFAULT_DEBUG as PARSER_DEFAULT_DEBUG
|
||||||
|
|
||||||
from types import CodeType
|
from types import CodeType
|
||||||
|
@@ -70,7 +70,7 @@ from uncompyle6 import PYTHON3
|
|||||||
from uncompyle6.code import iscode
|
from uncompyle6.code import iscode
|
||||||
from uncompyle6.parser import get_python_parser
|
from uncompyle6.parser import get_python_parser
|
||||||
from uncompyle6.parsers.astnode import AST
|
from uncompyle6.parsers.astnode import AST
|
||||||
from uncompyle6.parsers.spark import GenericASTTraversal, DEFAULT_DEBUG as PARSER_DEFAULT_DEBUG
|
from spark import GenericASTTraversal, DEFAULT_DEBUG as PARSER_DEFAULT_DEBUG
|
||||||
from uncompyle6.scanner import Code, get_scanner
|
from uncompyle6.scanner import Code, get_scanner
|
||||||
from uncompyle6.scanners.tok import Token, NoneToken
|
from uncompyle6.scanners.tok import Token, NoneToken
|
||||||
import uncompyle6.parser as python_parser
|
import uncompyle6.parser as python_parser
|
||||||
|
Reference in New Issue
Block a user