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, setType
public Object dupNode(Object t)
public Object create(Token payload)
TreeAdaptor
public Token createToken(int tokenType, String text)
createToken
in class BaseTreeAdaptor
public Token createToken(Token fromToken)
createToken
in class BaseTreeAdaptor
public void setTokenBoundaries(Object t, Token startToken, Token stopToken)
public int getTokenStartIndex(Object t)
TreeAdaptor
public int getTokenStopIndex(Object t)
TreeAdaptor
public String getText(Object t)
getText
in interface TreeAdaptor
getText
in class BaseTreeAdaptor
public int getType(Object t)
TreeAdaptor
getType
in interface TreeAdaptor
getType
in class BaseTreeAdaptor
public Token getToken(Object t)
public Object getChild(Object t, int i)
TreeAdaptor
getChild
in interface TreeAdaptor
getChild
in class BaseTreeAdaptor
public int getChildCount(Object t)
TreeAdaptor
getChildCount
in interface TreeAdaptor
getChildCount
in class BaseTreeAdaptor
public Object getParent(Object t)
TreeAdaptor
public int getChildIndex(Object t)
TreeAdaptor
public void setChildIndex(Object t, int index)
public void replaceChildren(Object parent, int startChildIndex, int stopChildIndex, Object t)
TreeAdaptor
Copyright © 1992–2015 ANTLR. All rights reserved.