Package ortus.boxlang.compiler.parser
Class BoxScriptLexerCustom
java.lang.Object
org.antlr.v4.runtime.Recognizer<Integer,org.antlr.v4.runtime.atn.LexerATNSimulator>
org.antlr.v4.runtime.Lexer
ortus.boxlang.parser.antlr.BoxScriptLexer
ortus.boxlang.compiler.parser.BoxScriptLexerCustom
- All Implemented Interfaces:
org.antlr.v4.runtime.TokenSource
public class BoxScriptLexerCustom
extends ortus.boxlang.parser.antlr.BoxScriptLexer
I extend the generated ANTLR lexer to add some custom methods for getting unpopped modes
so we can perform better validation after parsing.
-
Field Summary
Fields inherited from class ortus.boxlang.parser.antlr.BoxScriptLexer
_ATN, _decisionToDFA, _serializedATN, _sharedContextCache, ABSTRACT, AMPAMP, AMPERSAND, AND, ANY, ARRAY, ARROW, ARROW_RIGHT, AS, ASSERT, AT, BACKSLASH, BANG, BANGEQUAL, BITWISE_AND, BITWISE_COMPLEMENT, BITWISE_OR, BITWISE_SIGNED_LEFT_SHIFT, BITWISE_SIGNED_RIGHT_SHIFT, BITWISE_UNSIGNED_RIGHT_SHIFT, BITWISE_XOR, BOOLEAN, BREAK, CASE, CASTAS, CATCH, channelNames, CLASS_NAME, CLOSE_QUOTE, CLOSE_SQUOTE, COLON, COLONCOLON, COMMA, COMMENT, COMPONENT_ISLAND_BODY, COMPONENT_ISLAND_END, COMPONENT_ISLAND_START, componentIsland, CONCATEQUAL, CONTAIN, CONTAINS, CONTINUE, DEFAULT, DO, DOES, DOT, ELIF, ELSE, ELVIS, EQ, EQEQ, EQUAL, EQUALSIGN, EQV, FALSE, FINAL, FINALLY, FLOAT_LITERAL, FLOAT_LITERAL_DECIMAL_ONLY, FLOAT_LITERAL_DECIMAL_ONLY_E_NOTATION, FOR, FUNCTION, GE, GREATER, GT, GTE, GTESIGN, GTSIGN, HANY, HASHHASH, hashMode, ICHAR, IDENTIFIER, IF, IMP, IMPORT, IN, INCLUDE, INSTANCEOF, INTEGER_LITERAL, INTERFACE, IS, JAVA, JAVADOC_COMMENT, LBRACE, LBRACKET, LE, LESS, LESSTHANGREATERTHAN, LINE_COMMENT, LPAREN, LT, LTE, LTESIGN, LTSIGN, MESSAGE, MINUS, MINUSEQUAL, MINUSMINUS, MOD, modeNames, MODEQUAL, NEQ, NEW, NEWLINE, NOT, NULL, NUMERIC, OPEN_QUOTE, OR, PACKAGE, PARAM, PERCENT, PIPE, PIPEPIPE, PLUS, PLUSEQUAL, PLUSPLUS, POWER, PRIVATE, PROPERTY, PUBLIC, QM, QUERY, quotesMode, RBRACE, RBRACKET, REMOTE, REQUEST, REQUIRED, RETHROW, RETURN, RPAREN, ruleNames, SEMICOLON, SERVER, SETTING, SHASHHASH, SLASH, SLASHEQUAL, squotesMode, STAR, STAREQUAL, STATIC, STRING, STRING_LITERAL, STRUCT, SWITCH, TEQ, THAN, THROW, TO, tokenNames, TRUE, TRY, TYPE, VAR, VARIABLES, VOCABULARY, WHEN, WHILE, WS, XOR
Fields 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, SKIP
Fields inherited from class org.antlr.v4.runtime.Recognizer
_interp, EOF
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.antlr.v4.runtime.Token
findPreviousToken
(int type) Get the last token of a specific typeorg.antlr.v4.runtime.Token
findUnclosedToken
(int start, int end) Back up to the closest unclosed brace Return null if none found *Get the unpopped modes on the Lexer's mode stackboolean
Check if there are unpopped modes on the Lexer's mode stackboolean
lastModeWas
(int mode) Check if the last mode was a specific modeMethods inherited from class ortus.boxlang.parser.antlr.BoxScriptLexer
getATN, getChannelNames, getGrammarFileName, getModeNames, getRuleNames, getSerializedATN, getTokenNames, getVocabulary, sempred
Methods inherited from class org.antlr.v4.runtime.Lexer
emit, emit, emitEOF, getAllTokens, getChannel, getCharErrorDisplay, getCharIndex, getCharPositionInLine, getErrorDisplay, getErrorDisplay, getInputStream, getLine, getSourceName, getText, getToken, getTokenFactory, getType, mode, more, nextToken, notifyListeners, popMode, pushMode, recover, recover, reset, setChannel, setCharPositionInLine, setInputStream, setLine, setText, setToken, setTokenFactory, setType, skip
Methods inherited from class org.antlr.v4.runtime.Recognizer
action, addErrorListener, getErrorHeader, getErrorListenerDispatch, getErrorListeners, getInterpreter, getParseInfo, getRuleIndexMap, getState, getTokenErrorDisplay, getTokenType, getTokenTypeMap, precpred, removeErrorListener, removeErrorListeners, setInterpreter, setState
-
Constructor Details
-
BoxScriptLexerCustom
public BoxScriptLexerCustom(org.antlr.v4.runtime.CharStream input) Constructor- Parameters:
input
- input stream
-
-
Method Details
-
hasUnpoppedModes
public boolean hasUnpoppedModes()Check if there are unpopped modes on the Lexer's mode stack- Returns:
- true if there are unpopped modes
-
getUnpoppedModes
Get the unpopped modes on the Lexer's mode stack- Returns:
- list of unpopped modes
-
lastModeWas
public boolean lastModeWas(int mode) Check if the last mode was a specific mode- Parameters:
mode
- mode to check- Returns:
- true if the last mode was the specified mode
-
findPreviousToken
public org.antlr.v4.runtime.Token findPreviousToken(int type) Get the last token of a specific type- Parameters:
type
- type of token to find- Returns:
- the last token of the specified type
-
findUnclosedToken
public org.antlr.v4.runtime.Token findUnclosedToken(int start, int end) Back up to the closest unclosed brace Return null if none found *- Returns:
- the unmatched opening brace
-