edu.mit.ai.psg.jeva
Class LeftAssociativeOperatorExpression

java.lang.Object
  |
  +--edu.mit.ai.psg.jeva.SimpleNode
        |
        +--edu.mit.ai.psg.jeva.JevaNode
              |
              +--edu.mit.ai.psg.jeva.ExpressionNode
                    |
                    +--edu.mit.ai.psg.jeva.LeftAssociativeOperatorExpression
Direct Known Subclasses:
JNEAdditiveExpression, JNEAndExpression, JNEEqualityExpression, JNEExclusiveOrExpression, JNEInclusiveOrExpression, JNEMultiplicativeExpression, JNERelationalExpression, JNEShiftExpression

public abstract class LeftAssociativeOperatorExpression
extends ExpressionNode

Shared implementation for left associative operators.

Author:
CarlManning, caroma@ai.mit.edu
Copyright (c) 1997, 1998 Massachusetts Institute of Technology

Fields inherited from class edu.mit.ai.psg.jeva.SimpleNode
children, id, parent
 
Method Summary
abstract  Object binaryCombine(Token operator, Object accumResult, Object nextResult)
          binaryCombine -- combine two values, implemented in subclasses
abstract  IClass binaryCombineTypes(Token operator, IClass accumType, IClass nextType)
          binaryCombineTypes -- IClass of result of combining two types; implemented in subclasses
 boolean computeIsConstant(IEnv env)
           
 IClass computeType(IEnv env)
           
 Object eval(IEnv env)
           
 
Methods inherited from class edu.mit.ai.psg.jeva.ExpressionNode
getType, getType, getValue, isConstant
 
Methods inherited from class edu.mit.ai.psg.jeva.JevaNode
checkInsertionPoint, find2ndTokenBeforeEndBody, findChildIndex, findPrecedingToken, findTokenBeforeChild, findTokenBeforeChild, findTokenBeforeEnd, getBeginToken, getEndToken, insertChildTokens, insertNewChildAfter, insertNewChildAt, insertNewChildBefore, jjtAccept, jnGetChild, jnGetParent, print, print, printToken, printToString, printToString, removeChild, removeChildTokens, replaceChild, replaceChild, setBeginToken, setEndToken, updateEndTokens, updateEndTokensPriorChild, updateEndTokensPriorNode, updateEndTokensPriorNode
 
Methods inherited from class edu.mit.ai.psg.jeva.SimpleNode
dump, jjtAddChild, jjtClose, jjtGetChild, jjtGetNumChildren, jjtGetParent, jjtOpen, jjtSetParent, toString, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

computeType

public IClass computeType(IEnv env)
                   throws VerifyingException
Returns:
IClass of result returned by this operator on these arguments.
Throws:
IllegalTypeException - if types not acceptable
VerifyingException - if expression is illegal.
Overrides:
computeType in class ExpressionNode

binaryCombineTypes

public abstract IClass binaryCombineTypes(Token operator,
                                          IClass accumType,
                                          IClass nextType)
binaryCombineTypes -- IClass of result of combining two types; implemented in subclasses
Parameters:
operator - is the Token between expressions (e.g., +,-,*,/,...)
accumResult - is result of accumulating the expressions to the left of the operator.
nextResult - is result of evaluating the next expression to the right of the operator.
Returns:
IClass of result of the combining accumResult and nextResult with operator.
Throws:
IllegalArgumentException - if types not acceptable

computeIsConstant

public boolean computeIsConstant(IEnv env)
                          throws VerifyingException
Returns:
true if result of this expression is constant. Default is true if all subexpressions are constant, but subclasses may override this behavior.
Throws:
VerifyingException - if expression is illegal.
Overrides:
computeIsConstant in class ExpressionNode

eval

public Object eval(IEnv env)
            throws ThrowException
Returns:
evaluated children combined leftAssociatively, using binaryCombine()
Throws:
ThrowException - if completes abruptly with an exception
Overrides:
eval in class ExpressionNode

binaryCombine

public abstract Object binaryCombine(Token operator,
                                     Object accumResult,
                                     Object nextResult)
                              throws ThrowException
binaryCombine -- combine two values, implemented in subclasses
Parameters:
operator - is the Token between expressions (e.g., +,-,*,/,...)
accumResult - is result of accumulating the expressions to the left of the operator.
nextResult - is result of evaluating the next expression to the right of the operator.
Returns:
result of the combining accumResult and nextResult with operator
Throws:
ThrowException - wraps exception thrown by operator.

Copyright (c) 1996-1999
Massachusetts Institute of Technology

Feedback: jeva-bugs@ai.mit.edu