|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object antlr.BaseAST antlr.CommonAST com.ph.pr.apps.jaspcleaner.TNode
public class TNode
Class TNode is an implementation of the AST interface and adds many useful features: It is double-linked for reverse searching. (this is currently incomplete, in that method doubleLink() must be called after any changes to the tree to maintain the reverse links). It can store a definition node (defNode), so that nodes such as scoped names can refer to the node that defines the name. It stores line numbers for nodes. Searches for parents and children of a tree can be done based on their type. The tree can be printed to System.out using a lisp-style syntax.
Field Summary | |
---|---|
protected java.util.Hashtable |
attributes
|
protected int |
colNum
|
protected TNode |
defNode
|
protected TNode |
left
|
protected int |
lineNum
|
protected boolean |
marker
|
protected java.lang.String |
text
|
(package private) static java.lang.String |
tokenVocabulary
|
protected int |
ttype
|
protected TNode |
up
|
Fields inherited from class antlr.BaseAST |
---|
down, right |
Constructor Summary | |
---|---|
TNode()
|
Method Summary | |
---|---|
void |
addSibling(antlr.collections.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 |
java.lang.Object |
getAttribute(java.lang.String attrName)
lookup the attribute name in the attribute table. |
java.util.Hashtable |
getAttributesTable()
get the hashtable that holds attribute values. |
int |
getColNum()
Get the line number for this node. |
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 |
getLocalColNum()
|
int |
getLocalLineNum()
|
boolean |
getMarker()
Get the marker value for this node. |
static java.lang.String |
getNameForType(int t)
converts an int tree token type to a name. |
TNode |
getParent()
return the parent node of this node |
TNode |
getPrevSibling()
Get the previous sibling in line before this one |
java.lang.String |
getText()
Get the token text for this node |
int |
getType()
Get the token type for this node |
void |
initialize(antlr.collections.AST tr)
|
void |
initialize(antlr.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(antlr.collections.AST t,
int indent)
protected method that does the work of printing |
static void |
printTree(antlr.collections.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(java.lang.String attrName,
java.lang.Object value)
set an attribute in the attribute table. |
void |
setColNum(int colNum_)
Set the column number for this node |
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(java.lang.String text_)
Set the token text for this node |
static void |
setTokenVocabulary(java.lang.String s)
Set the token vocabulary to a tokentypes class generated by antlr. |
void |
setType(int ttype_)
Set the token type for this node |
java.lang.String |
toString()
return a short string representation of the node |
Methods inherited from class antlr.CommonAST |
---|
initialize |
Methods inherited from class antlr.BaseAST |
---|
addChild, decode, encode, equals, equalsList, equalsListPartial, equalsTree, equalsTreePartial, findAll, findAllPartial, getColumn, getFirstChild, getLine, getNextSibling, getNumberOfChildren, getTokenNames, removeChildren, setFirstChild, setNextSibling, setVerboseStringConversion, toStringList, toStringTree, xmlSerialize, xmlSerializeNode, xmlSerializeRootClose, xmlSerializeRootOpen |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected int ttype
protected java.lang.String text
protected int lineNum
protected int colNum
protected TNode defNode
protected TNode up
protected TNode left
protected boolean marker
protected java.util.Hashtable attributes
static java.lang.String tokenVocabulary
Constructor Detail |
---|
public TNode()
Method Detail |
---|
public static void setTokenVocabulary(java.lang.String s)
public void initialize(antlr.Token token)
initialize
in interface antlr.collections.AST
initialize
in class antlr.CommonAST
public void initialize(antlr.collections.AST tr)
initialize
in interface antlr.collections.AST
initialize
in class antlr.CommonAST
public int getType()
getType
in interface antlr.collections.AST
getType
in class antlr.CommonAST
public void setType(int ttype_)
setType
in interface antlr.collections.AST
setType
in class antlr.CommonAST
public boolean getMarker()
public void setMarker(boolean marker_)
public java.util.Hashtable getAttributesTable()
public void setAttribute(java.lang.String attrName, java.lang.Object value)
public java.lang.Object getAttribute(java.lang.String attrName)
public int getLineNum()
public int getLocalLineNum()
public int getColNum()
public int getLocalColNum()
public void setLineNum(int lineNum_)
public void setColNum(int colNum_)
public java.lang.String getText()
getText
in interface antlr.collections.AST
getText
in class antlr.CommonAST
public void setText(java.lang.String text_)
setText
in interface antlr.collections.AST
setText
in class antlr.CommonAST
public TNode getLastChild()
public TNode getLastSibling()
public TNode getFirstSibling()
public TNode getPrevSibling()
public TNode getParent()
public void addSibling(antlr.collections.AST node)
public int numberOfChildren()
public void removeSelf()
public TNode getDefNode()
public void setDefNode(TNode n)
public TNode deepCopy()
public TNode deepCopyWithRightSiblings()
public java.lang.String toString()
toString
in interface antlr.collections.AST
toString
in class antlr.BaseAST
public static void printTree(antlr.collections.AST t)
protected static void printASTNode(antlr.collections.AST t, int indent)
public static java.lang.String getNameForType(int t)
public void doubleLink()
public TNode parentOfType(int type)
public TNode firstChildOfType(int type)
public TNode firstSiblingOfType(int type)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |