public class TNode
extends CommonAST
Modifier and Type | Field and Description |
---|---|
protected Hashtable<String,Object> |
attributes |
protected TNode |
defNode |
protected TNode |
left |
protected int |
lineNum |
protected boolean |
marker |
protected String |
text |
protected int |
ttype |
protected TNode |
up |
Constructor and Description |
---|
TNode() |
Modifier and Type | Method and Description |
---|---|
void |
addSibling(AST node)
add the new node as a new sibling, inserting it ahead of any
existing next sibling.
|
TNode |
deepCopy()
return a deep copy of this node, and all sub nodes.
|
TNode |
deepCopyWithRightSiblings()
return a deep copy of this node, all sub nodes,
and right siblings.
|
void |
doubleLink()
set up reverse links between this node and its first
child and its first sibling, and link those as well
|
TNode |
firstChildOfType(int type)
find the first child of the node
of the given type, return null on failure
|
TNode |
firstSiblingOfType(int type)
find the first sibling of the node
of the given type, return null on failure
|
String |
getAllChildrenText()
Returns the text for this node and all children
|
Object |
getAttribute(String attrName)
lookup the attribute name in the attribute table.
|
Hashtable<String,Object> |
getAttributesTable()
get the hashtable that holds attribute values.
|
TNode |
getDefNode()
return the def node for this node
|
TNode |
getFirstSibling()
return the first sibling of this node, which is
this if the prev sibling is null
|
TNode |
getLastChild()
return the last child of this node, or null if there is none
|
TNode |
getLastSibling()
return the last sibling of this node, which is
this if the next sibling is null
|
int |
getLineNum()
Get the line number for this node.
|
int |
getLocalLineNum() |
boolean |
getMarker()
Get the marker value for this node.
|
static String |
getNameForType(int t)
converts an int tree token type to a name.
|
TNode |
getParent()
return the parent node of this node
|
String |
getText()
Get the token text for this node
|
int |
getType()
Get the token type for this node
|
void |
initialize(AST tr) |
void |
initialize(Token token) |
int |
numberOfChildren()
return the number of children of this node
|
TNode |
parentOfType(int type)
find first parent of the given type,
return null on failure
|
protected static void |
printASTNode(AST t,
int indent)
protected method that does the work of printing
|
static void |
printTree(AST t)
print given tree to System.out
|
void |
removeSelf()
remove this node from the tree, resetting sibling and parent
pointers as necessary.
|
void |
setAttribute(String attrName,
Object value)
set an attribute in the attribute table.
|
void |
setDefNode(TNode n)
set the def node for this node
|
void |
setLineNum(int lineNum_)
Set the line number for this node
|
void |
setMarker(boolean marker_)
Set the marker value for this node.
|
void |
setText(String text_)
Set the token text for this node
|
static void |
setTokenVocabulary(String s)
Set the token vocabulary to a tokentypes class
generated by antlr.
|
void |
setType(int ttype_)
Set the token type for this node
|
String |
toString()
return a short string representation of the node
|
protected int ttype
protected String text
protected int lineNum
protected TNode defNode
protected TNode up
protected TNode left
protected boolean marker
public static void setTokenVocabulary(String s)
public void initialize(Token token)
public void initialize(AST tr)
public int getType()
public void setType(int ttype_)
public boolean getMarker()
public void setMarker(boolean marker_)
public Hashtable<String,Object> getAttributesTable()
public void setAttribute(String attrName, Object value)
public Object getAttribute(String attrName)
public int getLineNum()
public int getLocalLineNum()
public void setLineNum(int lineNum_)
public String getText()
public void setText(String text_)
public String getAllChildrenText()
public TNode getLastChild()
public TNode getLastSibling()
public TNode getFirstSibling()
public TNode getParent()
public void addSibling(AST node)
public int numberOfChildren()
public void removeSelf()
public TNode getDefNode()
public void setDefNode(TNode n)
public TNode deepCopy()
public TNode deepCopyWithRightSiblings()
public String toString()
public static void printTree(AST t)
protected static void printASTNode(AST t, int indent)
public static String getNameForType(int t)
public void doubleLink()
public TNode parentOfType(int type)
public TNode firstChildOfType(int type)
public TNode firstSiblingOfType(int type)