Class ExpressionParser
java.lang.Object
com.igormaznitsa.jcp.expression.ExpressionParser
This class is a parser allows to parse an expression and make a tree as the output
- Author:
- Igor Maznitsa (igor.maznitsa@igormaznitsa.com)
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumThe enumeration describes some special items which can be met in the expression -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ExpressionParserparse(String expressionStr, PreprocessorContext context) To parse an expression represented as a string and get a treereadExpression(PushbackReader reader, ExpressionTree tree, PreprocessorContext context, boolean insideBracket, boolean argument) It reads an expression from a reader and fill a tree
-
Constructor Details
-
ExpressionParser
public ExpressionParser()
-
-
Method Details
-
getInstance
-
parse
To parse an expression represented as a string and get a tree- Parameters:
expressionStr- the expression string to be parsed, must not be nullcontext- 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 nulltree- the result tree to be filled by read items, must not be nullcontext- a preprocessor context to be used for variablesinsideBracket- the flag shows that the expression can be ended by a bracketargument- 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
-