| 
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--antlr.BaseAST
A Child-Sibling Tree. A tree with PLUS at the root and with two children 3 and 4 is structured as: PLUS | 3 -- 4 and can be specified easily in LISP notation as (PLUS 3 4) where every '(' starts a new subtree. These trees are particular useful for translators because of the flexibility of the children lists. They are also very easy to walk automatically, whereas trees with specific children reference fields can't easily be walked automatically. This class contains the basic support for an AST. Most people will create ASTs that are subclasses of BaseAST or of CommonAST.
| Field Summary | |
protected  BaseAST | 
down
 | 
protected  BaseAST | 
right
 | 
| Constructor Summary | |
BaseAST()
 | 
|
| Method Summary | |
 void | 
addChild(AST node)
Add a node to the end of the child list for this node  | 
static String | 
decode(String text)
 | 
static String | 
encode(String text)
 | 
 boolean | 
equals(AST t)
Is node t equal to this in terms of token type and text?  | 
 boolean | 
equalsList(AST t)
Is t an exact structural and equals() match of this tree.  | 
 boolean | 
equalsListPartial(AST sub)
Is 'sub' a subtree of this list?  | 
 boolean | 
equalsTree(AST t)
Is tree rooted at 'this' equal to 't'?  | 
 boolean | 
equalsTreePartial(AST sub)
Is 't' a subtree of the tree rooted at 'this'?  | 
 ASTEnumeration | 
findAll(AST target)
Walk the tree looking for all exact subtree matches.  | 
 ASTEnumeration | 
findAllPartial(AST sub)
Walk the tree looking for all subtrees.  | 
 AST | 
getFirstChild()
Get the first child of this node; null if not children  | 
 AST | 
getNextSibling()
Get the next sibling in line after this one  | 
 int | 
getNumberOfChildren()
How many children does this node have?  | 
 String | 
getText()
Get the token text for this node  | 
 int | 
getType()
Get the token type for this node  | 
abstract  void | 
initialize(AST t)
 | 
abstract  void | 
initialize(int t,
           String txt)
 | 
abstract  void | 
initialize(Token t)
 | 
 void | 
removeChildren()
Remove all children  | 
 void | 
setFirstChild(AST c)
Set the first child of a node.  | 
 void | 
setNextSibling(AST n)
Set the next sibling after this one.  | 
 void | 
setText(String text)
Set the token text for this node  | 
 void | 
setType(int ttype)
Set the token type for this node  | 
static void | 
setVerboseStringConversion(boolean verbose,
                           String[] names)
 | 
 String | 
toString()
 | 
 String | 
toStringList()
Print out a child-sibling tree in LISP notation  | 
 String | 
toStringTree()
 | 
 void | 
xmlSerialize(Writer out)
 | 
 void | 
xmlSerializeNode(Writer out)
 | 
 void | 
xmlSerializeRootClose(Writer out)
 | 
 void | 
xmlSerializeRootOpen(Writer out)
 | 
| Methods inherited from class java.lang.Object | 
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait | 
| Field Detail | 
protected BaseAST down
protected BaseAST right
| Constructor Detail | 
public BaseAST()
| Method Detail | 
public void addChild(AST node)
addChild in interface ASTpublic int getNumberOfChildren()
getNumberOfChildren in interface ASTpublic boolean equals(AST t)
equals in interface ASTpublic boolean equalsList(AST t)
equalsList in interface ASTpublic boolean equalsListPartial(AST sub)
equalsListPartial in interface ASTpublic boolean equalsTree(AST t)
equalsTree in interface ASTpublic boolean equalsTreePartial(AST sub)
equalsTreePartial in interface ASTpublic ASTEnumeration findAll(AST target)
findAll in interface ASTpublic ASTEnumeration findAllPartial(AST sub)
findAllPartial in interface ASTpublic AST getFirstChild()
getFirstChild in interface ASTpublic AST getNextSibling()
getNextSibling in interface ASTpublic String getText()
getText in interface ASTpublic int getType()
getType in interface AST
public abstract void initialize(int t,
                                String txt)
initialize in interface ASTpublic abstract void initialize(AST t)
initialize in interface ASTpublic abstract void initialize(Token t)
initialize in interface ASTpublic void removeChildren()
public void setFirstChild(AST c)
AST
setFirstChild in interface ASTpublic void setNextSibling(AST n)
AST
setNextSibling in interface ASTpublic void setText(String text)
setText in interface ASTpublic void setType(int ttype)
setType in interface AST
public static void setVerboseStringConversion(boolean verbose,
                                              String[] names)
public String toString()
toString in interface ASTtoString in class Objectpublic String toStringList()
toStringList in interface ASTpublic String toStringTree()
toStringTree in interface ASTpublic static String decode(String text)
public static String encode(String text)
public void xmlSerializeNode(Writer out)
                      throws IOException
IOException
public void xmlSerializeRootOpen(Writer out)
                          throws IOException
IOException
public void xmlSerializeRootClose(Writer out)
                           throws IOException
IOException
public void xmlSerialize(Writer out)
                  throws IOException
IOException
  | 
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||