mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2024-11-23 13:09:49 +00:00
NT importstmt -> import to match AST
This commit is contained in:
parent
4ea1416fdd
commit
34117522b2
21
README.rst
21
README.rst
@ -3,7 +3,7 @@
|
||||
uncompyle6
|
||||
==========
|
||||
|
||||
A native Python cross-version Decompiler and Fragment Decompiler.
|
||||
A native Python cross-version decompiler and fragment decompiler.
|
||||
The successor to decompyle, uncompyle, and uncompyle2.
|
||||
|
||||
|
||||
@ -17,12 +17,12 @@ source code. It accepts bytecodes from Python version 1.5, and 2.1 to
|
||||
Why this?
|
||||
---------
|
||||
|
||||
Ok, I'll say it: this software is amazing. It is a little more than
|
||||
just your normal hacky decompiler. Using compiler_ technology, the
|
||||
program creates a parse tree of the program from the instructions;
|
||||
nodes at the upper levels that look a little like what might come from
|
||||
a Python AST. So we can really classify and understand what's going on
|
||||
in sections of Python bytecode.
|
||||
Ok, I'll say it: this software is amazing. It is more than your
|
||||
normal hacky decompiler. Using compiler_ technology, the program
|
||||
creates a parse tree of the program from the instructions; nodes at
|
||||
the upper levels that look a little like what might come from a Python
|
||||
AST. So we can really classify and understand what's going on in
|
||||
sections of Python bytecode.
|
||||
|
||||
Building on this, another thing that makes this different from other
|
||||
CPython bytecode decompilers is the ability to deparse just
|
||||
@ -37,9 +37,10 @@ See this_ for more information.
|
||||
|
||||
Python fragment deparsing given an instruction offset is useful in
|
||||
showing stack traces and can be encorporated into any program that
|
||||
wants to show a location in more detail than just a line number. This
|
||||
code can be also used when source-code information does not exist and
|
||||
there is just bytecode. Again, my debugggers make use of this.
|
||||
wants to show a location in more detail than just a line number at
|
||||
runtime. This code can be also used when source-code information does
|
||||
not exist and there is just bytecode. Again, my debugggers make use of
|
||||
this.
|
||||
|
||||
There were (and still are) a number of decompyle, uncompyle,
|
||||
uncompyle2, uncompyle3 forks around. Almost all of them come basically
|
||||
|
@ -379,7 +379,7 @@ class PythonParser(GenericASTBuilder):
|
||||
|
||||
def p_import20(self, args):
|
||||
"""
|
||||
stmt ::= importstmt
|
||||
stmt ::= import
|
||||
stmt ::= importfrom
|
||||
stmt ::= importstar
|
||||
stmt ::= importmultiple
|
||||
@ -390,7 +390,7 @@ class PythonParser(GenericASTBuilder):
|
||||
alias ::= IMPORT_FROM store
|
||||
alias ::= IMPORT_NAME load_attrs store
|
||||
|
||||
importstmt ::= LOAD_CONST LOAD_CONST alias
|
||||
import ::= LOAD_CONST LOAD_CONST alias
|
||||
importstar ::= LOAD_CONST LOAD_CONST IMPORT_NAME IMPORT_STAR
|
||||
importfrom ::= LOAD_CONST LOAD_CONST IMPORT_NAME importlist POP_TOP
|
||||
importmultiple ::= LOAD_CONST LOAD_CONST alias imports_cont
|
||||
|
@ -13,8 +13,8 @@ class Python15Parser(Python21Parser):
|
||||
|
||||
def p_import15(self, args):
|
||||
"""
|
||||
importstmt ::= filler IMPORT_NAME STORE_FAST
|
||||
importstmt ::= filler IMPORT_NAME STORE_NAME
|
||||
import ::= filler IMPORT_NAME STORE_FAST
|
||||
import ::= filler IMPORT_NAME STORE_NAME
|
||||
|
||||
importfrom ::= filler IMPORT_NAME importlist
|
||||
importfrom ::= filler filler IMPORT_NAME importlist POP_TOP
|
||||
|
@ -26,7 +26,7 @@ class Python24Parser(Python25Parser):
|
||||
# 2.5+ has two LOAD_CONSTs, one for the number '.'s in a relative import
|
||||
# keep positions similar to simplify semantic actions
|
||||
|
||||
importstmt ::= filler LOAD_CONST alias
|
||||
import ::= filler LOAD_CONST alias
|
||||
importfrom ::= filler LOAD_CONST IMPORT_NAME importlist POP_TOP
|
||||
importstar ::= filler LOAD_CONST IMPORT_NAME IMPORT_STAR
|
||||
|
||||
|
@ -274,7 +274,7 @@ TABLE_DIRECT = {
|
||||
'kv': ( '%c: %c', 3, 1 ),
|
||||
'kv2': ( '%c: %c', 1, 2 ),
|
||||
'mapexpr': ( '{%[1]C}', (0, maxint, ', ') ),
|
||||
'importstmt': ( '%|import %c\n', 2),
|
||||
'import': ( '%|import %c\n', 2),
|
||||
'importlist': ( '%C', (0, maxint, ', ') ),
|
||||
'importfrom': ( '%|from %[2]{pattr} import %c\n',
|
||||
(3, 'importlist') ),
|
||||
|
@ -18,7 +18,7 @@ We add some format specifiers here not used in pysource
|
||||
from src to dest.
|
||||
|
||||
For example in:
|
||||
'importstmt': ( '%|import %c%x\n', 2, (2,(0,1)), ),
|
||||
'import': ( '%|import %c%x\n', 2, (2,(0,1)), ),
|
||||
|
||||
node 2 range information, it in %c, is copied to nodes 0 and 1.
|
||||
|
||||
@ -88,7 +88,7 @@ TABLE_DIRECT_FRAGMENT = {
|
||||
'continue_stmt': ( '%|%rcontinue\n', ),
|
||||
'passstmt': ( '%|%rpass\n', ),
|
||||
'raise_stmt0': ( '%|%rraise\n', ),
|
||||
'importstmt': ( '%|import %c%x\n', 2, (2, (0, 1)), ),
|
||||
'import': ( '%|import %c%x\n', 2, (2, (0, 1)), ),
|
||||
'importfrom': ( '%|from %[2]{pattr}%x import %c\n', (2, (0, 1)), 3),
|
||||
'importmultiple': ( '%|import%b %c%c\n', 0, 2, 3 ),
|
||||
'list_for': (' for %c%x in %c%c', 2, (2, (1, )), 0, 3 ),
|
||||
|
Loading…
Reference in New Issue
Block a user