tenua.symbol
Class Power

java.lang.Object
  extended by tenua.symbol.Symbol
      extended by tenua.symbol.Power

public class Power
extends Symbol

A Symbol that represents an integer power

Author:
Daniel Wachsstock

Field Summary
static Power FIVE
           
static Power FOUR
           
static Power ONE
           
static Power SEVEN
           
static Power SIX
           
static Power THREE
           
static Power TWO
           
static Power ZERO
           
 
Fields inherited from class tenua.symbol.Symbol
CLEAR_STACK, maxPrecedence
 
Method Summary
 void eval(DoubleStack s, VariableMemento v)
          evaluate the Symbol
static Power getInstance(int i)
           
 java.lang.String toString()
           
 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, wait, wait, wait
 

Field Detail

ZERO

public static final Power ZERO

ONE

public static final Power ONE

TWO

public static final Power TWO

THREE

public static final Power THREE

FOUR

public static final Power FOUR

FIVE

public static final Power FIVE

SIX

public static final Power SIX

SEVEN

public static final Power SEVEN
Method Detail

getInstance

public static Power getInstance(int i)

eval

public void eval(DoubleStack s,
                 VariableMemento v)
Description copied from class: Symbol
evaluate the Symbol

Specified by:
eval in class 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 java.lang.String toString()
Overrides:
toString in class java.lang.Object

toString

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

Overrides:
toString in class Symbol
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 Symbol.maxPrecedence
st - the SymbolTable to get Symbol names from Note: the name is a misnomer; it uses StringBuffer's, not String's