antlraux package
v0.2.1

antlraux.context.asts
Class TypeAST

java.lang.Object
  |
  +--antlr.BaseAST
        |
        +--antlr.CommonAST
              |
              +--antlraux.util.LexInfoAST
                    |
                    +--antlraux.context.asts.TypeAST
All Implemented Interfaces:
antlr.collections.AST, LexInfo, java.io.Serializable
Direct Known Subclasses:
ExpressionAST

public class TypeAST
extends LexInfoAST

This class may be used when modelling an AST with type information. It sould not be used for expressions; ExpressionAST is more suited for that. This class could be used for easily obtaining the Type of tree node that codes a type. Typically you'll have that kind of node at the beginning of your declarations. For example, in a languaje that declares variables like in C you may have:

 int a;
 
The rule that recognizes this declaration could be:
 declaration: type IDENT SEMI ;
 type : TYPE_INT
      | TYPE_FLOAT
      | ...
      ;
 
TypeAST sould be used in the type rule, like this:
 type : TYPE_INT 
        { ##.setExpType(getType(TYPE_INT)); }
      | TYPE_FLOAT
        ...
      ;
 
Once this is done, you can obtain one type's "expression type" just calling getExpType().

Warning: TypeAST, ExpressionAST and ScopeAST copy first child and sibling with their only constructor. See their constructor's comments for details.

See Also:
Serialized Form

Field Summary
protected static boolean verboseStringConversion
           
 
Fields inherited from class antlr.BaseAST
down, right
 
Fields inherited from interface antlraux.util.LexInfo
DEFAULT_COLUMN, DEFAULT_FILENAME, DEFAULT_LINE
 
Constructor Summary
TypeAST()
           
TypeAST(antlr.collections.AST other)
          This constructors calls initialize(AST) so it copies other's first child and next sibling.
 
Method Summary
 Type getExpType()
           
 void initialize(antlr.collections.AST ast)
          Warning: this implementation of initialize copies ast's first child and next sibling.
 void setExpType(Type t)
           
static void setVerboseStringConversion(boolean b)
          If set to true, this adds some additional information to the string generated by toString() (shows the AST's type)
 java.lang.String toString()
          Returns a String representing the information in the root of the node.
 
Methods inherited from class antlraux.util.LexInfoAST
addChildLeft, addChildLeftWithSiblings, addSibling, copyLexInfo, getColumn, getFilename, getLastChild, getLastSibling, getLexInfoString, getLine, getPrevChild, initialize, replaceChild, replaceChildWithSiblings, setColumn, setFilename, setLine, tabulate, toStringList, toStringList, toStringTree
 
Methods inherited from class antlr.CommonAST
getText, getType, initialize, setText, setType
 
Methods inherited from class antlr.BaseAST
addChild, decode, encode, equals, equalsList, equalsListPartial, equalsTree, equalsTreePartial, findAll, findAllPartial, getFirstChild, getNextSibling, getNumberOfChildren, removeChildren, setFirstChild, setNextSibling, setVerboseStringConversion, xmlSerialize, xmlSerializeNode, xmlSerializeRootClose, xmlSerializeRootOpen
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

verboseStringConversion

protected static boolean verboseStringConversion
Constructor Detail

TypeAST

public TypeAST()

TypeAST

public TypeAST(antlr.collections.AST other)
This constructors calls initialize(AST) so it copies other's first child and next sibling.

Method Detail

setExpType

public void setExpType(Type t)

getExpType

public Type getExpType()

initialize

public void initialize(antlr.collections.AST ast)
Warning: this implementation of initialize copies ast's first child and next sibling.

Specified by:
initialize in interface antlr.collections.AST
Overrides:
initialize in class LexInfoAST
Parameters:
ast - The AST whose information is to be copied

setVerboseStringConversion

public static void setVerboseStringConversion(boolean b)
If set to true, this adds some additional information to the string generated by toString() (shows the AST's type)


toString

public java.lang.String toString()
Description copied from class: LexInfoAST
Returns a String representing the information in the root of the node. If LexInfoAST.setVerboseStringConversion(boolean) has been set to true, it adds the lex information of the AST (using LexInfoAST.getLexInfoString())

Specified by:
toString in interface antlr.collections.AST
Overrides:
toString in class LexInfoAST

antlraux package
v0.2.1

Created by Enrique José García Cota