compiler.transformer
index
/usr/local/lib/python2.5/compiler/transformer.py
Module Docs

Parse tree transformation module.
 
Transforms Python source code into an abstract syntax tree (AST)
defined in the ast module.
 
The simplest ways to invoke this module are via parse and parseFile.
parse(buf) -> AST
parseFile(path) -> AST

 
Modules
       
parser
symbol
sys
token

 
Classes
       
Transformer
exceptions.StandardError(exceptions.Exception)
WalkerError

 
class Transformer
    Utility object for transforming Python parse trees.
 
Exposes the following methods:
    tree = transform(ast_tree)
    tree = parsesuite(text)
    tree = parseexpr(text)
    tree = parsefile(fileob | filename)
 
  Methods defined here:
__init__(self)
and_expr(self, nodelist)
and_test(self, nodelist)
argument(self, nodelist)
arith_expr(self, nodelist)
assert_stmt(self, nodelist)
atom(self, nodelist)
atom_backquote(self, nodelist)
atom_lbrace(self, nodelist)
atom_lpar(self, nodelist)
atom_lsqb(self, nodelist)
atom_name(self, nodelist)
atom_number(self, nodelist)
atom_string(self, nodelist)
break_stmt(self, nodelist)
classdef(self, nodelist)
com_NEWLINE(self, *args)
com_append_stmt(self, stmts, node)
com_apply_trailer(self, primaryNode, nodelist)
com_arglist(self, nodelist)
com_argument(self, nodelist, kw)
com_assign(self, node, assigning)
com_assign_attr(self, primary, node, assigning)
com_assign_list(self, node, assigning)
com_assign_name(self, node, assigning)
com_assign_trailer(self, primary, node, assigning)
com_assign_tuple(self, node, assigning)
com_augassign(self, node)
Return node suitable for lvalue of augmented assignment
 
Names, slices, and attributes are the only allowable nodes.
com_augassign_op(self, node)
com_bases(self, node)
com_binary(self, constructor, nodelist)
Compile 'NODE (OP NODE)*' into (type, [ node1, ..., nodeN ]).
com_call_function(self, primaryNode, nodelist)
com_dictmaker(self, nodelist)
com_dotted_as_name(self, node)
com_dotted_as_names(self, node)
com_dotted_name(self, node)
com_fpdef(self, node)
com_fplist(self, node)
com_gen_iter(self, node)
com_generator_expression(self, expr, node)
com_import_as_name(self, node)
com_import_as_names(self, node)
com_list_comprehension(self, expr, node)
com_list_constructor(self, nodelist)
com_list_iter(self, node)
com_node(self, node)
com_select_member(self, primaryNode, nodelist)
com_slice(self, primary, node, assigning)
com_sliceobj(self, node)
com_stmt(self, node)
com_subscript(self, node)
com_subscriptlist(self, primary, nodelist, assigning)
com_try_except_finally(self, nodelist)
com_with(self, nodelist)
com_with_var(self, nodelist)
comp_op(self, nodelist)
comparison(self, nodelist)
compile_node(self, node)
compound_stmt = stmt(self, nodelist)
continue_stmt(self, nodelist)
decode_literal(self, lit)
decorator(self, nodelist)
decorator_name(self, nodelist)
decorators(self, nodelist)
del_stmt(self, nodelist)
dotted_name(self, nodelist)
eval_input(self, nodelist)
exec_stmt(self, nodelist)
expr(self, nodelist)
expr_stmt(self, nodelist)
exprlist = testlist(self, nodelist)
factor(self, nodelist)
file_input(self, nodelist)
flow_stmt = stmt(self, nodelist)
for_stmt(self, nodelist)
fpdef(self, nodelist)
fplist(self, nodelist)
funcdef(self, nodelist)
get_docstring(self, node, n=None)
global_stmt(self, nodelist)
if_stmt(self, nodelist)
import_from(self, nodelist)
import_name(self, nodelist)
import_stmt(self, nodelist)
lambdef(self, nodelist)
lookup_node(self, node)
not_test(self, nodelist)
old_lambdef = lambdef(self, nodelist)
old_test = or_test(self, nodelist)
or_test(self, nodelist)
parameters(self, nodelist)
parseexpr(self, text)
Return a modified parse tree for the given expression text.
parsefile(self, file)
Return a modified parse tree for the contents of the given file.
parsesuite(self, text)
Return a modified parse tree for the given suite text.
pass_stmt(self, nodelist)
power(self, nodelist)
print_stmt(self, nodelist)
raise_stmt(self, nodelist)
return_stmt(self, nodelist)
shift_expr(self, nodelist)
simple_stmt(self, nodelist)
single_input(self, node)
sliceop(self, nodelist)
small_stmt = stmt(self, nodelist)
stmt(self, nodelist)
suite(self, nodelist)
term(self, nodelist)
test(self, nodelist)
testlist(self, nodelist)
testlist1 = testlist(self, nodelist)
testlist_gexp(self, nodelist)
testlist_safe = testlist(self, nodelist)
trailer(self, nodelist)
transform(self, tree)
Transform an AST into a modified parse tree.
try_stmt(self, nodelist)
varargslist(self, nodelist)
while_stmt(self, nodelist)
with_stmt(self, nodelist)
with_var(self, nodelist)
xor_expr(self, nodelist)
yield_expr(self, nodelist)
yield_stmt(self, nodelist)

 
class WalkerError(exceptions.StandardError)
    
Method resolution order:
WalkerError
exceptions.StandardError
exceptions.Exception
exceptions.BaseException
__builtin__.object

Data descriptors defined here:
__weakref__
list of weak references to the object (if defined)

Methods inherited from exceptions.StandardError:
__init__(...)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Data and other attributes inherited from exceptions.StandardError:
__new__ = <built-in method __new__ of type object at 0x8125520>
T.__new__(S, ...) -> a new object with type S, a subtype of T

Methods inherited from exceptions.BaseException:
__delattr__(...)
x.__delattr__('name') <==> del x.name
__getattribute__(...)
x.__getattribute__('name') <==> x.name
__getitem__(...)
x.__getitem__(y) <==> x[y]
__getslice__(...)
x.__getslice__(i, j) <==> x[i:j]
 
Use of negative indices is not supported.
__reduce__(...)
__repr__(...)
x.__repr__() <==> repr(x)
__setattr__(...)
x.__setattr__('name', value) <==> x.name = value
__setstate__(...)
__str__(...)
x.__str__() <==> str(x)

Data descriptors inherited from exceptions.BaseException:
__dict__
args
message
exception message

 
Functions
       
Node(*args)
asList(nodes)
debug_tree(tree)
extractLineNo(ast)
parse(buf, mode='exec')
parseFile(path)

 
Data
        CO_VARARGS = 4
CO_VARKEYWORDS = 8
OP_APPLY = 'OP_APPLY'
OP_ASSIGN = 'OP_ASSIGN'
OP_DELETE = 'OP_DELETE'
k = 51
name = 'If'
nodes = {'expression': 'Expression'}
v = 'OP'