jsynoptic.parser
Class ExpressionNode
java.lang.Object
jsynoptic.parser.SimpleNode
jsynoptic.parser.ExpressionNode
- All Implemented Interfaces:
- java.lang.Cloneable, Node
- Direct Known Subclasses:
- NodeForAddition, NodeForBooleanTest, NodeForFunctionCall, NodeForLogicalOperation, NodeForMultiplication, NodeForNumber, NodeForPower, NodeForUnaryOperation
public abstract class ExpressionNode
- extends SimpleNode
- implements java.lang.Cloneable
This is the base class for all our nodes
It has an evaluate() function, which evaluates the subtree under this node and return a Number value
As a commodity to avoid duplicate code, it also has a function to return the list of variables used
at any place in the tree
Method Summary |
java.lang.Object |
clone()
|
abstract java.lang.Number |
evaluate()
Evaluate the subtree under this node and return the computation result as a number |
java.util.Set |
getVariables()
Return the list of variables used at any place in the tree. |
Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
ExpressionNode
public ExpressionNode(int i)
- From SimpleNode
- Parameters:
i
-
ExpressionNode
public ExpressionNode(ExpressionParser p,
int i)
- From SimpleNode
- Parameters:
p
- i
-
evaluate
public abstract java.lang.Number evaluate()
- Evaluate the subtree under this node and return the computation result as a number
getVariables
public java.util.Set getVariables()
- Return the list of variables used at any place in the tree.
- Returns:
- The vector of all variable used, of type VariableDefinition. The returned vector may be empty, but not null
clone
public java.lang.Object clone()
- Overrides:
clone
in class java.lang.Object