|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.antlr.runtime.tree.BaseTreeAdaptor
org.antlr.runtime.tree.CommonTreeAdaptor
public class CommonTreeAdaptor
A TreeAdaptor that works with any Tree implementation. It provides really just factory methods; all the work is done by BaseTreeAdaptor. If you would like to have different tokens created than ClassicToken objects, you need to override this and then set the parser tree adaptor to use your subclass. To get your parser to build nodes of a different type, override create(Token), errorNode(), and to be safe, YourTreeClass.dupNode(). dupNode is called to duplicate nodes during rewrite operations.
Field Summary |
---|
Fields inherited from class org.antlr.runtime.tree.BaseTreeAdaptor |
---|
treeToUniqueIDMap, uniqueNodeID |
Constructor Summary | |
---|---|
CommonTreeAdaptor()
|
Method Summary | |
---|---|
java.lang.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,
java.lang.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. |
java.lang.Object |
dupNode(java.lang.Object t)
Duplicate a node. |
java.lang.Object |
getChild(java.lang.Object t,
int i)
Get a child 0..n-1 node |
int |
getChildCount(java.lang.Object t)
How many children? If 0, then this is a leaf node |
int |
getChildIndex(java.lang.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. |
java.lang.Object |
getParent(java.lang.Object t)
Who is the parent node of this node; if null, implies node is root. |
java.lang.String |
getText(java.lang.Object t)
|
Token |
getToken(java.lang.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(java.lang.Object t)
Get the token start index for this subtree; return -1 if no such index |
int |
getTokenStopIndex(java.lang.Object t)
Get the token stop index for this subtree; return -1 if no such index |
int |
getType(java.lang.Object t)
For tree parsing, I need to know the token type of a node |
void |
replaceChildren(java.lang.Object parent,
int startChildIndex,
int stopChildIndex,
java.lang.Object t)
Replace from start to stop child index of parent with t, which might be a list. |
void |
setChildIndex(java.lang.Object t,
int index)
|
void |
setParent(java.lang.Object t,
java.lang.Object parent)
|
void |
setTokenBoundaries(java.lang.Object t,
Token startToken,
Token stopToken)
Track start/stop token for subtree root created for a rule. |
Methods inherited from class org.antlr.runtime.tree.BaseTreeAdaptor |
---|
addChild, becomeRoot, becomeRoot, create, create, create, deleteChild, dupTree, dupTree, errorNode, getUniqueID, isNil, nil, rulePostProcessing, setChild, setText, setType |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public CommonTreeAdaptor()
Method Detail |
---|
public java.lang.Object dupNode(java.lang.Object t)
public java.lang.Object create(Token payload)
TreeAdaptor
public Token createToken(int tokenType, java.lang.String text)
createToken
in class BaseTreeAdaptor
public Token createToken(Token fromToken)
createToken
in class BaseTreeAdaptor
public void setTokenBoundaries(java.lang.Object t, Token startToken, Token stopToken)
public int getTokenStartIndex(java.lang.Object t)
TreeAdaptor
public int getTokenStopIndex(java.lang.Object t)
TreeAdaptor
public java.lang.String getText(java.lang.Object t)
getText
in interface TreeAdaptor
getText
in class BaseTreeAdaptor
public int getType(java.lang.Object t)
TreeAdaptor
getType
in interface TreeAdaptor
getType
in class BaseTreeAdaptor
public Token getToken(java.lang.Object t)
public java.lang.Object getChild(java.lang.Object t, int i)
TreeAdaptor
getChild
in interface TreeAdaptor
getChild
in class BaseTreeAdaptor
public int getChildCount(java.lang.Object t)
TreeAdaptor
getChildCount
in interface TreeAdaptor
getChildCount
in class BaseTreeAdaptor
public java.lang.Object getParent(java.lang.Object t)
TreeAdaptor
public void setParent(java.lang.Object t, java.lang.Object parent)
public int getChildIndex(java.lang.Object t)
TreeAdaptor
public void setChildIndex(java.lang.Object t, int index)
public void replaceChildren(java.lang.Object parent, int startChildIndex, int stopChildIndex, java.lang.Object t)
TreeAdaptor
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |