Class TokenReader

java.lang.Object
ch.andre601.expressionparser.tokens.readers.TokenReader
Direct Known Subclasses:
NonQuotedLiteralTokenReader, NumberTokenReader, PatternTokenReader, QuotedLiteralTokenReader

public abstract class TokenReader extends Object
The token reader is used to find specific patterns within a provided text to then turn into a Token, "tokenizing" the text over time.
  • Constructor Details

    • TokenReader

      public TokenReader(int priority)
      Constructor for creating a new TokenReader.
      Parameters:
      priority - The priority this TokenReader should have.
  • Method Details

    • getPriority

      public int getPriority()
      Priority of the TokenReader instance.
      Returns:
      Priority of the TokenReader instance.
    • read

      public abstract Token read(String text, ParsePosition position, ParseWarnCollector collector)
      Abstract method that is called by the ExpressionparserEngine to turn the provided String into a token.
      The provided ParsePosition instance indicates the current position within the String and should be updated accordingly when parsing the String to a Token.

      Assuming the DefaultExpressionParserEngine is used, returning null will result in skipping this TokenReader.

      Parameters:
      text - The text to parse.
      position - The current position within the text.
      collector - Instance of the ParseWarnCollector used for the parsing.
      Returns:
      Possibly-null Token instance.