Esempio n. 1
0
  public String toString() {
    String tmp = new String();
    ArrayList<Expression> args;

    if (this.op == null) {
      if (this instanceof Variable) {
        tmp = ((Variable) this).getValue().toString();
        if (this.flag != null && this.flag.equals(Flag.UMINUS)) tmp = "-" + tmp;
      } else if (this instanceof FunctionCall) {
        tmp = ((FunctionCall) this).getTag() + "(";
        args = ((FunctionCall) this).getArgs();

        for (int i = args.size() - 1; i >= 0; i--) tmp = tmp + args.get(i).toString() + ",";
        tmp = tmp.substring(0, tmp.length() - 1) + ")";
      }
    } else {
      String l = this.left.toString();
      String r = this.right.toString();

      if (this.priority) tmp = "( " + l + " " + op.getString() + " " + r + " )";
      else tmp = l + " " + op.getString() + " " + r;

      if (this.flag != null && this.flag.equals(Flag.UMINUS)) tmp = "-( " + tmp + " )";
    }
    return tmp;
  }