You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-03 16:59:52 +08:00
Doc changes.
This commit is contained in:
@@ -700,14 +700,14 @@ class GenericASTTraversal:
|
|||||||
raise GenericASTTraversalPruningException
|
raise GenericASTTraversalPruningException
|
||||||
|
|
||||||
def preorder(self, node=None):
|
def preorder(self, node=None):
|
||||||
"""Walk the tree. For each node with typestring name *name* if this
|
"""Walk the tree. For each node with typestring name *name* if the
|
||||||
class has a method called n_*name*, call that before walking
|
node has a method called n_*name*, call that before walking
|
||||||
children. If there is no method defined was call a "default"
|
children. If there is no method define, call a
|
||||||
subclasses will probably want to define.
|
self.default(node) instead. Subclasses of GenericASTTtraversal
|
||||||
|
ill probably want to override this method.
|
||||||
|
|
||||||
|
If the node has a method called *name*_exit, that is called
|
||||||
If this class has a method called *name*_exit, that is called
|
after all children have been called. So in this sense this
|
||||||
after all children have been callsed. So in this sense this
|
|
||||||
function is both preorder and postorder combined.
|
function is both preorder and postorder combined.
|
||||||
"""
|
"""
|
||||||
if node is None:
|
if node is None:
|
||||||
|
@@ -1,7 +1,8 @@
|
|||||||
# Copyright (c) 1999 John Aycock
|
|
||||||
# Copyright (c) 2000-2002 by hartmut Goebel <h.goebel@crazy-compilers.com>
|
|
||||||
# Copyright (c) 2005 by Dan Pascu <dan@windowmaker.org>
|
|
||||||
# Copyright (c) 2015 by Rocky Bernstein
|
# Copyright (c) 2015 by Rocky Bernstein
|
||||||
|
# Copyright (c) 2005 by Dan Pascu <dan@windowmaker.org>
|
||||||
|
# Copyright (c) 2000-2002 by hartmut Goebel <h.goebel@crazy-compilers.com>
|
||||||
|
# Copyright (c) 1999 John Aycock
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Creates Python source code from an uncompyle6 abstract syntax tree,
|
Creates Python source code from an uncompyle6 abstract syntax tree,
|
||||||
and indexes fragments which can be accessed by instruction offset
|
and indexes fragments which can be accessed by instruction offset
|
||||||
@@ -996,10 +997,10 @@ class FragmentsWalker(pysource.SourceWalker, object):
|
|||||||
self.prune()
|
self.prune()
|
||||||
|
|
||||||
def engine(self, entry, startnode):
|
def engine(self, entry, startnode):
|
||||||
'''The format template interpetation engine. See the comment at the
|
"""The format template interpetation engine. See the comment at the
|
||||||
beginning of this module for the how we interpret format specifications such as
|
beginning of this module for the how we interpret format specifications such as
|
||||||
%c, %C, and so on.
|
%c, %C, and so on.
|
||||||
'''
|
"""
|
||||||
|
|
||||||
# print("-----")
|
# print("-----")
|
||||||
# print(startnode)
|
# print(startnode)
|
||||||
|
@@ -1,10 +1,9 @@
|
|||||||
# Copyright (c) 1999 John Aycock
|
|
||||||
# Copyright (c) 2000-2002 by hartmut Goebel <h.goebel@crazy-compilers.com>
|
|
||||||
# Copyright (c) 2005 by Dan Pascu <dan@windowmaker.org>
|
|
||||||
# Copyright (c) 2015 by Rocky Bernstein
|
# Copyright (c) 2015 by Rocky Bernstein
|
||||||
|
# Copyright (c) 2005 by Dan Pascu <dan@windowmaker.org>
|
||||||
|
# Copyright (c) 2000-2002 by hartmut Goebel <h.goebel@crazy-compilers.com>
|
||||||
|
# Copyright (c) 1999 John Aycock
|
||||||
|
|
||||||
"""
|
"""Creates Python source code from an uncompyle6 abstract syntax tree.
|
||||||
Creates Python source code from an uncompyle6 abstract syntax tree.
|
|
||||||
|
|
||||||
The terminal symbols are CPython bytecode instructions. (See the
|
The terminal symbols are CPython bytecode instructions. (See the
|
||||||
python documentation under module "dis" for a list of instructions
|
python documentation under module "dis" for a list of instructions
|
||||||
@@ -13,13 +12,18 @@ and what they mean).
|
|||||||
Upper levels of the grammar is a more-or-less conventional grammar for
|
Upper levels of the grammar is a more-or-less conventional grammar for
|
||||||
Python.
|
Python.
|
||||||
|
|
||||||
Semantic action rules for nonterminal symbols can be table driven.
|
Semantic action rules for nonterminal symbols can be specified here by
|
||||||
This mechanism uses a printf-like syntax to direct substitution from
|
creating a method prefaced with "n_" for that nonterminal. For
|
||||||
attributes of the nonterminal and its children..
|
example, "n_exec_stmt" handles the semantic actions for the
|
||||||
|
"exec_smnt" nonterminal symbol. Similarly if a method with the name
|
||||||
|
of the nontermail is suffixed with "_exit" it will be called after
|
||||||
|
all of its children are called.
|
||||||
|
|
||||||
The other way to specify a semantic rule is to create a method
|
Another other way to specify a semantic rule for a nonterminal is via
|
||||||
prefaced with "n_" for that nonterminal. For example, "n_exec_stmt"
|
rule given in one of the tables MAP_R0, MAP_R, or MAP_DIRECT.
|
||||||
handles the semantic actions for the "exec_smnt" nonterminal symbol.
|
|
||||||
|
These uses a printf-like syntax to direct substitution from attributes
|
||||||
|
of the nonterminal and its children..
|
||||||
|
|
||||||
The rest of the below describes how table-driven semantic actions work
|
The rest of the below describes how table-driven semantic actions work
|
||||||
and gives a list of the format specifiers. The default() and engine()
|
and gives a list of the format specifiers. The default() and engine()
|
||||||
@@ -57,7 +61,6 @@ methods implement most of the below.
|
|||||||
|
|
||||||
The '%' may optionally be followed by a number (C) in square brackets, which
|
The '%' may optionally be followed by a number (C) in square brackets, which
|
||||||
makes the engine walk down to N[C] before evaluating the escape code.
|
makes the engine walk down to N[C] before evaluating the escape code.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
|
||||||
@@ -979,7 +982,6 @@ class SourceWalker(GenericASTTraversal, object):
|
|||||||
|
|
||||||
assert hasattr(code, 'co_name')
|
assert hasattr(code, 'co_name')
|
||||||
code = Code(code, self.scanner, self.currentclass)
|
code = Code(code, self.scanner, self.currentclass)
|
||||||
|
|
||||||
ast = self.build_ast(code._tokens, code._customize)
|
ast = self.build_ast(code._tokens, code._customize)
|
||||||
self.customize(code._customize)
|
self.customize(code._customize)
|
||||||
ast = ast[0][0][0]
|
ast = ast[0][0][0]
|
||||||
@@ -1244,6 +1246,11 @@ class SourceWalker(GenericASTTraversal, object):
|
|||||||
self.default(node)
|
self.default(node)
|
||||||
|
|
||||||
def engine(self, entry, startnode):
|
def engine(self, entry, startnode):
|
||||||
|
"""The format template interpetation engine. See the comment at the
|
||||||
|
beginning of this module for the how we interpret format specifications such as
|
||||||
|
%c, %C, and so on.
|
||||||
|
"""
|
||||||
|
|
||||||
# self.print_("-----")
|
# self.print_("-----")
|
||||||
# self.print(startnode)
|
# self.print(startnode)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user