Examples of ExpressionNode


Examples of net.mitza.rel.parser.expression.ExpressionNode

  }

  // term -> factor prod_op
  private ExpressionNode term() {
    // term -> factor prod_op
    ExpressionNode factor = factor();
    return prodOperation(factor);
  }
View Full Code Here

Examples of net.mitza.rel.parser.expression.ExpressionNode

      }

      // reduce the input and recursively call prod_op
      boolean positive = lookahead.sequence.equals("*");
      nextToken();
      ExpressionNode factor = factor();
      prod.add(factor, positive);

      return prodOperation(prod);
    }

View Full Code Here

Examples of net.mitza.rel.parser.expression.ExpressionNode

      int function = FunctionExpressionNode.stringToFunction(lookahead.sequence);
      if (function < 0) {
        throw new ParserException("Unexpected Function '%s' found", lookahead);
      }
      nextToken();
      ExpressionNode factor = factor();
      return new FunctionExpressionNode(function, factor);
    }

    // factor -> argument raise_op
    ExpressionNode argument = argument();
    return raiseOperation(argument);
  }
View Full Code Here

Examples of net.mitza.rel.parser.expression.ExpressionNode

  // raise_op -> EPSILON
  private ExpressionNode raiseOperation(ExpressionNode expression) {
    // raise_op -> RAISED argument
    if (lookahead.tokenType == TokenTypes.EXPONENTIATION) {
      nextToken();
      ExpressionNode exponent = argument();

      return new ExponentiationExpressionNode(expression, exponent);
    }

    // raise_op -> EPSILON
View Full Code Here

Examples of net.mitza.rel.parser.expression.ExpressionNode

  // argument -> OPEN_PARENTHESIS expression CLOSE_PARENTHESIS
  private ExpressionNode argument() {
    // argument -> OPEN_PARENTHESIS expression CLOSE_PARENTHESIS
    if (lookahead.tokenType == TokenTypes.OPEN_PARENTHESIS) {
      nextToken();
      ExpressionNode expression = mathematicalExpression();
      if (lookahead.tokenType != TokenTypes.CLOSE_PARENTHESIS) {
        throw new ParserException("Closing parentehesis expected", lookahead);
      }
      nextToken();
      return expression;
View Full Code Here

Examples of net.mitza.rel.parser.expression.ExpressionNode

  // value -> NUMBER
  // value -> VARIABLE
  private ExpressionNode value() {
    // value -> NUMBER
    if (lookahead.tokenType == TokenTypes.VALUE) {
      ExpressionNode constant = new ConstantExpressionNode(lookahead.sequence);
      nextToken();
      return constant;
    }

    // value -> VARIABLE
    if (lookahead.tokenType == TokenTypes.VARIABLE) {
      ExpressionNode variable = variable();
      return variable;
    }

    if (lookahead.tokenType == TokenTypes.EPSILON) {
      throw new ParserException("Unexpected end of input");
View Full Code Here

Examples of net.mitza.rel.parser.expression.ExpressionNode

    }

    // bean_op -> OPEN_BRACKET expression CLOSE_BRACKET bean_op
    if (lookahead.tokenType == TokenTypes.OPEN_BRACKET) {
      nextToken();
      ExpressionNode index = mathematicalExpression();
      bean.setIndex(index);
      if (lookahead.tokenType != TokenTypes.CLOSE_BRACKET) {
        throw new ParserException("Closing bracket expected", lookahead);
      }
      nextToken();
View Full Code Here

Examples of net.mitza.rel.parser.expression.ExpressionNode

    // ExpressionNode expr = parser.parseExpression("sin(pi/2)");
    // expr.accept(new SetVariable("pi", Math.PI));
    // System.out.println("The value of the expression is " + expr.getValue());

    long t = System.currentTimeMillis();
    ExpressionNode expr = null;
    for (int i = 0; i < 1000; i++) {
      expr = parser.parseCondition("2.8 + 0.1*2 == 3 && 22 > 21 + 0.5");
      expr.getBooleanValue();
      expr = parser.parseExpression("a['b'] + ' o\\'clock' + (1 + 2 * 3 - sin(3) / 2 + 2 ^ 3)");
      expr.getValue();
      expr = parser.parseCondition("2.8 + 0.1*2 == 3 && 22 > 21 + 0.6");
      expr.getBooleanValue();
      expr = parser.parseExpression("a['b'] + ' o\\'clock' + (1 + 2 * 3 - sin(3) / 2 + 2 ^ 4)");
      expr.getValue();
    }

    t = System.currentTimeMillis() - t;
    log.debug("Finish. Execution took " + (t / 1000.0) + "s");

View Full Code Here

Examples of net.mitza.rel.parser.expression.ExpressionNode

    if (expression == null) {
      return "";
    }

    Parser parser = new Parser(context);
    ExpressionNode expressionNode = parser.parseExpression(expression);
    return expressionNode.getValue();
  }
View Full Code Here

Examples of net.mitza.rel.parser.expression.ExpressionNode

    if (condition == null) {
      return false;
    }

    Parser parser = new Parser(context);
    ExpressionNode expressionNode = parser.parseCondition(condition);
    return expressionNode.getBooleanValue();
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.