Package net.mitza.rel.parser.expression

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


  }

  // proposition -> expression comp_op
  private ExpressionNode logicalProposition() {
    // proposition -> expression comp_op
    ExpressionNode expression = mathematicalExpression();
    expression = comparisonOperation(expression);
    return expression;
  }
View Full Code Here


  private ExpressionNode comparisonOperation(ExpressionNode leftHand) {
    // comp_op -> COMPARATOR expression comp_op
    if (lookahead.tokenType == TokenTypes.COMPARATOR) {
      String operator = lookahead.sequence;
      nextToken();
      ExpressionNode rightHand = mathematicalExpression();
      return new ComparatorExpressionNode(leftHand, rightHand, operator);
    }

    // comp_op -> EPSILON
    return leftHand;
View Full Code Here

  // expression -> signed_term sum_op
  private ExpressionNode mathematicalExpression() {
    // only one rule
    // expression -> signed_term sum_op
    ExpressionNode signedTerm = signedTerm();
    signedTerm = sumOperation(signedTerm);
    return signedTerm;
  }
View Full Code Here

      }

      // reduce the input and recursively call sum_op
      boolean positive = lookahead.sequence.equals("+");
      nextToken();
      ExpressionNode term = term();
      sum.add(term, positive);

      return sumOperation(sum);
    }
View Full Code Here

  private ExpressionNode signedTerm() {
    // signed_term -> PLUSMINUS term
    if (lookahead.tokenType == TokenTypes.ADDITION) {
      boolean positive = lookahead.sequence.equals("+");
      nextToken();
      ExpressionNode term = term();
      if (positive) {
        return term;
      } else {
        return new AdditionExpressionNode(term, false);
      }
View Full Code Here

  }

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

      }

      // 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

      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

  // 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

  // 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

TOP

Related Classes of net.mitza.rel.parser.expression.ExpressionNode

Copyright © 2018 www.massapicom. 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.