A TreeAdaptor proxy that fires debugging events to a
DebugEventListener delegate and uses the TreeAdaptor delegate to do the
actual work. All AST events are triggered by this adaptor; no code gen
changes are needed in generated rules. Debugging events are triggered
*after* invoking tree adaptor routines.
Trees created with actions in rewrite actions like "-> ^(ADD
{foo} {bar})" cannot be tracked as they might not use the adaptor to
create foo, bar. The debug listener has to deal with tree node IDs for
which it did not see a createNode event. A single <unknown> node
is sufficient even if it represents a whole tree.
|
__init__(self,
dbg,
adaptor)
x.__init__(...) initializes x; see help(type(x)) for signature |
|
|
|
createWithPayload(self,
payload)
Create a tree node from Token object; for CommonTree type trees, then
the token just becomes the payload. |
|
|
|
createFromToken(self,
tokenType,
fromToken,
text=None)
Create a new node derived from a token, with a new token type and
(optionally) new text. |
|
|
|
createFromType(self,
tokenType,
text)
Create a new node derived from a token, with a new token type. |
|
|
|
errorNode(self,
input,
start,
stop,
exc)
Return a tree node representing an error. |
|
|
|
dupTree(self,
tree)
Duplicate tree recursively, using dupNode() for each node |
|
|
|
simulateTreeConstruction(self,
t)
^(A B C): emit create A, create B, add child, ... |
|
|
|
dupNode(self,
treeNode)
Duplicate a single tree node. |
|
|
|
nil(self)
Return a nil node (an empty but non-null node) that can hold a list
of element as the children. |
|
|
|
isNil(self,
tree)
Is tree considered a nil node used to make lists of child nodes? |
|
|
|
addChild(self,
t,
child)
Add a child to the tree t. |
|
|
|
becomeRoot(self,
newRoot,
oldRoot)
If oldRoot is a nil root, just copy or move the children to newRoot. |
|
|
|
rulePostProcessing(self,
root)
Given the root of the subtree created for this rule, post process it
to do any simplifications or whatever you want. |
|
|
|
getType(self,
t)
For tree parsing, I need to know the token type of a node |
|
|
|
setType(self,
t,
type)
Node constructors can set the type of a node |
|
|
|
|
|
setText(self,
t,
text)
Node constructors can set the text of a node |
|
|
|
getToken(self,
t)
Return the token object from which this node was created. |
|
|
|
setTokenBoundaries(self,
t,
startToken,
stopToken)
Where are the bounds in the input token stream for this node and all
children? Each rule that creates AST nodes will call this method
right before returning. |
|
|
|
getTokenStartIndex(self,
t)
Get the token start index for this subtree; return -1 if no such
index |
|
|
|
getTokenStopIndex(self,
t)
Get the token stop index for this subtree; return -1 if no such index |
|
|
|
getChild(self,
t,
i)
Get a child 0..n-1 node |
|
|
|
setChild(self,
t,
i,
child)
Set ith child (0..n-1) to t; t must be non-null and non-nil node |
|
|
|
deleteChild(self,
t,
i)
Remove ith child and shift children down from right. |
|
|
|
getChildCount(self,
t)
How many children? If 0, then this is a leaf node |
|
|
|
|
|
getParent(self,
t)
Who is the parent node of this node; if null, implies node is root. |
|
|
|
getChildIndex(self,
t)
What index is this node in the child list? Range: 0..n-1 If your node
type doesn't handle this, it's ok but the tree rewrites in tree
parsers need this functionality. |
|
|
|
setParent(self,
t,
parent)
Who is the parent node of this node; if null, implies node is root. |
|
|
|
setChildIndex(self,
t,
index)
What index is this node in the child list? Range: 0..n-1 If your node
type doesn't handle this, it's ok but the tree rewrites in tree
parsers need this functionality. |
|
|
|
replaceChildren(self,
parent,
startChildIndex,
stopChildIndex,
t)
Replace from start to stop child index of parent with t, which might
be a list. |
|
|
|
|
|
setDebugListener(self,
dbg) |
|
|
|
|
Inherited from tree.TreeAdaptor :
create
Inherited from object :
__delattr__ ,
__format__ ,
__getattribute__ ,
__hash__ ,
__new__ ,
__reduce__ ,
__reduce_ex__ ,
__repr__ ,
__setattr__ ,
__sizeof__ ,
__str__ ,
__subclasshook__
|