public class CommonTreeAdaptor extends BaseTreeAdaptor
treeToUniqueIDMap, uniqueNodeID| Constructor and Description |
|---|
CommonTreeAdaptor() |
| Modifier and Type | Method and Description |
|---|---|
Object |
create(Token payload)
Create a tree node from Token object; for CommonTree type trees,
then the token just becomes the payload.
|
Token |
createToken(int tokenType,
String text)
Tell me how to create a token for use with imaginary token nodes.
|
Token |
createToken(Token fromToken)
Tell me how to create a token for use with imaginary token nodes.
|
Object |
dupNode(Object t)
Duplicate a node.
|
Object |
getChild(Object t,
int i)
Get a child 0..n-1 node
|
int |
getChildCount(Object t)
How many children? If 0, then this is a leaf node
|
int |
getChildIndex(Object 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.
|
Object |
getParent(Object t)
Who is the parent node of this node; if null, implies node is root.
|
String |
getText(Object t) |
Token |
getToken(Object t)
What is the Token associated with this node? If
you are not using CommonTree, then you must
override this in your own adaptor.
|
int |
getTokenStartIndex(Object t)
Get the token start index for this subtree; return -1 if no such index
|
int |
getTokenStopIndex(Object t)
Get the token stop index for this subtree; return -1 if no such index
|
int |
getType(Object t)
For tree parsing, I need to know the token type of a node
|
void |
replaceChildren(Object parent,
int startChildIndex,
int stopChildIndex,
Object t)
Replace from start to stop child index of parent with t, which might
be a list.
|
void |
setChildIndex(Object t,
int index) |
void |
setParent(Object t,
Object parent) |
void |
setTokenBoundaries(Object t,
Token startToken,
Token stopToken)
Track start/stop token for subtree root created for a rule.
|
addChild, becomeRoot, becomeRoot, create, create, create, deleteChild, dupTree, dupTree, errorNode, getUniqueID, isNil, nil, rulePostProcessing, setChild, setText, setTypepublic Object dupNode(Object t)
public Object create(Token payload)
TreeAdaptorpublic Token createToken(int tokenType, String text)
createToken in class BaseTreeAdaptorpublic Token createToken(Token fromToken)
createToken in class BaseTreeAdaptorpublic void setTokenBoundaries(Object t, Token startToken, Token stopToken)
public int getTokenStartIndex(Object t)
TreeAdaptorpublic int getTokenStopIndex(Object t)
TreeAdaptorpublic String getText(Object t)
getText in interface TreeAdaptorgetText in class BaseTreeAdaptorpublic int getType(Object t)
TreeAdaptorgetType in interface TreeAdaptorgetType in class BaseTreeAdaptorpublic Token getToken(Object t)
public Object getChild(Object t, int i)
TreeAdaptorgetChild in interface TreeAdaptorgetChild in class BaseTreeAdaptorpublic int getChildCount(Object t)
TreeAdaptorgetChildCount in interface TreeAdaptorgetChildCount in class BaseTreeAdaptorpublic Object getParent(Object t)
TreeAdaptorpublic int getChildIndex(Object t)
TreeAdaptorpublic void setChildIndex(Object t, int index)
public void replaceChildren(Object parent, int startChildIndex, int stopChildIndex, Object t)
TreeAdaptorCopyright © 1992-2013 ANTLR. All Rights Reserved.