antlr
Class BaseAST

java.lang.Object
  |
  +--antlr.BaseAST
All Implemented Interfaces:
AST, Serializable
Direct Known Subclasses:
AstroAST, CommonAST

public abstract class BaseAST
extends Object
implements AST, Serializable

Untamed: 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.

See Also:
Serialized Form

Field Summary
protected  BaseAST down
           
protected  BaseAST right
           
private static String[] tokenNames
           
private static boolean verboseStringConversion
           
 
Constructor Summary
BaseAST()
          Enabled:
 
Method Summary
 void addChild(AST node)
          Enabled: Add a node to the end of the child list for this node
static String decode(String text)
          Enabled:
private  void doWorkForFindAll(Vector v, AST target, boolean partialMatch)
           
static String encode(String text)
          Enabled:
 boolean equals(AST t)
          Enabled: Is node t equal to this in terms of token type and text?
 boolean equalsList(AST t)
          Enabled: Is t an exact structural and equals() match of this tree.
 boolean equalsListPartial(AST sub)
          Enabled: Is 'sub' a subtree of this list? The siblings of the root are NOT ignored.
 boolean equalsTree(AST t)
          Enabled: Is tree rooted at 'this' equal to 't'? The siblings of 'this' are ignored.
 boolean equalsTreePartial(AST sub)
          Enabled: Is 't' a subtree of the tree rooted at 'this'? The siblings of 'this' are ignored.
 ASTEnumeration findAll(AST target)
          Enabled: Walk the tree looking for all exact subtree matches.
 ASTEnumeration findAllPartial(AST sub)
          Enabled: Walk the tree looking for all subtrees.
 AST getFirstChild()
          Enabled: Get the first child of this node; null if not children
 AST getNextSibling()
          Enabled: Get the next sibling in line after this one
 String getText()
          Enabled: Get the token text for this node
 int getType()
          Enabled: Get the token type for this node
abstract  void initialize(AST t)
          Enabled:
abstract  void initialize(int t, String txt)
          Enabled:
abstract  void initialize(Token t)
          Enabled:
 void removeChildren()
          Enabled: Remove all children
 void setFirstChild(AST c)
          Enabled:
 void setNextSibling(AST n)
          Enabled:
 void setText(String text)
          Enabled: Set the token text for this node
 void setType(int ttype)
          Enabled: Set the token type for this node
static void setVerboseStringConversion(boolean verbose, String[] names)
          Enabled:
 String toString()
          Suppressed:
 String toStringList()
          Enabled: Print out a child-sibling tree in LISP notation
 String toStringTree()
          Enabled:
 void xmlSerialize(Writer out)
          Enabled:
 void xmlSerializeNode(Writer out)
          Enabled:
 void xmlSerializeRootClose(Writer out)
          Enabled:
 void xmlSerializeRootOpen(Writer out)
          Enabled:
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

down

protected BaseAST down

right

protected BaseAST right

verboseStringConversion

private static boolean verboseStringConversion

tokenNames

private static String[] tokenNames
Constructor Detail

BaseAST

public BaseAST()
Enabled:

Method Detail

addChild

public void addChild(AST node)
Enabled: Add a node to the end of the child list for this node

Specified by:
addChild in interface AST

doWorkForFindAll

private void doWorkForFindAll(Vector v,
                              AST target,
                              boolean partialMatch)

equals

public boolean equals(AST t)
Enabled: Is node t equal to this in terms of token type and text?

Specified by:
equals in interface AST

equalsList

public boolean equalsList(AST t)
Enabled: Is t an exact structural and equals() match of this tree. The 'this' reference is considered the start of a sibling list.

Specified by:
equalsList in interface AST

equalsListPartial

public boolean equalsListPartial(AST sub)
Enabled: Is 'sub' a subtree of this list? The siblings of the root are NOT ignored.

Specified by:
equalsListPartial in interface AST

equalsTree

public boolean equalsTree(AST t)
Enabled: Is tree rooted at 'this' equal to 't'? The siblings of 'this' are ignored.

Specified by:
equalsTree in interface AST

equalsTreePartial

public boolean equalsTreePartial(AST sub)
Enabled: Is 't' a subtree of the tree rooted at 'this'? The siblings of 'this' are ignored.

Specified by:
equalsTreePartial in interface AST

findAll

public ASTEnumeration findAll(AST target)
Enabled: Walk the tree looking for all exact subtree matches. Return an ASTEnumerator that lets the caller walk the list of subtree roots found herein.

Specified by:
findAll in interface AST

findAllPartial

public ASTEnumeration findAllPartial(AST sub)
Enabled: Walk the tree looking for all subtrees. Return an ASTEnumerator that lets the caller walk the list of subtree roots found herein.

Specified by:
findAllPartial in interface AST

getFirstChild

public AST getFirstChild()
Enabled: Get the first child of this node; null if not children

Specified by:
getFirstChild in interface AST

getNextSibling

public AST getNextSibling()
Enabled: Get the next sibling in line after this one

Specified by:
getNextSibling in interface AST

getText

public String getText()
Enabled: Get the token text for this node

Specified by:
getText in interface AST

getType

public int getType()
Enabled: Get the token type for this node

Specified by:
getType in interface AST

initialize

public abstract void initialize(int t,
                                String txt)
Enabled:

Specified by:
initialize in interface AST

initialize

public abstract void initialize(AST t)
Enabled:

Specified by:
initialize in interface AST

initialize

public abstract void initialize(Token t)
Enabled:

Specified by:
initialize in interface AST

removeChildren

public void removeChildren()
Enabled: Remove all children


setFirstChild

public void setFirstChild(AST c)
Enabled:

Specified by:
setFirstChild in interface AST

setNextSibling

public void setNextSibling(AST n)
Enabled:

Specified by:
setNextSibling in interface AST

setText

public void setText(String text)
Enabled: Set the token text for this node

Specified by:
setText in interface AST

setType

public void setType(int ttype)
Enabled: Set the token type for this node

Specified by:
setType in interface AST

setVerboseStringConversion

public static void setVerboseStringConversion(boolean verbose,
                                              String[] names)
Enabled:


toString

public String toString()
Suppressed:

Specified by:
toString in interface AST
Overrides:
toString in class Object
Returns:
a string representation of the object.

toStringList

public String toStringList()
Enabled: Print out a child-sibling tree in LISP notation

Specified by:
toStringList in interface AST

toStringTree

public String toStringTree()
Enabled:

Specified by:
toStringTree in interface AST

decode

public static String decode(String text)
Enabled:


encode

public static String encode(String text)
Enabled:


xmlSerializeNode

public void xmlSerializeNode(Writer out)
                      throws IOException
Enabled:

IOException

xmlSerializeRootOpen

public void xmlSerializeRootOpen(Writer out)
                          throws IOException
Enabled:

IOException

xmlSerializeRootClose

public void xmlSerializeRootClose(Writer out)
                           throws IOException
Enabled:

IOException

xmlSerialize

public void xmlSerialize(Writer out)
                  throws IOException
Enabled:

IOException


comments?