tracer.expression
Class ExprNode

java.lang.Object
  |
  +--tracer.expression.ExprNode

public class ExprNode
extends java.lang.Object

A reduced expression node in an operator-precedence parsing tree.


Field Summary
 int etype
          Expression node type.
(package private) static int EXPNODE_BINFUNC
          An expression node containing two expression nodes and a binary function applicable on them.
(package private) static int EXPNODE_CONST
          An expression node containing a constant number.
(package private) static int EXPNODE_EMPTY
          An empty expression node.
(package private) static int EXPNODE_NODE
          An expression node containing a single expression node.
(package private) static int EXPNODE_UNARYFUNC
          An expression node containing an expression node and a unary function applicable on it.
(package private) static int EXPNODE_VAR
          An expression node containing a variable.
(package private)  Function func
          Function contained in the current expression node.
(package private)  double id
          Constant contained in the current expression node.
(package private)  ExprNode node1
          Expression node 1 contained in the current expression node.
(package private)  ExprNode node2
          Expression node 2 contained in the current expression node.
(package private)  int numNodes
           
(package private)  Variable variable
          Variable contained in the current expression node.
 
Constructor Summary
ExprNode()
          Create a default empty expression node.
 
Method Summary
 double eval()
          Evaluate the expression node.
 void push(double i)
          Pushes a const into the expression node.
 void push(ExprNode n)
          Pushes an expression node into the expression node.
 void push(Function f)
          Pushes a function into the expression node.
 void push(Symbol sym)
          Pushes a symbol into the expression node.
 void push(Variable v)
          Pushes a variable into the expression node.
 java.lang.String toString()
          Returns the string representation of the expression node.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

EXPNODE_EMPTY

static final int EXPNODE_EMPTY
An empty expression node.

EXPNODE_NODE

static final int EXPNODE_NODE
An expression node containing a single expression node.

EXPNODE_UNARYFUNC

static final int EXPNODE_UNARYFUNC
An expression node containing an expression node and a unary function applicable on it.

EXPNODE_BINFUNC

static final int EXPNODE_BINFUNC
An expression node containing two expression nodes and a binary function applicable on them.

EXPNODE_CONST

static final int EXPNODE_CONST
An expression node containing a constant number.

EXPNODE_VAR

static final int EXPNODE_VAR
An expression node containing a variable.

etype

public int etype
Expression node type.

numNodes

int numNodes

node1

ExprNode node1
Expression node 1 contained in the current expression node. It is valid when the type of current expression node is one of the following: EXPNODE_NODE, EXPNODE_UNARYFUNC and EXPNODE_BINFUNC.

node2

ExprNode node2
Expression node 2 contained in the current expression node. It is valid when the type of current expression node is EXPNODE_BINFUNC.

func

Function func
Function contained in the current expression node. It is valid when the type of current expression node is either one of the following: EXPNODE_UNARYFUNC and EXPNODE_BINFUNC.

id

double id
Constant contained in the current expression node. It is valid when the type of current expression node isEXPNODE_CONST.

variable

Variable variable
Variable contained in the current expression node. It is valid when the type of current expression node isEXPNODE_VAR.
Constructor Detail

ExprNode

public ExprNode()
Create a default empty expression node.
Method Detail

push

public void push(Symbol sym)
          throws ExpressionParseException
Pushes a symbol into the expression node. It will dispatch corresponding operation depending on the type of input symbol.

push

public void push(ExprNode n)
          throws ExpressionParseException
Pushes an expression node into the expression node.

push

public void push(Function f)
          throws ExpressionParseException
Pushes a function into the expression node.

push

public void push(double i)
          throws ExpressionParseException
Pushes a const into the expression node.

push

public void push(Variable v)
          throws ExpressionParseException
Pushes a variable into the expression node.

eval

public double eval()
            throws ExpressionEvalException
Evaluate the expression node.

toString

public java.lang.String toString()
Returns the string representation of the expression node.
Overrides:
toString in class java.lang.Object