Class ExpressionParser

java.lang.Object
com.igormaznitsa.jcp.expression.ExpressionParser

public final class ExpressionParser extends Object
This class is a parser allows to parse an expression and make a tree as the output
Author:
Igor Maznitsa (igor.maznitsa@igormaznitsa.com)
  • Constructor Details

    • ExpressionParser

      public ExpressionParser()
  • Method Details

    • getInstance

      public static ExpressionParser getInstance()
    • parse

      public ExpressionTree parse(String expressionStr, PreprocessorContext context) throws IOException
      To parse an expression represented as a string and get a tree
      Parameters:
      expressionStr - the expression string to be parsed, must not be null
      context - a preprocessor context to be used to get variable values
      Returns:
      a tree containing parsed expression
      Throws:
      IOException - it will be thrown if there is a problem to read the expression string
    • readExpression

      public ExpressionItem readExpression(PushbackReader reader, ExpressionTree tree, PreprocessorContext context, boolean insideBracket, boolean argument) throws IOException
      It reads an expression from a reader and fill a tree
      Parameters:
      reader - the reader to be used as the character source, must not be null
      tree - the result tree to be filled by read items, must not be null
      context - a preprocessor context to be used for variables
      insideBracket - the flag shows that the expression can be ended by a bracket
      argument - the flag shows that the expression can be ended by a comma
      Returns:
      the last read expression item (a comma or a bracket for instance), it can be null
      Throws:
      IOException - it will be thrown if there is a problem in reading from the reader