Class ELParser
The parser is a recursive descent implementation of the grammar, with the operator precedence described in the section 1.16 of the specification.
- Since:
- 1.0
- Author:
- Denis Stepanov
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe nesting depth an expression may reach by default. -
Method Summary
Modifier and TypeMethodDescriptionstatic ELNodeParses an expression, which can be a literal-expression, an eval-expression or a composite expression, nested at mostDEFAULT_MAX_DEPTHlevels deep.static ELNodeParses an expression, which can be a literal-expression, an eval-expression or a composite expression.static ELNodeParses an expression that must consist of a single eval-expression, as required for a method expression by the section 1.2.3 of the specification.static ELNodeParses an expression that must consist of a single eval-expression, as required for a method expression by the section 1.2.3 of the specification.
-
Field Details
-
DEFAULT_MAX_DEPTH
public static final int DEFAULT_MAX_DEPTHThe nesting depth an expression may reach by default.The parser is a recursive descent implementation and the tree it produces is walked recursively by every consumer, so an expression nested beyond the depth of the call stack would fail with a
StackOverflowErrorrather than with an exception of the specification. An expression string built at runtime therefore has to be bounded, and no expression a person writes comes close to this limit.A parenthesised sub-expression is the level that costs the most stack, around fifteen frames of the recursive descent, so this default holds on a thread whose stack is half of the usual one. Parse with
parse(String, int)to raise it for expressions generated by a tool.- See Also:
-
-
Method Details
-
parse
Parses an expression, which can be a literal-expression, an eval-expression or a composite expression, nested at mostDEFAULT_MAX_DEPTHlevels deep.- Parameters:
expression- The expression- Returns:
- The parsed expression
-
parse
Parses an expression, which can be a literal-expression, an eval-expression or a composite expression.- Parameters:
expression- The expressionmaxDepth- The nesting depth the expression may reach, beyond which it is rejected- Returns:
- The parsed expression
-
parseEval
-
parseEval
Parses an expression that must consist of a single eval-expression, as required for a method expression by the section 1.2.3 of the specification.- Parameters:
expression- The expressionmaxDepth- The nesting depth the expression may reach, beyond which it is rejected- Returns:
- The parsed expression
-