Class CFLexerCustom

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

public class CFLexerCustom extends ortus.boxlang.parser.antlr.CFLexer
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
    Modifier and Type
    Field
    Description
    static boolean
     

    Fields inherited from class ortus.boxlang.parser.antlr.CFLexer

    _ATN, _decisionToDFA, _serializedATN, _sharedContextCache, ABSTRACT, AMPAMP, AMPERSAND, AND, ARROW, ARROW_RIGHT, AS, AT, ATTRIBUTE_NAME, BACKSLASH, BADC, BANG, BANGEQUAL, BITWISE_AND, BITWISE_COMPLEMENT, BITWISE_OR, BITWISE_SIGNED_LEFT_SHIFT, BITWISE_SIGNED_RIGHT_SHIFT, BITWISE_UNSIGNED_RIGHT_SHIFT, BITWISE_XOR, BREAK, CASE, CASTAS, CATCH, channelNames, CLOSE_QUOTE, CLOSE_SQUOTE, COLON, COLONCOLON, COMMA, COMMENT, COMMENT_END, COMMENT_START, COMMENT_TEXT, COMPONENT, COMPONENT_CLOSE, COMPONENT_CLOSE_EQUAL, COMPONENT_EQUALS, COMPONENT_ISLAND_END, COMPONENT_ISLAND_START, COMPONENT_NAME, COMPONENT_OPEN, COMPONENT_SLASH, COMPONENT_SLASH_CLOSE, COMPONENT_WHITESPACE, COMPONENT_WHITESPACE_OUTPUT, COMPONENT_WHITESPACE_OUTPUT2, COMPONENT_WHITESPACE_OUTPUT3, COMPONENT_WHITESPACE_OUTPUT4, componentIsland, CONCATEQUAL, CONTAIN, CONTAINS, CONTENT_TEXT, CONTENT_TEXT2, CONTINUE, DEFAULT, DEFAULT_SCRIPT_MODE, DEFAULT_TEMPLATE_MODE, DO, DOES, DOT, DOT_FLOAT_LITERAL, DOT_NUMBER_PREFIXED_IDENTIFIER, DUMMY, DUMMY2, DUMMY3, ELSE, ELSEIF, ELVIS, EQ, EQEQ, EQUAL, EQUALSIGN, EQV, expressionCountStack, FALSE, FINAL, FINALLY, FLOAT_LITERAL, FOR, FUNCTION, GE, GREATER, GT, GTE, GTESIGN, GTSIGN, HANY, HASHHASH, hashMode, ICHAR, IDENTIFIER, IF, ILLEGAL_IDENTIFIER, IMP, IMPORT, IN, INCLUDE, INSTANCEOF, INTEGER_LITERAL, INTERFACE, IS, isQuery, ISSCRIPT, ISTEMPLATE, JAVA, JAVADOC_COMMENT, LBRACE, LBRACKET, LE, LESS, LESSTHANGREATERTHAN, LINE_COMMENT, LPAREN, LT, LTE, LTESIGN, LTSIGN, MINUS, MINUSEQUAL, MINUSMINUS, MOD, modeNames, MODEQUAL, NEQ, NEW, NEWLINE, NOT, NULL, OPEN_QUOTE, OR, OUTPUT_END, OUTPUT_START, PACKAGE, PARAM, PERCENT, PIPE, PIPEPIPE, PLUS, PLUSEQUAL, PLUSPLUS, POWER, PREFIX, PREFIXEDIDENTIFIER, PRIVATE, PROPERTY, PUBLIC, QM, quotesMode, RBRACE, RBRACKET, REMOTE, REQUIRED, RETHROW, RETURN, RPAREN, ruleNames, SCRIPT_END_BODY, SCRIPT_OPEN, SEMICOLON, SHASHHASH, SLASH, SLASH_PREFIX, SLASHEQUAL, squotesMode, STAR, STAREQUAL, STATIC, STRING_LITERAL, SWITCH, TAG_COMMENT, TAG_COMMENT_END, TAG_COMMENT_START, TAG_COMMENT_TEXT, TEMPLATE_ARGUMENT, TEMPLATE_ATTVALUE, TEMPLATE_BREAK, TEMPLATE_CASE, TEMPLATE_CATCH, TEMPLATE_COMMENT_MODE, TEMPLATE_COMMENT_QUIET, TEMPLATE_COMPONENT, TEMPLATE_COMPONENT_MODE, TEMPLATE_COMPONENT_NAME_MODE, TEMPLATE_CONTINUE, TEMPLATE_DEFAULTCASE, TEMPLATE_ELSE, TEMPLATE_ELSEIF, TEMPLATE_END_COMPONENT, TEMPLATE_EXPRESSION_MODE_COMPONENT, TEMPLATE_FINALLY, TEMPLATE_FUNCTION, TEMPLATE_IF, TEMPLATE_IF2, TEMPLATE_IMPORT, TEMPLATE_INCLUDE, TEMPLATE_INTERFACE, TEMPLATE_OUTPUT_MODE, TEMPLATE_POSSIBLE_COMPONENT, TEMPLATE_PROPERTY, TEMPLATE_RETHROW, TEMPLATE_RETURN, TEMPLATE_SET, TEMPLATE_SWITCH, TEMPLATE_THROW, TEMPLATE_TRY, TEMPLATE_UNQUOTED_VALUE_MODE, TEMPLATE_WHILE, TEMPLATE_WS, TEMPLATE_XFSCRIPT, TENQ, TEQ, THAN, THROW, TO, tokenNames, TRUE, TRY, UNEXPECTED_EXPRESSION_END, UNQUOTED_VALUE_PART, VAR, 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
    CFLexerCustom(org.antlr.v4.runtime.CharStream input, int defaultMode, ErrorListener errorListener, CFParser parser)
    Constructor
  • Method Summary

    Modifier and Type
    Method
    Description
    org.antlr.v4.runtime.Token
    Get the last token of a specific type
    List<org.antlr.v4.runtime.Token>
    findPreviousTokenAndXSiblings(int type, int count)
    Get the last token of a specific type and the next x siblings Returns empty list if not found
    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
    Get the unpopped modes on the Lexer's mode stack
    boolean
    hasMode(int mode)
    Check if a specific mode is on the 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 grammar to return a single elseif token so we're changing any elseif tokens to be two tokens.
    void
     

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

    action, getATN, getBracketCount, getChannelNames, getGrammarFileName, getModeNames, getParenCount, getRuleNames, getSerializedATN, getTokenNames, getVocabulary, isTagEnd, isTagStart, lastModeWas, popMode, pushMode, 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, recover, recover, setChannel, setCharPositionInLine, setInputStream, setLine, setText, setToken, setTokenFactory, setType, skip

    Methods inherited from class org.antlr.v4.runtime.Recognizer

    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
  • Field Details

    • debug

      public static boolean debug
  • Constructor Details

    • CFLexerCustom

      public CFLexerCustom(org.antlr.v4.runtime.CharStream input, int defaultMode, ErrorListener errorListener, CFParser parser)
      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
    • getUnpoppedModesInts

      public List<Integer> getUnpoppedModesInts()
      Get the unpopped modes on the Lexer's mode stack
      Returns:
      list of 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 grammar 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
    • reset

      public void reset()
      Overrides:
      reset in class ortus.boxlang.parser.antlr.CFLexer
    • hasMode

      public boolean hasMode(int mode)
      Check if a specific mode is on the stack
      Parameters:
      mode - mode to check
      Returns:
      true if the mode is on the stack
    • findPreviousTokenAndXSiblings

      public List<org.antlr.v4.runtime.Token> findPreviousTokenAndXSiblings(int type, int count)
      Get the last token of a specific type and the next x siblings Returns empty list if not found
      Parameters:
      type - type of token to find
      count - number of siblings to find
      Returns:
      the list of tokens starting from the specified type