public abstract class BaseTreeAdaptor extends Object implements TreeAdaptor
| Modifier and Type | Field and Description |
|---|---|
protected Map<Object,Integer> |
treeToUniqueIDMap
System.identityHashCode() is not always unique; we have to
track ourselves.
|
protected int |
uniqueNodeID |
| Constructor and Description |
|---|
BaseTreeAdaptor() |
| Modifier and Type | Method and Description |
|---|---|
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
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitcreate, dupNode, getChildIndex, getParent, getToken, getTokenStartIndex, getTokenStopIndex, replaceChildren, setChildIndex, setParent, setTokenBoundariesprotected Map<Object,Integer> treeToUniqueIDMap
protected int uniqueNodeID
public Object nil()
TreeAdaptornil in interface TreeAdaptorpublic Object errorNode(TokenStream input, Token start, Token stop, RecognitionException e)
errorNode in interface TreeAdaptorpublic boolean isNil(Object tree)
TreeAdaptorisNil in interface TreeAdaptorpublic Object dupTree(Object tree)
TreeAdaptordupTree in interface TreeAdaptorpublic Object dupTree(Object t, Object parent)
public void addChild(Object t, Object child)
addChild in interface TreeAdaptorpublic Object becomeRoot(Object newRoot, Object oldRoot)
becomeRoot in interface TreeAdaptorpublic Object rulePostProcessing(Object root)
rulePostProcessing in interface TreeAdaptorpublic Object becomeRoot(Token newRoot, Object oldRoot)
TreeAdaptorbecomeRoot in interface TreeAdaptorpublic Object create(int tokenType, Token fromToken)
TreeAdaptorcreate in interface TreeAdaptorpublic Object create(int tokenType, Token fromToken, String text)
TreeAdaptorcreate in interface TreeAdaptorpublic Object create(int tokenType, String text)
TreeAdaptorcreate in interface TreeAdaptorpublic int getType(Object t)
TreeAdaptorgetType in interface TreeAdaptorpublic void setType(Object t, int type)
TreeAdaptorsetType in interface TreeAdaptorpublic String getText(Object t)
getText in interface TreeAdaptorpublic void setText(Object t, String text)
TreeAdaptorsetText in interface TreeAdaptorpublic Object getChild(Object t, int i)
TreeAdaptorgetChild in interface TreeAdaptorpublic void setChild(Object t, int i, Object child)
TreeAdaptorsetChild in interface TreeAdaptorpublic Object deleteChild(Object t, int i)
TreeAdaptordeleteChild in interface TreeAdaptorpublic int getChildCount(Object t)
TreeAdaptorgetChildCount in interface TreeAdaptorpublic int getUniqueID(Object node)
TreeAdaptorgetUniqueID in interface TreeAdaptorpublic abstract Token createToken(int tokenType, String text)
public abstract Token createToken(Token fromToken)
Copyright © 1992-2013 ANTLR. All Rights Reserved.