Public Member Functions | Static Public Member Functions | Protected Attributes

antlr.BaseAST Class Reference

Inheritance diagram for antlr.BaseAST:
antlr.collections.AST antlr.CommonAST antlr.ParseTree CalcAST antlr.CommonASTWithHiddenTokens ASTType49 MyAST PascalAST antlr.ParseTreeRule antlr.ParseTreeToken BinaryOperatorAST INTNode

List of all members.

Public Member Functions

void addChild (AST node)
int getNumberOfChildren ()
boolean equals (AST t)
boolean equalsList (AST t)
boolean equalsListPartial (AST sub)
boolean equalsTree (AST t)
boolean equalsTreePartial (AST sub)
ASTEnumeration findAll (AST target)
ASTEnumeration findAllPartial (AST sub)
AST getFirstChild ()
AST getNextSibling ()
String getText ()
int getType ()
int getLine ()
int getColumn ()
abstract void initialize (int t, String txt)
abstract void initialize (AST t)
abstract void initialize (Token t)
void removeChildren ()
void setFirstChild (AST c)
void setNextSibling (AST n)
void setText (String text)
void setType (int ttype)
String toString ()
String toStringList ()
String toStringTree ()
void xmlSerializeNode (Writer out) throws IOException
void xmlSerializeRootOpen (Writer out) throws IOException
void xmlSerializeRootClose (Writer out) throws IOException
void xmlSerialize (Writer out) throws IOException

Static Public Member Functions

static void setVerboseStringConversion (boolean verbose, String[] names)
static String[] getTokenNames ()
static String decode (String text)
static String encode (String text)

Protected Attributes

BaseAST down
BaseAST right

Detailed Description

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.


Member Function Documentation

void antlr.BaseAST.addChild ( AST  node  ) 
static String antlr.BaseAST.decode ( String  text  )  [static]
static String antlr.BaseAST.encode ( String  text  )  [static]
boolean antlr.BaseAST.equals ( AST  t  ) 
boolean antlr.BaseAST.equalsList ( AST  t  ) 

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

References antlr.collections.AST.equals(), antlr.collections.AST.equalsList(), antlr.collections.AST.getFirstChild(), and antlr.collections.AST.getNextSibling().

Referenced by antlr.BaseAST.equalsTree().

boolean antlr.BaseAST.equalsListPartial ( AST  sub  ) 
boolean antlr.BaseAST.equalsTree ( AST  t  ) 

Is tree rooted at 'this' equal to 't'? The siblings of 'this' are ignored.

References antlr.BaseAST.equals(), antlr.BaseAST.equalsList(), antlr.collections.AST.getFirstChild(), and antlr.BaseAST.getFirstChild().

boolean antlr.BaseAST.equalsTreePartial ( AST  sub  ) 

Is 't' a subtree of the tree rooted at 'this'? The siblings of 'this' are ignored.

References antlr.BaseAST.equals(), antlr.BaseAST.equalsListPartial(), antlr.collections.AST.getFirstChild(), and antlr.BaseAST.getFirstChild().

ASTEnumeration antlr.BaseAST.findAll ( AST  target  ) 

Walk the tree looking for all exact subtree matches. Return an ASTEnumerator that lets the caller walk the list of subtree roots found herein.

ASTEnumeration antlr.BaseAST.findAllPartial ( AST  sub  ) 

Walk the tree looking for all subtrees. Return an ASTEnumerator that lets the caller walk the list of subtree roots found herein.

int antlr.BaseAST.getColumn (  ) 
int antlr.BaseAST.getLine (  ) 
AST antlr.BaseAST.getNextSibling (  ) 

Get the next sibling in line after this one

References antlr.BaseAST.right.

Referenced by BinaryOperatorAST.right(), and SymtabPhase.usesUnitsPart().

int antlr.BaseAST.getNumberOfChildren (  ) 

How many children does this node have?

References antlr.BaseAST.down, and antlr.BaseAST.right.

String antlr.BaseAST.getText (  ) 
static String [] antlr.BaseAST.getTokenNames (  )  [static]

Return an array of strings that maps token ID to it's text.

Since:
2.7.3
int antlr.BaseAST.getType (  ) 
abstract void antlr.BaseAST.initialize ( int  t,
String  txt 
) [pure virtual]

Implemented in antlr.CommonAST, antlr.ParseTree, and CalcAST.

abstract void antlr.BaseAST.initialize ( AST  t  )  [pure virtual]
abstract void antlr.BaseAST.initialize ( Token  t  )  [pure virtual]
void antlr.BaseAST.removeChildren (  ) 

Remove all children

References antlr.BaseAST.down.

void antlr.BaseAST.setFirstChild ( AST  c  ) 

References antlr.BaseAST.down.

void antlr.BaseAST.setNextSibling ( AST  n  ) 

References antlr.BaseAST.right.

void antlr.BaseAST.setText ( String  text  ) 

Set the token text for this node

Reimplemented in antlr.CommonAST.

void antlr.BaseAST.setType ( int  ttype  ) 

Set the token type for this node

Reimplemented in antlr.CommonAST.

static void antlr.BaseAST.setVerboseStringConversion ( boolean  verbose,
String[]  names 
) [static]
String antlr.BaseAST.toStringList (  ) 

Print out a child-sibling tree in LISP notation

References antlr.collections.AST.getFirstChild(), antlr.collections.AST.getNextSibling(), and antlr.BaseAST.toString().

Referenced by Calc.main(), and antlr.BaseAST.toStringTree().

String antlr.BaseAST.toStringTree (  ) 
void antlr.BaseAST.xmlSerialize ( Writer  out  )  throws IOException

Referenced by Main.main().

void antlr.BaseAST.xmlSerializeNode ( Writer  out  )  throws IOException
void antlr.BaseAST.xmlSerializeRootClose ( Writer  out  )  throws IOException

Reimplemented in MULTNode, and PLUSNode.

void antlr.BaseAST.xmlSerializeRootOpen ( Writer  out  )  throws IOException

Member Data Documentation


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Enumerations Properties