Esempio n. 1
0
 public BigDecimal getFirst() {
   if (this.type == Type.VALUE) {
     return this.value[0];
   } else {
     throw new IllegalStateException("Wrong type " + type.toString());
   }
 }
Esempio n. 2
0
 public boolean isLeftAssociative() {
   if (this.type == Type.OPERATOR) {
     if (this.operator == '^') return false;
     else return true;
   } else {
     throw new IllegalStateException("Wrong type " + type.toString());
   }
 }
Esempio n. 3
0
  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());
    }
  }