Home | Trees | Index | Help |
|
---|
Package yagdoc :: Module scanner :: Class Tree |
|
object
--+
|
Tree
Expanded parse tree branch.
It supports the list protocol, behaving like a proxy forTree.items
in this regards. Empty tree
evaluates as False
in boolean context. For performance
reasons one often operates on the items
field directly.
However for operations such as:
for node in tree: ...
the proxying overhead exists only in the creation of the iterator and should be small.
It also overrides the comparison protocol, operators'=='
and '!='
compare two trees without regard to token
positions in the file. This means that Tree
objects corresponding to declarations:
int foo(int x, double y); int foo(int x, double y);
will evaluate as equal. This is what one is normally interested in.
Note due to the recursive nature of the comparision it does not help
to compare the type
and items
fields directly in order to compare
two trees including token positions (which should be seldom needed).
type
attribute in both Tree
and Token
enables duck-typed walking through
the expanded parse trees.
Method Summary | |
---|---|
Create a new expanded parse Tree. | |
__delitem__(self,
key)
| |
__eq__(self,
other)
| |
__getitem__(self,
key)
| |
__iter__(self)
| |
__len__(self)
| |
__ne__(self,
other)
| |
__setitem__(self,
key,
value)
| |
Tree
|
Descend an expanded parse tree through branches of given names. |
tuple of str or
None
|
Find the name of a tree (corresponding to for instance a variable or user function). |
list of Tree
|
Gather all branches of given name in an expanded parse tree. |
Inherited from object :
__delattr__ ,
__getattribute__ ,
__hash__ ,
__new__ ,
__reduce__ ,
__reduce_ex__ ,
__repr__ ,
__setattr__ ,
__str__
| |
Subname scanners | |
Scan 'enum_body' tree for symbol names. | |
Scan 'struct_body' tree for symbol names. | |
Scan function type sub tree for symbol names. | |
Scan 'prototype_args' tree for symbol names. | |
Scan 'type' tree for symbol names. |
Instance Variable Summary | |
---|---|
list of Token or Tree |
items : List of items this branch consits of. |
str |
type : Name of this branch. |
Class Variable Summary | |
---|---|
list |
__slots__ = ['type', 'items']
|
Method Details |
---|
subnames_enum_body(self, symbols, stack)Scan'enum_body' tree for symbol names.
|
subnames_struct_body(self, symbols, stack)Scan'struct_body' tree for symbol names.
|
subnames_user_function_parent(self, symbols, stack)Scan function type sub tree for symbol names. The tree root note is a parent of'user_function' , for
instance 'argument' , 'struct_field' ,
'typedef' or 'variable' . It is expected to
contain 'type' , possibly some
'variable_modifier' s and 'user_function' . The
name of the parent must be already on stack and in symbols, only return
type and arguments are scanned.
|
subnames_prototype_args(self, symbols, stack)Scan'prototype_args' tree for symbol names.
|
subnames_type(self, symbols, stack)Scan'type' tree for symbol names.
|
__init__(self,
root,
items=None)
|
descend(self, names, pos=0)Descend an expanded parse tree through branches of given names. The first branch with given name is always taken.
|
find_name(self)Find the name of a tree (corresponding to for instance a variable or user function). How the name is determined depends on the particular tree branch type.
|
gather_all(self, name)Gather all branches of given name in an expanded parse tree. |
Instance Variable Details |
---|
itemsList of items this branch consits of. Leaves areToken s, no-leaf branches are Tree s.
|
typeName of this branch. That is the correspondingparser
grammar rule name, except the couple of cases we refactor the tree into
new branch types.
|
Class Variable Details |
---|
__slots__
|
Home | Trees | Index | Help |
|
---|
Generated by Epydoc 2.1 on Fri Oct 5 00:36:53 2007 | http://epydoc.sf.net |