Top Description Methods
org.antlr.v4.runtime.atn

public Interface LexerAction

Known Direct Implementers
org.antlr.v4.runtime.atn.LexerChannelAction, org.antlr.v4.runtime.atn.LexerIndexedCustomAction, org.antlr.v4.runtime.atn.LexerModeAction, org.antlr.v4.runtime.atn.LexerMoreAction, org.antlr.v4.runtime.atn.LexerPopModeAction, org.antlr.v4.runtime.atn.LexerPushModeAction, org.antlr.v4.runtime.atn.LexerSkipAction, org.antlr.v4.runtime.atn.LexerTypeAction, org.antlr.v4.runtime.atn.LexerCustomAction
Imports
org.antlr.v4.runtime.CharStream, .Lexer

Represents a single action which can be executed following the successful match of a lexer rule. Lexer actions are used for both embedded action syntax and ANTLR 4's new lexer command syntax.
Author
Sam Harwell
Since
4.2

Method Summary

Modifier and TypeMethod and Description
public void
execute(Lexer
The lexer instance.
lexer
)

Execute the lexer action in the context of the specified Lexer.

public LexerActionType

Returns:

The serialization type of the lexer action.
getActionType
()

Gets the serialization type of the lexer action.

public boolean

Returns:

true if the lexer action semantics can be affected by the position of the input CharStream at the time it is executed; otherwise, false.
isPositionDependent
()

Gets whether the lexer action is position-dependent.

Method Detail

executeback to summary
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.

Parameters
lexer:Lexer

The lexer instance.

getActionTypeback to summary
public LexerActionType getActionType()

Gets the serialization type of the lexer action.

Returns:LexerActionType

The serialization type of the lexer action.

isPositionDependentback to summary
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.

Returns:boolean

true if the lexer action semantics can be affected by the position of the input CharStream at the time it is executed; otherwise, false.