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, wait
create, dupNode, getChildIndex, getParent, getToken, getTokenStartIndex, getTokenStopIndex, replaceChildren, setChildIndex, setParent, setTokenBoundaries
protected Map<Object,Integer> treeToUniqueIDMap
protected int uniqueNodeID
public Object nil()
TreeAdaptor
nil
in interface TreeAdaptor
public Object errorNode(TokenStream input, Token start, Token stop, RecognitionException e)
errorNode
in interface TreeAdaptor
public boolean isNil(Object tree)
TreeAdaptor
isNil
in interface TreeAdaptor
public 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 TreeAdaptor
public 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 TreeAdaptor
public int getType(Object t)
TreeAdaptor
getType
in interface TreeAdaptor
public void setType(Object t, int type)
TreeAdaptor
setType
in interface TreeAdaptor
public 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 TreeAdaptor
public int getChildCount(Object t)
TreeAdaptor
getChildCount
in interface TreeAdaptor
public int getUniqueID(Object node)
TreeAdaptor
getUniqueID
in interface TreeAdaptor
public abstract Token createToken(int tokenType, String text)
public abstract Token createToken(Token fromToken)
Copyright © 1992–2015 ANTLR. All rights reserved.