Package net.mitza.rel.parser.expression

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


    this();
    this.context = context;
  }

  public ExpressionNode parseCondition(String expression) {
    ExpressionNode logicalExpression = null;
    if (USE_CACHE) {
      logicalExpression = cache.get(expression);
    }

    if (logicalExpression == null) {
      Tokenizer tokenizer = Tokenizer.getExpressionTokenizer();
      tokenizer.tokenize(expression);
      LinkedList<Token> tokens = tokenizer.getTokens();
      logicalExpression = parseCondition(tokens);
      if (USE_CACHE) {
        cache.put(expression, logicalExpression);
      }
    } else {
      logicalExpression.accept(new SetContextVisitor(context));
    }

    return logicalExpression;
  }
View Full Code Here


  public ExpressionNode parseCondition(LinkedList<Token> tokens) {
    this.tokens = new LinkedList<Token>(tokens);
    lookahead = this.tokens.getFirst();

    ExpressionNode logicalExpression = logicalExpression();
    logicalExpression.accept(new SetContextVisitor(context));

    return logicalExpression;
  }
View Full Code Here

   *            the string holding the input
   * @return the internal representation of the expression in form of an expression tree made out of ExpressionNode
   *         objects
   */
  public ExpressionNode parseExpression(String expression) {
    ExpressionNode mathematicalExpression = null;
    if (USE_CACHE) {
      mathematicalExpression = cache.get(expression);
    }

    if (mathematicalExpression == null) {
      Tokenizer tokenizer = Tokenizer.getExpressionTokenizer();
      tokenizer.tokenize(expression);
      LinkedList<Token> tokens = tokenizer.getTokens();
      mathematicalExpression = parseExpression(tokens);
      if (USE_CACHE) {
        cache.put(expression, mathematicalExpression);
      }
    } else {
      mathematicalExpression.accept(new SetContextVisitor(context));
    }

    return mathematicalExpression;
  }
View Full Code Here

   */
  public ExpressionNode parseExpression(LinkedList<Token> tokens) {
    this.tokens = new LinkedList<Token>(tokens);
    lookahead = this.tokens.getFirst();

    ExpressionNode mathematicalExpression = mathematicalExpression();
    mathematicalExpression.accept(new SetContextVisitor(context));

    return mathematicalExpression;
  }
View Full Code Here

  // logical -> or_term or_op
  private ExpressionNode logicalExpression() {
    // only one rule
    // logical -> or_term or_op
    ExpressionNode expression = orTerm();
    expression = orOperation(expression);
    return expression;
  }
View Full Code Here

      } else {
        disjunction = new OrExpressionNode(expression);
      }

      nextToken();
      ExpressionNode term = orTerm();
      disjunction.add(term);

      return orOperation(disjunction);
    }
View Full Code Here

  }

  // or_term -> and_term and_op
  private ExpressionNode orTerm() {
    // or_term -> and_term and_op
    ExpressionNode term = andTerm();
    return andOperation(term);
  }
View Full Code Here

      } else {
        conjunction = new AndExpressionNode(expression);
      }

      nextToken();
      ExpressionNode term = andTerm();
      conjunction.add(term);

      return andOperation(conjunction);
    }
View Full Code Here

  // and_term -> NOT not_term
  private ExpressionNode andTerm() {
    // and_term -> NOT not_term
    if (lookahead.tokenType == TokenTypes.NOT) {
      nextToken();
      ExpressionNode term = notTerm();
      return new NotExpressionNode(term);
    }

    // and_term -> not_term
    return notTerm();
View Full Code Here

  // not_term -> proposition
  private ExpressionNode notTerm() {
    // not_term -> OPEN_PARENTHESIS logical CLOSE_PARENTHESIS
    if (lookahead.tokenType == TokenTypes.OPEN_PARENTHESIS) {
      nextToken();
      ExpressionNode logicalExpression = logicalExpression();
      if (lookahead.tokenType != TokenTypes.CLOSE_PARENTHESIS) {
        throw new ParserException("Closing parenthesis expected", lookahead);
      }
      nextToken();
      return logicalExpression;
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.