Class CFScriptLexerCustom

java.lang.Object
org.antlr.v4.runtime.Recognizer<Integer,org.antlr.v4.runtime.atn.LexerATNSimulator>
org.antlr.v4.runtime.Lexer
ortus.boxlang.parser.antlr.CFScriptLexer
ortus.boxlang.compiler.parser.CFScriptLexerCustom
All Implemented Interfaces:
org.antlr.v4.runtime.TokenSource

public class CFScriptLexerCustom extends ortus.boxlang.parser.antlr.CFScriptLexer
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.CFScriptLexer

    _ATN, _decisionToDFA, _serializedATN, _sharedContextCache, ABSTRACT, AMPAMP, AMPERSAND, AND, ANY, ARRAY, ARROW, ARROW_RIGHT, AS, 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, ELSE, ELSEIF, 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, PREFIX, PREFIXEDIDENTIFIER, 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, TAG_COMMENT, TAG_COMMENT_END, TAG_COMMENT_START, TAG_COMMENT_TEXT, 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
    Constructor
    Description
    CFScriptLexerCustom(org.antlr.v4.runtime.CharStream input)
    Constructor
  • Method Summary

    Modifier and Type
    Method
    Description
    org.antlr.v4.runtime.Token
    Get the last token of a specific type
    org.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 stack
    boolean
    Check if there are unpopped modes on the Lexer's mode stack
    boolean
    lastModeWas(int mode)
    Check if the last mode was a specific mode
    org.antlr.v4.runtime.Token
    Supporting silly behavior of if( condition ) { } elseif( condition ) { } but it totally messed with the grammer to return a single elseif token so we're changing any elseif tokens to be two tokens.

    Methods inherited from class ortus.boxlang.parser.antlr.CFScriptLexer

    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, 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

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • CFScriptLexerCustom

      public CFScriptLexerCustom(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

      public List<String> 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
    • nextToken

      public org.antlr.v4.runtime.Token nextToken()
      Supporting silly behavior of if( condition ) { } elseif( condition ) { } but it totally messed with the grammer to return a single elseif token so we're changing any elseif tokens to be two tokens.
      Specified by:
      nextToken in interface org.antlr.v4.runtime.TokenSource
      Overrides:
      nextToken in class org.antlr.v4.runtime.Lexer
    • 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