Package eu.bandm.tools.lljava.parser
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>>
Hand-written Ramus-based lexer for LLJava.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Immutable LLJava tokens.static enum
Enumeration of LLJava token types. -
Field Summary
Modifier and TypeFieldDescriptionstatic final int
The default number of the first column of each line in the input document.static final int
The default number of the first line in the input document. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptiondiscard
(LLJavaLexer.TokenType first, LLJavaLexer.TokenType... rest) Returns a functional object that supplies the tokens of this lexer, except for those of the given types.discard
(Set<LLJavaLexer.TokenType> types) Returns a functional object that supplies the tokens of this lexer, except for the given types.get()
static Optional<LLJavaLexer.TokenType>
getKeywordType
(String text) Returns the token type associated with a keyword if defined.void
setFirstColumn
(int firstColumn) Sets the number of the first column of each line in the input document.void
setFirstLine
(int firstLine) Sets the number of the first line in the input document.stream()
Returns a sequential token stream with this lexer as its source.
-
Field Details
-
DEFAULT_FIRST_LINE
public static final int DEFAULT_FIRST_LINEThe default number of the first line in the input document.- See Also:
-
DEFAULT_FIRST_COLUMN
public static final int DEFAULT_FIRST_COLUMNThe default number of the first column of each line in the input document.- See Also:
-
-
Constructor Details
-
LLJavaLexer
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
- Specified by:
get
in interfaceSupplier<D>
- Returns:
- the next token of this lexer
- Throws:
UncheckedIOException
- if the input cannot be read.
-
stream
Returns a sequential token stream with this lexer as its source.- Returns:
- a sequential stream over the tokens produces by this lexer.
-
discard
public Supplier<LLJavaLexer.Token<D>> discard(LLJavaLexer.TokenType first, LLJavaLexer.TokenType... rest) Returns a functional object that supplies the tokens of this lexer, except for those of the given types.- Parameters:
first
- a token type to discardrest
- 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
- ifLLJavaLexer.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
- ifLLJavaLexer.TokenType.EOF
is specified to be discarded.
-
getKeywordType
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.
-