ITreeAdaptor Interface |
Namespace: Stimulsoft.Data.Expressions.Antlr.Runtime.Tree
The ITreeAdaptor type exposes the following members.
Name | Description | |
---|---|---|
![]() | AddChild |
Add a child to the tree t. If child is a flat tree (a list), make all
in list children of t. Warning: if t has no children, but child does
and child isNil then you can decide it is ok to move children to t via
t.children = child.children; i.e., without copying the array. Just
make sure that this is consistent with have the user will build
ASTs. Do nothing if t or child is null.
|
![]() | BecomeRoot(Object, Object) |
If oldRoot is a nil root, just copy or move the children to newRoot.
If not a nil root, make oldRoot a child of newRoot.
|
![]() | BecomeRoot(IToken, Object) |
Create a node for newRoot make it the root of oldRoot.
If oldRoot is a nil root, just copy or move the children to newRoot.
If not a nil root, make oldRoot a child of newRoot.
|
![]() | Create(IToken) |
Create a tree node from Token object; for CommonTree type trees,
then the token just becomes the payload. This is the most
common create call.
|
![]() | Create(Int32, IToken) |
Create a new node derived from a token, with a new token type.
This is invoked from an imaginary node ref on right side of a
rewrite rule as IMAG[$tokenLabel].
|
![]() | Create(Int32, String) |
Create a new node derived from a token, with a new token type.
This is invoked from an imaginary node ref on right side of a
rewrite rule as IMAG["IMAG"].
|
![]() | Create(IToken, String) |
Same as create(fromToken) except set the text too.
This is invoked when the text terminal option is set, as in
IMAG<text='IMAG'>.
|
![]() | Create(Int32, IToken, String) |
Same as create(tokenType,fromToken) except set the text too.
This is invoked from an imaginary node ref on right side of a
rewrite rule as IMAG[$tokenLabel, "IMAG"].
|
![]() | DeleteChild | Remove ith child and shift children down from right. |
![]() | DupNode(Object) | Duplicate a single tree node. |
![]() | DupNode(Int32, Object) | |
![]() | DupNode(Object, String) | |
![]() | DupNode(Int32, Object, String) | |
![]() | DupTree | Duplicate tree recursively, using dupNode() for each node |
![]() | ErrorNode |
Return a tree node representing an error. This node records the
tokens consumed during error recovery. The start token indicates the
input symbol at which the error was detected. The stop token indicates
the last symbol consumed during recovery.
|
![]() | GetChild | Get a child 0..n-1 node |
![]() | GetChildCount | How many children? If 0, then this is a leaf node |
![]() | GetChildIndex |
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.
|
![]() | GetParent |
Who is the parent node of this node; if null, implies node is root.
If your node type doesn't handle this, it's ok but the tree rewrites
in tree parsers need this functionality.
|
![]() | GetText | |
![]() | GetToken |
Return the token object from which this node was created.
Currently used only for printing an error message.
The error display routine in BaseRecognizer needs to
display where the input the error occurred. If your
tree of limitation does not store information that can
lead you to the token, you can create a token filled with
the appropriate information and pass that back. See
BaseRecognizer.getErrorMessage().
|
![]() | GetTokenStartIndex | Get the token start index for this subtree; return -1 if no such index |
![]() | GetTokenStopIndex | Get the token stop index for this subtree; return -1 if no such index |
![]() | GetType | For tree parsing, I need to know the token type of a node |
![]() | GetUniqueID | For identifying trees. |
![]() | IsNil | Is tree considered a nil node used to make lists of child nodes? |
![]() | Nil |
Return a nil node (an empty but non-null node) that can hold
a list of element as the children. If you want a flat tree (a list)
use "t=adaptor.nil(); t.addChild(x); t.addChild(y);"
|
![]() | ReplaceChildren |
Replace from start to stop child index of parent with t, which might
be a list. Number of children may be different after this call.
|
![]() | RulePostProcessing |
Given the root of the subtree created for this rule, post process
it to do any simplifications or whatever you want. A required
behavior is to convert ^(nil singleSubtree) to singleSubtree
as the setting of start/stop indexes relies on a single non-nil root
for non-flat trees.
|
![]() | SetChild | Set ith child (0..n-1) to t; t must be non-null and non-nil node |
![]() | SetChildIndex | |
![]() | SetParent | |
![]() | SetText | Node constructors can set the text of a node |
![]() | SetTokenBoundaries |
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. Flat trees (i.e., lists) will
still usually have a nil root node just to hold the children list.
That node would contain the start/stop indexes then.
|
![]() | SetType | Node constructors can set the type of a node |