org.omegahat.Environment.Parser.Parse
Class BasicExpression

java.lang.Object
  |
  +--antlr.BaseAST
        |
        +--antlr.CommonAST
              |
              +--org.omegahat.Environment.Parser.Parse.BasicExpression
All Implemented Interfaces:
antlr.collections.AST, Evaluable, ExpressionInt, OmegaTokenTypes, java.lang.Runnable, java.io.Serializable, Subsettable, TreeNodeInt
Direct Known Subclasses:
AllTerms, Catch, ClassDefinition, Comment, ConditionalExpressionStatement, ConstantExpression, ElementAccess, EnumeratedForLoop, FlowControl, ForLoop, FunctionCall, FunctionExpression, FunctionType, LazyArgument, List, LocalVariable, NumberExpression, SimpleParameterModifier, Type

public abstract class BasicExpression
extends antlr.CommonAST
implements ExpressionInt, java.lang.Runnable, OmegaTokenTypes, java.io.Serializable, Subsettable

Fundamental expression class which most of the language expression classes extend. This provides the tree connectivity support, evaluator access, substitute mechanism, reflectance hooks, and so on.

See Also:
Serialized Form

Field Summary
protected  java.util.Vector children
           
protected  Comment[] comments
           
protected  boolean isActive
           
protected  TreeNodeInt parent
           
static int POST
           
static int PRE
           
 
Fields inherited from class antlr.BaseAST
down, right
 
Fields inherited from interface org.omegahat.Environment.Parser.AntlrParser.OmegaTokenTypes
ABSTRACT, ARG_LIST, ARRAY_DECLARATOR, ARRAY_INIT, ASSIGN, BAND, BAND_ASSIGN, BLOCK, BNOT, BOR, BOR_ASSIGN, BREAK, BSR, BSR_ASSIGN, BXOR, BXOR_ASSIGN, CHAR_LITERAL, CLASS_DEF, COLON, COMMA, CONTINUE, CTOR_DEF, DEC, DIV, DIV_ASSIGN, DOT, DOTS, EAGER, ELEMENT_OP, EOF, EQUAL, ESC, EXPONENT, EXPONENT_OP, EXPR, EXTENDS_CLAUSE, FINAL, FLOAT_SUFFIX, FUNCTION, GE, GT, HEX_DIGIT, IDENT, IMPLEMENTS_CLAUSE, IMPORT, INC, INDEX_OP, INSTANCE_INIT, INSTANCEOF, INTERFACE_DEF, LABELED_STAT, LAND, LAZY, LBRACK, LCURLY, LE, LITERAL_abstract, LITERAL_boolean, LITERAL_break, LITERAL_byte, LITERAL_case, LITERAL_catch, LITERAL_char, LITERAL_class, LITERAL_const, LITERAL_continue, LITERAL_default, LITERAL_do, LITERAL_double, LITERAL_eager, LITERAL_else, LITERAL_extends, LITERAL_false, LITERAL_final, LITERAL_finally, LITERAL_float, LITERAL_for, LITERAL_function, LITERAL_global, LITERAL_if, LITERAL_implements, LITERAL_import, LITERAL_in, LITERAL_instanceof, LITERAL_int, LITERAL_interface, LITERAL_lazy, LITERAL_long, LITERAL_method, LITERAL_native, LITERAL_new, LITERAL_null, LITERAL_private, LITERAL_protected, LITERAL_public, LITERAL_return, LITERAL_short, LITERAL_static, LITERAL_super, LITERAL_switch, LITERAL_synchronized, LITERAL_this, LITERAL_threadsafe, LITERAL_throw, LITERAL_throws, LITERAL_transient, LITERAL_true, LITERAL_try, LITERAL_void, LITERAL_while, LNOT, LOR, LPAREN, LT, METHOD, METHOD_CALL, METHOD_DEF, MINUS, MINUS_ASSIGN, MISSING_ARG, ML_COMMENT, MOD, MOD_ASSIGN, MODIFIERS, NOT_EQUAL, NULL_TREE_LOOKAHEAD, NUM_FLOAT, NUM_INT, NUM_LONG, OBJBLOCK, PACKAGE_DEF, PARAMETER_DEF, PARAMETERS, PLUS, PLUS_ASSIGN, POST_DEC, POST_INC, QUESTION, RBRACK, RCURLY, RETURN, RPAREN, SEMI, SEQUENCE_OP, SL, SL_ASSIGN, SL_COMMENT, SLIST, SR, SR_ASSIGN, STAR, STAR_ASSIGN, STATIC_INIT, STRING_LITERAL, SYNCHRONIZED, THROW, TRANSIENT, TYPE, TYPECAST, UNARY_MINUS, UNARY_PLUS, VARIABLE_DEF, VOCAB, WS
 
Constructor Summary
BasicExpression()
           
BasicExpression(TreeNodeInt parent)
           
 
Method Summary
 TreeNodeInt addChild(TreeNodeInt src)
           
 int addComment(Comment c, int which)
           
 java.lang.Object apply(Function f)
           
 java.lang.Object apply(Function f, Evaluator evaluator)
           
 java.lang.Object apply(Function f, Evaluator evaluator, java.util.Vector result)
           
 java.util.Vector children()
           
 java.util.Vector children(java.util.Vector v)
           
 Comment comment(int which)
           
 Comment comment(int which, Comment c)
           
 int depth()
           
 java.lang.Exception error(java.lang.String msg, Evaluator evaluator)
           
 java.lang.Object eval(Evaluator evaluator)
           
 java.lang.Object eval(java.lang.Object[] args, Evaluator evaluator)
           
 void evalInit(Evaluator evaluator)
           
 Database evaluationFrame(java.lang.String name, Evaluator evaluator)
           
 Evaluator evaluator()
           
 java.util.AbstractCollection getReferencedVariables()
           
 java.util.AbstractCollection getReferencedVariables(boolean recursive)
          Return a list of the different variables identified in the expression.
 java.util.AbstractCollection getReferencedVariables(boolean recursive, java.util.AbstractCollection container)
           
 boolean isActive()
           
 boolean isActive(boolean val)
           
 TreeNodeInt parent()
           
 TreeNodeInt parent(TreeNodeInt p)
           
 Comment postComment()
           
 Comment postComment(Comment c)
           
 Comment preComment()
           
 Comment preComment(Comment c)
           
 java.lang.String render(boolean expanded)
           
 int replaceChild(TreeNodeInt originalChild, TreeNodeInt newChild)
           
 ExpressionInt resolve(Evaluator evaluator)
          Rewrite the expression by resolving class names, methods, etc.
 void run()
           
 boolean setParent(java.util.Enumeration e)
           
 boolean setParent(List l)
           
 boolean setParent(TreeNodeInt node)
           
 boolean setParent(java.util.Vector els)
           
 java.lang.String showComments(int which)
           
 java.lang.String showComments(int which, int max)
           
 java.lang.Object subset(java.lang.Object index, boolean keepStructure)
           
 ExpressionInt substitute(java.util.Hashtable db)
          Substitute the variable names in this expression (and its sub-components) present in the hashtable or database with the associated actual values.
 ExpressionInt substitute(java.util.Hashtable db, boolean expand)
           
 java.lang.String toString()
           
 
Methods inherited from class antlr.CommonAST
getText, getType, initialize, initialize, initialize, setText, setType
 
Methods inherited from class antlr.BaseAST
addChild, equals, equalsList, equalsListPartial, equalsTree, equalsTreePartial, findAll, findAllPartial, getFirstChild, getNextSibling, removeChildren, setFirstChild, setNextSibling, setVerboseStringConversion, toStringList, toStringTree
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

PRE

public static final int PRE

POST

public static final int POST

children

protected java.util.Vector children

parent

protected TreeNodeInt parent

isActive

protected boolean isActive

comments

protected Comment[] comments
Constructor Detail

BasicExpression

public BasicExpression()

BasicExpression

public BasicExpression(TreeNodeInt parent)
Method Detail

children

public java.util.Vector children()
Specified by:
children in interface TreeNodeInt

children

public java.util.Vector children(java.util.Vector v)

parent

public TreeNodeInt parent()
Specified by:
parent in interface TreeNodeInt

parent

public TreeNodeInt parent(TreeNodeInt p)
Specified by:
parent in interface TreeNodeInt

addChild

public TreeNodeInt addChild(TreeNodeInt src)
Specified by:
addChild in interface TreeNodeInt

replaceChild

public int replaceChild(TreeNodeInt originalChild,
                        TreeNodeInt newChild)
Specified by:
replaceChild in interface TreeNodeInt

setParent

public boolean setParent(java.util.Vector els)

setParent

public boolean setParent(List l)

setParent

public boolean setParent(java.util.Enumeration e)

setParent

public boolean setParent(TreeNodeInt node)

depth

public int depth()
Specified by:
depth in interface TreeNodeInt

run

public void run()
Specified by:
run in interface java.lang.Runnable

evaluator

public Evaluator evaluator()

eval

public java.lang.Object eval(Evaluator evaluator)
                      throws java.lang.Throwable
Specified by:
eval in interface Evaluable

eval

public java.lang.Object eval(java.lang.Object[] args,
                             Evaluator evaluator)
                      throws java.lang.Throwable
Specified by:
eval in interface Evaluable

evalInit

public void evalInit(Evaluator evaluator)

evaluationFrame

public Database evaluationFrame(java.lang.String name,
                                Evaluator evaluator)

isActive

public boolean isActive()

isActive

public boolean isActive(boolean val)

toString

public java.lang.String toString()
Overrides:
toString in class antlr.BaseAST

substitute

public ExpressionInt substitute(java.util.Hashtable db)
Description copied from interface: ExpressionInt
Substitute the variable names in this expression (and its sub-components) present in the hashtable or database with the associated actual values. Similar to the R/S substitute() function.
Specified by:
substitute in interface ExpressionInt

substitute

public ExpressionInt substitute(java.util.Hashtable db,
                                boolean expand)

resolve

public ExpressionInt resolve(Evaluator evaluator)
Description copied from interface: ExpressionInt
Rewrite the expression by resolving class names, methods, etc. as much as possible based on the evaluation context provided by the Evaluator so as to make it more efficient in future calls..
Specified by:
resolve in interface ExpressionInt

apply

public java.lang.Object apply(Function f)
                       throws java.lang.Throwable

apply

public java.lang.Object apply(Function f,
                              Evaluator evaluator)
                       throws java.lang.Throwable

apply

public java.lang.Object apply(Function f,
                              Evaluator evaluator,
                              java.util.Vector result)
                       throws java.lang.Throwable

getReferencedVariables

public java.util.AbstractCollection getReferencedVariables()

getReferencedVariables

public java.util.AbstractCollection getReferencedVariables(boolean recursive)
Return a list of the different variables identified in the expression.

getReferencedVariables

public java.util.AbstractCollection getReferencedVariables(boolean recursive,
                                                           java.util.AbstractCollection container)

render

public java.lang.String render(boolean expanded)

comment

public Comment comment(int which)

comment

public Comment comment(int which,
                       Comment c)

addComment

public int addComment(Comment c,
                      int which)

preComment

public Comment preComment()

preComment

public Comment preComment(Comment c)

postComment

public Comment postComment()

postComment

public Comment postComment(Comment c)

showComments

public java.lang.String showComments(int which)

showComments

public java.lang.String showComments(int which,
                                     int max)

error

public java.lang.Exception error(java.lang.String msg,
                                 Evaluator evaluator)
Specified by:
error in interface ExpressionInt

subset

public java.lang.Object subset(java.lang.Object index,
                               boolean keepStructure)
                        throws java.lang.Throwable
Specified by:
subset in interface Subsettable