Venice 0.751beta

nz.org.venice.parser.expression
Class ArithmeticExpression

java.lang.Object
  extended bynz.org.venice.parser.expression.AbstractExpression
      extended bynz.org.venice.parser.expression.BinaryExpression
          extended bynz.org.venice.parser.expression.ArithmeticExpression
All Implemented Interfaces:
java.lang.Cloneable, Expression
Direct Known Subclasses:
AddExpression, DivideExpression, MultiplyExpression, SubtractExpression

public abstract class ArithmeticExpression
extends BinaryExpression

Abstract base class for the arithmetic expressions: +, /, *, -


Field Summary
 
Fields inherited from interface nz.org.venice.parser.Expression
BOOLEAN_TYPE, FALSE, FLOAT_QUOTE_TYPE, FLOAT_TYPE, INTEGER_QUOTE_TYPE, INTEGER_SHORT_TYPE, INTEGER_TYPE, NUMERIC_TYPE, STRING_TYPE, TRUE, TRUE_LEVEL, UNDEFINED_TYPE
 
Constructor Summary
ArithmeticExpression(Expression left, Expression right)
          Create a new arithmetic expression with the given left and right arguments.
 
Method Summary
 int checkType()
          Check the input arguments to the expression.
 int getType()
          Get the type of the expression.
 Expression simplify()
          Perform simplifications and optimisations on the expression tree.
 
Methods inherited from class nz.org.venice.parser.expression.BinaryExpression
getChildCount, toString
 
Methods inherited from class nz.org.venice.parser.expression.AbstractExpression
clone, equals, getChild, getId, getIndex, getNumberFormat, getParent, getParseMetadata, hashCode, isRoot, iterator, parseDouble, parseInt, printParents, setChild, setChildMutableVersion, setParent, setParseMetadata, simplifyMutableVersion, size, size, toString, validTree, valueOfDouble, valueOfInt
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface nz.org.venice.parser.Expression
evaluate
 

Constructor Detail

ArithmeticExpression

public ArithmeticExpression(Expression left,
                            Expression right)
Create a new arithmetic expression with the given left and right arguments.

Method Detail

checkType

public int checkType()
              throws TypeMismatchException
Check the input arguments to the expression. They can only be Expression.INTEGER_TYPE or Expression.FLOAT_TYPE. * There are 4 possible cases: Expression.INTEGER_TYPE operator Expression.INTEGER_TYPE returns a Expression.INTEGER_TYPE Expression.INTEGER_TYPE operator Expression.FLOAT_TYPE returns a Expression.INTEGER_TYPE Expression.FLOAT_TYPE operator Expression.INTEGER_TYPE returns a Expression.FLOAT_TYPE Expression.FLOAT_TYPE operator Expression.FLOAT_TYPE returns a Expression.FLOAT_TYPE

Returns:
the type of the expression
Throws:
TypeMismatchException - if the expression has incorrect types

simplify

public Expression simplify()
Description copied from class: AbstractExpression
Perform simplifications and optimisations on the expression tree. For example, if the expression tree was a and true then the expression tree would be simplified to a.

Specified by:
simplify in interface Expression
Overrides:
simplify in class AbstractExpression

getType

public int getType()
Get the type of the expression.

Returns:
either Expression.FLOAT_TYPE or Expression.INTEGER_TYPE.

Venice 0.751beta