tenua.symbol
Class Binary
java.lang.Object
tenua.symbol.Symbol
tenua.symbol.Binary
public abstract class Binary
- extends Symbol
Symbol
subclass that represents a binary operator.
allows for precedence and associativity
Also exposes a large number of standard operators
- Author:
- Daniel Wachsstock
Method Summary |
abstract boolean |
leftAssociative()
the associativity of this operator |
abstract int |
precedence()
the precedence of this operator |
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 tenua.symbol.Symbol |
eval |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ADD
public static final Binary ADD
SUB
public static final Binary SUB
MUL
public static final Binary MUL
DIV
public static final Binary DIV
MOD
public static final Binary MOD
POW
public static final Binary POW
AND
public static final Binary AND
OR
public static final Binary OR
EQ
public static final Binary EQ
NE
public static final Binary NE
LE
public static final Binary LE
GE
public static final Binary GE
LT
public static final Binary LT
GT
public static final Binary GT
IF
public static final Binary IF
precedence
public abstract int precedence()
- the precedence of this operator
leftAssociative
public abstract boolean leftAssociative()
- the associativity of this operator
- Returns:
- true if it is left-associative,
false if right-associative
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 resultsprecedenceStack
- 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