tenua.symbol
Class Symbol

java.lang.Object
  extended by tenua.symbol.Symbol
Direct Known Subclasses:
Assignment, Binary, Interpreted, Power, Unary, Value

public abstract class Symbol
extends java.lang.Object

Represents something (numbers, id's, operators) that can be part of an Expression

Author:
Daniel Wachsstock

Field Summary
static Symbol CLEAR_STACK
          a Symbol that clears the stack
static java.lang.Integer maxPrecedence
          the maximum precedence.
 
Method Summary
abstract  void eval(DoubleStack s, VariableMemento v)
          evaluate the Symbol
 void toString(java.util.Stack stringStack, java.util.Stack precedenceStack, SymbolTable st)
          pushes a StringBuffer that reflects this Symbol, with all its arguments
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

maxPrecedence

public static final java.lang.Integer maxPrecedence
the maximum precedence. Just Integer.MAX_VALUE


CLEAR_STACK

public static final Symbol CLEAR_STACK
a Symbol that clears the stack

Method Detail

eval

public abstract void eval(DoubleStack s,
                          VariableMemento v)
evaluate the Symbol

Parameters:
s - the stack from which to pop arguments and to which to push results
v - the memento representing the current values of variables. If v is null, then use the default values

toString

public void toString(java.util.Stack stringStack,
                     java.util.Stack precedenceStack,
                     SymbolTable st)
pushes a StringBuffer that reflects this Symbol, with all its arguments

Parameters:
stringStack - the stack of StringBuffer from which to pop arguments and to which to push results
precedenceStack - a stack to be push'ed and pop'ed in parallel with stringStack that contains Integers, corresponding to the precedence of the arguments onstringStack. This is used to determine placement of parentheses. Anything other than a binary operation should push maxPrecedence
st - the SymbolTable to get Symbol names from Note: the name is a misnomer; it uses StringBuffer's, not String's