Class LexerIndexedCustomAction

    • Constructor Detail

      • LexerIndexedCustomAction

        public LexerIndexedCustomAction​(int offset,
                                        LexerAction action)
        Constructs a new indexed custom action by associating a character offset with a LexerAction.

        Note: This class is only required for lexer actions for which LexerAction.isPositionDependent() returns true.

        offset - The offset into the input CharStream, relative to the token start index, at which the specified lexer action should be executed.
        action - The lexer action to execute at a particular offset in the input CharStream.
    • Method Detail

      • getOffset

        public int getOffset()
        Gets the location in the input CharStream at which the lexer action should be executed. The value is interpreted as an offset relative to the token start index.
        The location in the input CharStream at which the lexer action should be executed.
      • getAction

        public LexerAction getAction()
        Gets the lexer action to execute.
        A LexerAction object which executes the lexer action.
      • isPositionDependent

        public boolean isPositionDependent()
        Gets whether the lexer action is position-dependent. Position-dependent actions may have different semantics depending on the CharStream index at the time the action is executed.

        Many lexer commands, including type, skip, and more, do not check the input index during their execution. Actions like this are position-independent, and may be stored more efficiently as part of the LexerATNConfig.lexerActionExecutor.

        Specified by:
        isPositionDependent in interface LexerAction
        This method returns true.
      • execute

        public void execute​(Lexer lexer)
        Execute the lexer action in the context of the specified Lexer.

        For position-dependent actions, the input stream must already be positioned correctly prior to calling this method.

        This method calls execute(org.antlr.v4.runtime.Lexer) on the result of getAction() using the provided lexer.

        Specified by:
        execute in interface LexerAction
        lexer - The lexer instance.
      • hashCode

        public int hashCode()
        hashCode in class Object