Interface LexicalAnalyzer

All Known Implementing Classes:
AntlrLexicalAnalyzer

@NotThreadSafe public interface LexicalAnalyzer
Lexical analyzer.

It is not meant to be thread-safe. Before using, make sure the lexer is reset.

  • Method Summary

    Modifier and Type
    Method
    Description
    default List<Token>
    analyze(String source)
    Analyze an entire source snapshot and return immutable tokens.
    default String[]
    Line comment opening and optional closing text, or null if unsupported.
    boolean
    Determines if a next token is available on the input at the current lexer position.
    Parse next token.
    void
    reset(char[] array, int offset, int length)
    Reset this lexical analyzer with new input.
  • Method Details

    • next

      Token next()
      Parse next token.
      Returns:
      next token, or Token.EOF if no token is available on the input
    • hasNext

      boolean hasNext()
      Determines if a next token is available on the input at the current lexer position.
      Returns:
      true if the lexer has a next token to be parsed
    • reset

      void reset(char[] array, int offset, int length)
      Reset this lexical analyzer with new input.
      Parameters:
      array - new program source code
      offset - the index of the first character to read
      length - length of how much to read
    • getLineCommentStartAndEnd

      default String[] getLineCommentStartAndEnd()
      Line comment opening and optional closing text, or null if unsupported.
    • analyze

      default List<Token> analyze(String source)
      Analyze an entire source snapshot and return immutable tokens. Implementations may mark declarations and include paths for source navigation.