You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-04 01:09:52 +08:00
DRY fragments.py preorder code
pysource.py: doc typo
This commit is contained in:
@@ -172,35 +172,8 @@ class FragmentsWalker(pysource.SourceWalker, object):
|
||||
self.last_finish = finish
|
||||
|
||||
def preorder(self, node=None):
|
||||
|
||||
if node is None:
|
||||
node = self.ast
|
||||
|
||||
start = len(self.f.getvalue())
|
||||
|
||||
try:
|
||||
name = 'n_' + self.typestring(node)
|
||||
if hasattr(self, name):
|
||||
func = getattr(self, name)
|
||||
func(node)
|
||||
else:
|
||||
self.default(node)
|
||||
except GenericASTTraversalPruningException:
|
||||
# All leaf nodes, those with the offset method among others
|
||||
# seems to fit under this exception. If this is not true
|
||||
# we would need to dupllicate the below code before the
|
||||
# return outside of this block
|
||||
self.set_pos_info(node, start, len(self.f.getvalue()))
|
||||
# print self.f.getvalue()[start:]
|
||||
return
|
||||
|
||||
for kid in node:
|
||||
self.preorder(kid)
|
||||
|
||||
name = name + '_exit'
|
||||
if hasattr(self, name):
|
||||
func = getattr(self, name)
|
||||
func(node)
|
||||
super(pysource.SourceWalker, self).preorder(node)
|
||||
self.set_pos_info(node, start, len(self.f.getvalue()))
|
||||
|
||||
return
|
||||
|
@@ -16,7 +16,7 @@ Semantic action rules for nonterminal symbols can be specified here by
|
||||
creating a method prefaced with "n_" for that nonterminal. For
|
||||
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
|
||||
of the nonterminal is suffixed with "_exit" it will be called after
|
||||
all of its children are called.
|
||||
|
||||
Another other way to specify a semantic rule for a nonterminal is via
|
||||
|
Reference in New Issue
Block a user