|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.antlr.runtime.tree.BaseTreeAdaptor
public abstract class BaseTreeAdaptor
A TreeAdaptor that works with any Tree implementation.
Field Summary | |
---|---|
protected java.util.Map |
treeToUniqueIDMap
System.identityHashCode() is not always unique; we have to track ourselves. |
protected int |
uniqueNodeID
|
Constructor Summary | |
---|---|
BaseTreeAdaptor()
|
Method Summary | |
---|---|
void |
addChild(java.lang.Object t,
java.lang.Object child)
Add a child to the tree t. |
java.lang.Object |
becomeRoot(java.lang.Object newRoot,
java.lang.Object oldRoot)
If oldRoot is a nil root, just copy or move the children to newRoot. |
java.lang.Object |
becomeRoot(Token newRoot,
java.lang.Object oldRoot)
Create a node for newRoot make it the root of oldRoot. |
java.lang.Object |
create(int tokenType,
java.lang.String text)
Create a new node derived from a token, with a new token type. |
java.lang.Object |
create(int tokenType,
Token fromToken)
Create a new node derived from a token, with a new token type. |
java.lang.Object |
create(int tokenType,
Token fromToken,
java.lang.String text)
Same as create(tokenType,fromToken) except set the text too. |
abstract Token |
createToken(int tokenType,
java.lang.String text)
Tell me how to create a token for use with imaginary token nodes. |
abstract Token |
createToken(Token fromToken)
Tell me how to create a token for use with imaginary token nodes. |
java.lang.Object |
deleteChild(java.lang.Object t,
int i)
Remove ith child and shift children down from right. |
java.lang.Object |
dupTree(java.lang.Object tree)
Duplicate tree recursively, using dupNode() for each node |
java.lang.Object |
dupTree(java.lang.Object t,
java.lang.Object parent)
This is generic in the sense that it will work with any kind of tree (not just Tree interface). |
java.lang.Object |
errorNode(TokenStream input,
Token start,
Token stop,
RecognitionException e)
create tree node that holds the start and stop tokens associated with an error. |
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 |
java.lang.String |
getText(java.lang.Object t)
|
int |
getType(java.lang.Object t)
For tree parsing, I need to know the token type of a node |
int |
getUniqueID(java.lang.Object node)
For identifying trees. |
boolean |
isNil(java.lang.Object tree)
Is tree considered a nil node used to make lists of child nodes? |
java.lang.Object |
nil()
Return a nil node (an empty but non-null node) that can hold a list of element as the children. |
java.lang.Object |
rulePostProcessing(java.lang.Object root)
Transform ^(nil x) to x and nil to null |
void |
setChild(java.lang.Object t,
int i,
java.lang.Object child)
Set ith child (0..n-1) to t; t must be non-null and non-nil node |
void |
setText(java.lang.Object t,
java.lang.String text)
Node constructors can set the text of a node |
void |
setType(java.lang.Object t,
int type)
Node constructors can set the type of a node |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.antlr.runtime.tree.TreeAdaptor |
---|
create, dupNode, getChildIndex, getParent, getToken, getTokenStartIndex, getTokenStopIndex, replaceChildren, setChildIndex, setParent, setTokenBoundaries |
Field Detail |
---|
protected java.util.Map treeToUniqueIDMap
protected int uniqueNodeID
Constructor Detail |
---|
public BaseTreeAdaptor()
Method Detail |
---|
public java.lang.Object nil()
TreeAdaptor
nil
in interface TreeAdaptor
public java.lang.Object errorNode(TokenStream input, Token start, Token stop, RecognitionException e)
errorNode
in interface TreeAdaptor
public boolean isNil(java.lang.Object tree)
TreeAdaptor
isNil
in interface TreeAdaptor
public java.lang.Object dupTree(java.lang.Object tree)
TreeAdaptor
dupTree
in interface TreeAdaptor
public java.lang.Object dupTree(java.lang.Object t, java.lang.Object parent)
public void addChild(java.lang.Object t, java.lang.Object child)
addChild
in interface TreeAdaptor
public java.lang.Object becomeRoot(java.lang.Object newRoot, java.lang.Object oldRoot)
becomeRoot
in interface TreeAdaptor
public java.lang.Object rulePostProcessing(java.lang.Object root)
rulePostProcessing
in interface TreeAdaptor
public java.lang.Object becomeRoot(Token newRoot, java.lang.Object oldRoot)
TreeAdaptor
becomeRoot
in interface TreeAdaptor
public java.lang.Object create(int tokenType, Token fromToken)
TreeAdaptor
create
in interface TreeAdaptor
public java.lang.Object create(int tokenType, Token fromToken, java.lang.String text)
TreeAdaptor
create
in interface TreeAdaptor
public java.lang.Object create(int tokenType, java.lang.String text)
TreeAdaptor
create
in interface TreeAdaptor
public int getType(java.lang.Object t)
TreeAdaptor
getType
in interface TreeAdaptor
public void setType(java.lang.Object t, int type)
TreeAdaptor
setType
in interface TreeAdaptor
public java.lang.String getText(java.lang.Object t)
getText
in interface TreeAdaptor
public void setText(java.lang.Object t, java.lang.String text)
TreeAdaptor
setText
in interface TreeAdaptor
public java.lang.Object getChild(java.lang.Object t, int i)
TreeAdaptor
getChild
in interface TreeAdaptor
public void setChild(java.lang.Object t, int i, java.lang.Object child)
TreeAdaptor
setChild
in interface TreeAdaptor
public java.lang.Object deleteChild(java.lang.Object t, int i)
TreeAdaptor
deleteChild
in interface TreeAdaptor
public int getChildCount(java.lang.Object t)
TreeAdaptor
getChildCount
in interface TreeAdaptor
public int getUniqueID(java.lang.Object node)
TreeAdaptor
getUniqueID
in interface TreeAdaptor
public abstract Token createToken(int tokenType, java.lang.String text)
public abstract Token createToken(Token fromToken)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |