antlraux package
v0.2.1

antlraux.context.asts
Class ExpressionAST

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

public class ExpressionAST
extends TypeAST

This class can be used to modelize the AST of an expression. It features an expression type (a Type), an RValue, LValue, and value.

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  java.lang.Object EValue
          This is a calculated value.
protected  boolean LValue
          An expression with left value set to true can be put on the left sign of an assignation; otherwise, they can't.
protected  boolean RValue
          An expression with no Rvalue cannot be used on the right side of an assignation, because they are not "readable".
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
ExpressionAST()
           
ExpressionAST(antlr.collections.AST other)
          This constructor copies the first child and next sibling of other using the initialize(AST) method
 
Method Summary
 java.lang.Object getEValue()
           
 boolean getLValue()
           
 boolean getRValue()
           
 void initialize(antlr.collections.AST ast)
          Warning: this implementation of initialize copies the first child and next sibling of ast.
 void setEValue(java.lang.Object o)
           
 void setLValue(boolean b)
           
 void setRValue(boolean b)
           
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, RValue, LValue and EValue)
 java.lang.String toString()
          Returns a String representing the information in the root of the node.
 
Methods inherited from class antlraux.context.asts.TypeAST
getExpType, setExpType
 
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

LValue

protected boolean LValue
An expression with left value set to true can be put on the left sign of an assignation; otherwise, they can't. An example of expression with LValue is a variable:
 a = 3; 
An expression without LValue could be a literal or an addition:
 "Hello"="world"; // Incorrect; "Hello" does not have LValue
 a+b = c;         // Incorrect: a+b has no LValue
 
Keep in mind that these are examples. Of course your languajes could consider having literals with lvalues...


RValue

protected boolean RValue
An expression with no Rvalue cannot be used on the right side of an assignation, because they are not "readable". The typical example is an invocation to a method that returns nothing:
 void voidFunction() {...}
 
 ...
 
 int a = voidFunction(); // Incorrect; Rvalue required
 
Of course this is an example. Some languajes might find useful setting LValue to true in this kind of function calls (thus recuperating a void value).


EValue

protected java.lang.Object EValue
This is a calculated value. Some initializations must be calculated in compile-time; for example static attribute initialization:
 class MyDumbClass{
   public int staticInt = 1+5+6;
 }
 
The value for literal "1" will be the integer 1, the value for literal "5" will be the integer 5, and the value for "6" will the the integer 6. This way, "1+5+6" can be evaluated in compile time (and set to 12).

Other use for this field is in iterpreters: The only way of calculating values is having them dynamically stored in the ASTs.


verboseStringConversion

protected static boolean verboseStringConversion
Constructor Detail

ExpressionAST

public ExpressionAST()

ExpressionAST

public ExpressionAST(antlr.collections.AST other)
This constructor copies the first child and next sibling of other using the initialize(AST) method

Method Detail

setLValue

public void setLValue(boolean b)

setRValue

public void setRValue(boolean b)

setEValue

public void setEValue(java.lang.Object o)

getLValue

public boolean getLValue()

getRValue

public boolean getRValue()

getEValue

public java.lang.Object getEValue()

initialize

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

Specified by:
initialize in interface antlr.collections.AST
Overrides:
initialize in class TypeAST
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, RValue, LValue and EValue)


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 TypeAST

antlraux package
v0.2.1

Created by Enrique José García Cota