|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object TreeNode
TreeNode is the abstract parent class for a parse tree node. It contains an integer ID data field that is common to all types of node. The ID defines what type of tree node this is, e.g., an IF node, a PLUS, etc. The ID values are those defined for symbols in sym.java.
Extensions of TreeNode add additional data fields to hold information necessary for a particular node type. The TreeNode extensions are the following:
See the documentation for each of these extending classes for further detail.
Field Summary | |
int |
id
The ID of this node. |
Constructor Summary | |
TreeNode()
Construct a tree node with id = 0. |
|
TreeNode(int id)
Construct a tree node with the given id. |
Method Summary | |
static java.lang.String |
symPrint(int id)
Print a readable string value for a numeric-valued tree ID. |
java.lang.String |
toString()
Output the String representation of a pre-order tree traversal. |
abstract java.lang.String |
toString(int level)
This is the recursive work-doer for toString. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public int id
Constructor Detail |
public TreeNode()
public TreeNode(int id)
Method Detail |
public java.lang.String toString()
For example, the following tree
looks like this from TreeNode.toString
+ a * b cThe implementation of toString() uses an int-valued overload to perform recursive traversal, passing an incrementing level value to successive recursive invocations. See the definitions of toString(int) in each TreeNode extension for further details.
public abstract java.lang.String toString(int level)
public static java.lang.String symPrint(int id)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |