public BigDecimal getFirst() { if (this.type == Type.VALUE) { return this.value[0]; } else { throw new IllegalStateException("Wrong type " + type.toString()); } }
public boolean isLeftAssociative() { if (this.type == Type.OPERATOR) { if (this.operator == '^') return false; else return true; } else { throw new IllegalStateException("Wrong type " + type.toString()); } }
public int getPrecedence() { if (this.type == Type.OPERATOR) { switch (this.operator) { case '^': return 3; case '*': case '/': return 2; case '+': case '-': return 1; default: return -1; } } else if (this.type == Type.FUNCTION) { return 4; } else { throw new IllegalStateException("Wrong type " + type.toString()); } }