Package org.apache.groovy.parser.antlr4
Class GroovyLangLexer
java.lang.Object
org.antlr.v4.runtime.Recognizer<Integer,org.antlr.v4.runtime.atn.LexerATNSimulator>
org.antlr.v4.runtime.Lexer
org.apache.groovy.parser.antlr4.AbstractLexer
org.apache.groovy.parser.antlr4.GroovyLexer
org.apache.groovy.parser.antlr4.GroovyLangLexer
- All Implemented Interfaces:
org.antlr.v4.runtime.TokenSource,SyntaxErrorReportable
The lexer for Groovy programming language, which is based on the lexer generated by Antlr4
-
Field Summary
Fields inherited from class org.apache.groovy.parser.antlr4.GroovyLexer
_ATN, _serializedATN, ABSTRACT, ADD, ADD_ASSIGN, AND, AND_ASSIGN, ARROW, AS, ASSERT, ASSIGN, ASYNC, AT, AWAIT, BITAND, BITNOT, BITOR, BooleanLiteral, BREAK, BuiltInPrimitiveType, CapitalizedIdentifier, CASE, CATCH, channelNames, CLASS, COLON, COMMA, CONST, CONTINUE, DEC, DEF, DEFAULT, DEFER, DIV, DIV_ASSIGN, DO, DOLLAR_SLASHY_GSTRING_MODE, DOT, DQ_GSTRING_MODE, ELLIPSIS, ELSE, ELVIS, ELVIS_ASSIGN, ENUM, EQUAL, EXTENDS, FINAL, FINALLY, FloatingPointLiteral, FOR, GE, GOTO, GSTRING_PATH_MODE, GSTRING_TYPE_SELECTOR_MODE, GStringBegin, GStringEnd, GStringPart, GStringPathPart, GT, IDENTICAL, Identifier, IF, IMPLEMENTS, IMPLIES, IMPORT, IN, INC, INSTANCEOF, IntegerLiteral, INTERFACE, LBRACE, LBRACK, LE, LPAREN, LSHIFT_ASSIGN, LT, METHOD_POINTER, METHOD_REFERENCE, MOD, MOD_ASSIGN, modeNames, MODULE, MUL, MUL_ASSIGN, NATIVE, NEW, NL, NON_SEALED, NOT, NOT_IDENTICAL, NOT_IN, NOT_INSTANCEOF, NOTEQUAL, NullLiteral, OR, OR_ASSIGN, PACKAGE, PERMITS, POWER, POWER_ASSIGN, PRIVATE, PROTECTED, PUBLIC, QUESTION, RANGE_EXCLUSIVE_FULL, RANGE_EXCLUSIVE_LEFT, RANGE_EXCLUSIVE_RIGHT, RANGE_INCLUSIVE, RBRACE, RBRACK, RECORD, REGEX_FIND, REGEX_MATCH, RETURN, RollBackOne, RPAREN, RSHIFT_ASSIGN, ruleNames, SAFE_CHAIN_DOT, SAFE_DOT, SAFE_INDEX, SEALED, SEMI, SH_COMMENT, SLASHY_GSTRING_MODE, SPACESHIP, SPREAD_DOT, STATIC, STRICTFP, StringLiteral, SUB, SUB_ASSIGN, SUPER, SWITCH, SYNCHRONIZED, TDQ_GSTRING_MODE, THIS, THREADSAFE, THROW, THROWS, tokenNames, TRAIT, TRANSIENT, TRY, UNEXPECTED_CHAR, URSHIFT_ASSIGN, VAL, VAR, VOCABULARY, VOID, VOLATILE, WHILE, WS, XOR, XOR_ASSIGN, YIELDFields inherited from class org.antlr.v4.runtime.Lexer
_channel, _factory, _hitEOF, _input, _mode, _modeStack, _text, _token, _tokenFactorySourcePair, _tokenStartCharIndex, _tokenStartCharPositionInLine, _tokenStartLine, _type, DEFAULT_MODE, DEFAULT_TOKEN_CHANNEL, HIDDEN, MAX_CHAR_VALUE, MIN_CHAR_VALUE, MORE, SKIPFields inherited from class org.antlr.v4.runtime.Recognizer
_interp, EOFFields inherited from interface org.apache.groovy.parser.antlr4.SyntaxErrorReportable
NO_OFFSET -
Constructor Summary
ConstructorsConstructorDescriptionGroovyLangLexer(Reader reader) GroovyLangLexer(org.antlr.v4.runtime.CharStream input) -
Method Summary
Modifier and TypeMethodDescriptionorg.antlr.v4.runtime.TokenReturns the next token, with a special case for EOF after a bare$in a GString.voidnotifyListeners(org.antlr.v4.runtime.LexerNoViableAltException e) Report a lexical error.voidrecover(org.antlr.v4.runtime.LexerNoViableAltException e) Abort lexing on the first lexical error.protected voidjust a hook, which will be overrided by GroovyLangLexerMethods inherited from class org.apache.groovy.parser.antlr4.GroovyLexer
action, emit, enterParenCallback, exitParenCallback, getChannelNames, getErrorColumn, getErrorLine, getGrammarFileName, getModeNames, getRuleNames, getSerializedATN, getSyntaxErrorSource, getTokenNames, getVocabulary, handleComment, isErrorIgnored, popMode, sempred, setErrorIgnoredMethods inherited from class org.antlr.v4.runtime.Lexer
emit, emitEOF, getAllTokens, getChannel, getCharErrorDisplay, getCharIndex, getCharPositionInLine, getErrorDisplay, getErrorDisplay, getInputStream, getLine, getSourceName, getText, getToken, getTokenFactory, getType, mode, more, pushMode, recover, reset, setChannel, setCharPositionInLine, setInputStream, setLine, setText, setToken, setTokenFactory, setType, skip, validateInputStreamMethods inherited from class org.antlr.v4.runtime.Recognizer
addErrorListener, getATN, getErrorHeader, getErrorListenerDispatch, getErrorListeners, getInterpreter, getParseInfo, getRuleIndexMap, getState, getTokenErrorDisplay, getTokenType, getTokenTypeMap, precpred, removeErrorListener, removeErrorListeners, setInterpreter, setStateMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.groovy.parser.antlr4.SyntaxErrorReportable
genPositionInfo, genPositionInfo, require, require, require, require, require, require, throwSyntaxError, throwSyntaxError
-
Constructor Details
-
GroovyLangLexer
- Throws:
IOException
-
GroovyLangLexer
public GroovyLangLexer(org.antlr.v4.runtime.CharStream input)
-
-
Method Details
-
nextToken
public org.antlr.v4.runtime.Token nextToken()Returns the next token, with a special case for EOF after a bare$in a GString.After
GStringBeginorGStringPartmatches a trailing$at the end of input, Antlr marks_hitEOFand would skipGroovyLexer.GSTRING_TYPE_SELECTOR_MODEentirely on the subsequent call. Detect that situation and report the dollar-body error instead of a generic unexpected-EOF parse failure.- Specified by:
nextTokenin interfaceorg.antlr.v4.runtime.TokenSource- Overrides:
nextTokenin classorg.antlr.v4.runtime.Lexer- Returns:
- the next token from the input
-
notifyListeners
public void notifyListeners(org.antlr.v4.runtime.LexerNoViableAltException e) Report a lexical error. When the failure is insideGroovyLexer.GSTRING_TYPE_SELECTOR_MODE(after a$in a GString), emit the dedicated dollar-body diagnostic instead of Antlr's generic token-recognition message.- Overrides:
notifyListenersin classorg.antlr.v4.runtime.Lexer- Parameters:
e- the recognition failure raised by the ATN simulator
-
recover
public void recover(org.antlr.v4.runtime.LexerNoViableAltException e) Abort lexing on the first lexical error. For an invalid character after$in a GString, throwGroovySyntaxErrorso the parser layer can surface a source-located syntax error without retrying SLL→LL or falling back to a generic exception message.- Overrides:
recoverin classorg.antlr.v4.runtime.Lexer- Parameters:
e- the recognition failure raised by the ATN simulator
-
rollbackOneChar
protected void rollbackOneChar()Description copied from class:GroovyLexerjust a hook, which will be overrided by GroovyLangLexer- Overrides:
rollbackOneCharin classGroovyLexer
-