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