public final class ExpressionParser
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
private static class |
ExpressionParser.ParserState
The enumeration describes inside states of the parses
|
static class |
ExpressionParser.SpecialItem
The enumeration describes some special items which can be met in the
expression
|
Modifier and Type | Field and Description |
---|---|
private static ExpressionParser |
INSTANCE
It contains the instance for the parser, because the parser is a singletone
|
private static OperatorSUB |
OPERATOR_SUB
The constant has been added to avoid repeating operations
|
Constructor and Description |
---|
ExpressionParser() |
Modifier and Type | Method and Description |
---|---|
static ExpressionParser |
getInstance() |
private static boolean |
isDelimiter(char chr) |
private static boolean |
isDelimiterOrOperatorChar(char chr) |
private static boolean |
isOperatorChar(char chr) |
(package private) ExpressionItem |
nextItem(java.io.PushbackReader reader,
PreprocessorContext context)
Read the next item from the reader
|
ExpressionTree |
parse(java.lang.String expressionStr,
PreprocessorContext context)
To parse an expression represented as a string and get a tree
|
ExpressionItem |
readExpression(java.io.PushbackReader reader,
ExpressionTree tree,
PreprocessorContext context,
boolean insideBracket,
boolean argument)
It reads an expression from a reader and fill a tree
|
private ExpressionTree |
readFunction(AbstractFunction function,
java.io.PushbackReader reader,
PreprocessorContext context,
FilePositionInfo[] includeStack,
java.lang.String sources)
The auxiliary method allows to form a function and its arguments as a tree
|
(package private) ExpressionItem |
readFunctionArgument(java.io.PushbackReader reader,
ExpressionTree tree,
PreprocessorContext context,
FilePositionInfo[] callStack,
java.lang.String source)
The auxiliary method allows to read a function argument
|
private static final ExpressionParser INSTANCE
private static final OperatorSUB OPERATOR_SUB
public static ExpressionParser getInstance()
public ExpressionTree parse(java.lang.String expressionStr, PreprocessorContext context) throws java.io.IOException
expressionStr
- the expression string to be parsed, must not be nullcontext
- a preprocessor context to be used to get variable values, it
can be nulljava.io.IOException
- it will be thrown if there is a problem to read the
expression stringpublic ExpressionItem readExpression(java.io.PushbackReader reader, ExpressionTree tree, PreprocessorContext context, boolean insideBracket, boolean argument) throws java.io.IOException
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 variables, it can be
nullinsideBracket
- the flag shows that the expression can be ended by a
bracketargument
- the flag shows that the expression can be ended by a commajava.io.IOException
- it will be thrown if there is a problem in reading from
the readerprivate ExpressionTree readFunction(AbstractFunction function, java.io.PushbackReader reader, PreprocessorContext context, FilePositionInfo[] includeStack, java.lang.String sources) throws java.io.IOException
function
- the function which arguments will be read from the stream,
must not be nullreader
- the reader to be used as the character source, must not be
nullcontext
- a preprocessor context, it will be used for a user functions
and variables, it can be nullincludeStack
- the current file include stack, can be nullsources
- the current source line, can be nulljava.io.IOException
- it will be thrown if there is any problem to read charsExpressionItem readFunctionArgument(java.io.PushbackReader reader, ExpressionTree tree, PreprocessorContext context, FilePositionInfo[] callStack, java.lang.String source) throws java.io.IOException
reader
- a reader to be the character source, must not be nulltree
- the result tree to be filled by read items, must not be nullcontext
- a preprocessor context, it can be nullcallStack
- the current file call stack, can be nullsource
- the current source line, can be nulljava.io.IOException
- it will be thrown if there is any error during char
reading from the readerprivate static boolean isDelimiterOrOperatorChar(char chr)
private static boolean isDelimiter(char chr)
private static boolean isOperatorChar(char chr)
ExpressionItem nextItem(java.io.PushbackReader reader, PreprocessorContext context) throws java.io.IOException
reader
- a reader to be used as the char source, must not be nullcontext
- a preprocessor context, it can be nulljava.io.IOException
- it will be thrown if there is any error during a char
reading