Lexer class abstract

Inheritance
Implemented types

Constructors

Lexer(CharStream input)

Properties

allTokens List<Token>
Return a list of all Token objects in input char stream. Forces load of all tokens. Does not include EOF token.
no setter
channel int
The channel number for the current token
getter/setter pair
channelNames List<String>?
no setter
charIndex int
What is the index of the current character of lookahead?
no setter
charPositionInLine int
Get the index into the current line for the current position in the input stream. The first character on a line has position 0.
getter/setter pairoverride-getter
errorListenerDispatch ErrorListener
no setterinherited
errorListeners List<ErrorListener>
no setterinherited
grammarFileName String
For debugging and other purposes, might want the grammar name. Have ANTLR generate an implementation for this method.
no setterinherited
hashCode int
The hash code for this object.
no setterinherited
inputStream CharStream
Set the char stream and reset the lexer
covariantgetter/setter pairoverride
interpreter LexerATNSimulator?
The ATN interpreter used by the recognizer for prediction.
getter/setter pairinherited
line int
Get the line number for the current position in the input stream. The first line in the input is line 1.
getter/setter pairoverride-getter
mode_ int
getter/setter pair
modeNames List<String>?
no setter
parseInfo ParseInfo?
If profiling during the parse/lex, this will return DecisionInfo records for each decision in recognizer in a ParseInfo object.
no setterinherited
ruleIndexMap Map<String, int>
Get a map from rule names to rule indexes.
no setterinherited
ruleNames List<String>
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
serializedATN List<int>
If this recognizer was generated, it will have a serialized ATN representation of the grammar.
no setterinherited
sourceName String
Gets the name of the underlying input source. This method returns a non-null, non-empty string. If such a name is not known, this method returns {@link IntStream#UNKNOWN_SOURCE_NAME}.
no setteroverride
state int
getter/setter pairinherited
text String
Return the text matched so far for the current token or any text override.
getter/setter pair
token Token?
Override if emitting multiple tokens.
no setter
tokenFactory TokenFactory<Token>
getter/setter pairoverride
tokenStartCharIndex int
What character index in the stream did the current token start at? Needed, for example, to get the text for current token. Set at the start of nextToken.
getter/setter pair
tokenStartCharPositionInLine int
The character position of first character within the line
getter/setter pair
tokenStartLine int
The line on which the first character of the token resides
getter/setter pair
tokenTypeMap Map<String, int>
Get a map from token names to token types.
no setterinherited
type int
The token type for the current token
getter/setter pair
vocabulary Vocabulary
Get the vocabulary used by the recognizer.
no setterinherited

Methods

action(RuleContext? _localctx, int ruleIndex, int actionIndex) → void
inherited
addErrorListener(ErrorListener listener) → void
inherited
emit() Token
The standard method called to automatically emit a token at the outermost lexical rule. The token object should point into the char buffer start..stop. If there is a text override in 'text', use that to set the token's text. Override this method to emit custom Token objects or provide a new factory.
emitEOF() Token
emitToken(Token token) → void
By default does not support multiple emits per nextToken invocation for efficiency reasons. Subclass and override this method, nextToken, and getToken (to push tokens into a list and pull from that list rather than a single variable as this implementation does).
getATN() ATN
Get the ATN used by the recognizer for prediction.
inherited
getCharErrorDisplay(int c) String
getErrorDisplay(String s) String
getErrorHeader(RecognitionException<IntStream> e) String
What is the error header, normally line/character position information? */
inherited
getTokenType(String tokenName) int
inherited
mode(int m) → void
more() → void
nextToken() Token
Return a token from this source; i.e., match a token on the char stream.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
notifyListeners(LexerNoViableAltException e) → void
popMode() int
precpred(RuleContext? localctx, int precedence) bool
inherited
pushMode(int m) → void
recover(RecognitionException<IntStream> re) → void
Lexers can normally match any char in it's vocabulary after matching a token, so do the easy thing and just kill a character and hope it all works out. You can instead use the rule invocation stack to do sophisticated error recovery if you are in a fragment rule.
removeErrorListener(ErrorListener listener) → void
inherited
removeErrorListeners() → void
inherited
reset([bool resetInput = false]) → void
sempred(RuleContext? _localctx, int ruleIndex, int actionIndex) bool
inherited
setToken(Token _token) → void
skip() → void
Instruct the lexer to skip creating a token for current lexer rule and look for another token. nextToken() knows to keep looking when a lexer rule finishes with token set to SKIP_TOKEN. Recall that if token==null at end of any token rule, it creates one for you and emits it.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Properties

DEFAULT_MODE int
final
DEFAULT_TOKEN_CHANNEL int
final
HIDDEN int
final
MAX_CHAR_VALUE int
final
MIN_CHAR_VALUE int
final
MORE int
final
SKIP int
final