Class LLJavaLexer<D>

java.lang.Object
eu.bandm.tools.lljava.parser.LLJavaLexer<D>
Type Parameters:
D - the type of source document identifiers
All Implemented Interfaces:
Supplier<LLJavaLexer.Token<D>>

public class LLJavaLexer<D> extends Object implements Supplier<LLJavaLexer.Token<D>>
Hand-written Ramus-based lexer for LLJava.
  • Field Details

    • DEFAULT_FIRST_LINE

      public static final int DEFAULT_FIRST_LINE
      The default number of the first line in the input document.
      See Also:
    • DEFAULT_FIRST_COLUMN

      public static final int DEFAULT_FIRST_COLUMN
      The default number of the first column of each line in the input document.
      See Also:
  • Constructor Details

    • LLJavaLexer

      public LLJavaLexer(@Opt D documentId, Reader in)
      DOCUMENT ME
  • Method Details

    • setFirstLine

      public void setFirstLine(int firstLine)
      Sets the number of the first line in the input document.

      If this method is not invoked, the default value is DEFAULT_FIRST_LINE (1).

      To avoid inconsistencies, this method should only be invoked before the first token is produced.

      Parameters:
      firstLine - the number of the first line in the input document
    • setFirstColumn

      public void setFirstColumn(int firstColumn)
      Sets the number of the first column of each line in the input document.

      If this method is not invoked, the default value is DEFAULT_FIRST_COLUMN (1).

      To avoid inconsistencies, this method should only be invoked before the first token is produced.

      Parameters:
      firstColumn - the number of the first column of each line in the input document
    • get

      public LLJavaLexer.Token<D> get()
      Specified by:
      get in interface Supplier<D>
      Returns:
      the next token of this lexer
      Throws:
      UncheckedIOException - if the input cannot be read.
    • stream

      public Stream<LLJavaLexer.Token<D>> stream()
      Returns a sequential token stream with this lexer as its source.
      Returns:
      a sequential stream over the tokens produces by this lexer.
    • discard

      Returns a functional object that supplies the tokens of this lexer, except for those of the given types.
      Parameters:
      first - a token type to discard
      rest - an array of more token types to discard
      Returns:
      a functional object that supplies the tokens of this lexer, except for those of the given types.
      Throws:
      IllegalArgumentException - if LLJavaLexer.TokenType.EOF is specified to be discarded.
    • discard

      Returns a functional object that supplies the tokens of this lexer, except for the given types.
      Parameters:
      types - a set of token types to discard
      Returns:
      a functional object that supplies the tokens of this lexer, except for those of the given types.
      Throws:
      IllegalArgumentException - if LLJavaLexer.TokenType.EOF is specified to be discarded.
    • getKeywordType

      public static Optional<LLJavaLexer.TokenType> getKeywordType(String text)
      Returns the token type associated with a keyword if defined.
      Parameters:
      text - a string that may or may not be a keyword
      Returns:
      optionally the token type associated with the keyword, or Optional.empty() if undefined.