Class ParenthesisedExpressionReader

java.lang.Object
ch.andre601.expressionparser.parsers.ValueReader
ch.andre601.expressionparser.parsers.ParenthesisedExpressionReader

public class ParenthesisedExpressionReader extends ValueReader
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 Details

    • ParenthesisedExpressionReader

      public ParenthesisedExpressionReader(Token openingParenthesis, Token closingParenthesis)
      Sets the tokens 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 the token 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 a with the retrieved values.
      May return null if no opening parenthesis Token matching the set one is found.
      Specified by:
      read in class ValueReader
      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.