private NumericExpression makeNumericExpression()

in api_dev/src/main/java/com/google/appengine/api/search/dev/ExpressionBuilder.java [356:413]


  private NumericExpression makeNumericExpression(Tree tree) {
    if (tree == null) {
      throw new IllegalArgumentException("Unexpected null node encountered");
    }

    switch (tree.getType()) {
      case ExpressionLexer.COUNT:
        return makeCountFieldsFunction(tree);
      case ExpressionLexer.ABS:
        return makeAbsoluteValueFunction(tree);
      case ExpressionLexer.DISTANCE:
        return makeDistanceFunction(tree);
      case ExpressionLexer.LOG:
        return makeLogFunction(tree);
      case ExpressionLexer.MAX:
        return makeMaxFunction(tree);
      case ExpressionLexer.MIN:
        return makeMinFunction(tree);
      case ExpressionLexer.SWITCH:
        throw new IllegalArgumentException("Function " + tree.getText() + " not yet implemented");
      case ExpressionLexer.GEOPOINT:
      case ExpressionLexer.SNIPPET:
        throw new IllegalArgumentException(
            "Function " + tree.getText() + " does not return numeric value");
      case ExpressionLexer.TIMES:
      case ExpressionLexer.DIV:
      case ExpressionLexer.PLUS:
      case ExpressionLexer.MINUS:
      case ExpressionLexer.POW:
      case ExpressionLexer.LT:
      case ExpressionLexer.GT:
      case ExpressionLexer.LE:
      case ExpressionLexer.EQ:
      case ExpressionLexer.NE:
      case ExpressionLexer.GE:
        return makeNumericBinaryExpression(tree);

      case ExpressionLexer.INT:
      case ExpressionLexer.FLOAT:
        return makeNumericValueExpression(tree);

      case ExpressionLexer.NEG:
        return new NegExpression(makeNumericExpression(tree.getChild(0)));

      case ExpressionLexer.NAME:
        if (SortExpression.SCORE_FIELD_NAME.equals(tree.getText())) {
          return new ScoreExpression();
        }
        FieldExpression e = FieldExpression.makeFieldExpression(
            tree.getText(), fieldTypes.get(tree.getText()));
        e.checkType(ContentType.NUMBER);
        return e;

      default:
         throw new IllegalArgumentException(
             "Not yet implemented or unexpected: " + getTokenName(tree.getType()));
    }
  }