Class ParenthesisedExpressionReader
java.lang.Object
ch.andre601.expressionparser.parsers.ValueReader
ch.andre601.expressionparser.parsers.ParenthesisedExpressionReader
ValueReader
converting a set of token into an ExpressionTemplate
if the first token is the same
as the first token provided and the follow-up tokens containing the second provided token.-
Constructor Summary
ConstructorDescriptionParenthesisedExpressionReader
(Token openingParenthesis, Token closingParenthesis) Sets thetokens
to look for when parsing. -
Method Summary
Modifier and TypeMethodDescriptionread
(ExpressionTemplateParser parser, List<Token> tokens, ParseWarnCollector collector) Takes the first Token from thetoken list
and checks, if it is the set opening parenthesis Token.
-
Constructor Details
-
ParenthesisedExpressionReader
Sets thetokens
to look for when parsing.- Parameters:
openingParenthesis
- First token to look for representing an opening parenthesis.closingParenthesis
- Second token to look for representing a closing parenthesis.
-
-
Method Details
-
read
public ExpressionTemplate read(ExpressionTemplateParser parser, List<Token> tokens, ParseWarnCollector collector) Takes the first Token from thetoken list
and checks, if it is the set opening parenthesis Token.
If true, iterates through the remaining Token list until a closing parenthesis Token matching the one set is found, or the end of the list is reached and returns awith the retrieved values
.
May return null if no opening parenthesis Token matching the set one is found.- Specified by:
read
in classValueReader
- Parameters:
parser
- ExpressionTemplateParser instance to use. The default ExpressionTemplateParser provides itself here.tokens
- List of tokens to parse into an ExpressionTemplate.collector
-ParseWarnCollector
instance to use.- Returns:
- Possibly null
ExpressionTemplate
.
-