Package org.antlr.v4.runtime.atn
Interface LexerAction
- All Known Implementing Classes:
LexerChannelAction
,LexerCustomAction
,LexerIndexedCustomAction
,LexerModeAction
,LexerMoreAction
,LexerPopModeAction
,LexerPushModeAction
,LexerSkipAction
,LexerTypeAction
public interface LexerAction
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.
- Since:
- 4.2
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Execute the lexer action in the context of the specifiedLexer
.Gets the serialization type of the lexer action.boolean
Gets whether the lexer action is position-dependent.
-
Method Details
-
getActionType
LexerActionType getActionType()Gets the serialization type of the lexer action.- Returns:
- The serialization type of the lexer action.
-
isPositionDependent
boolean isPositionDependent()Gets whether the lexer action is position-dependent. Position-dependent actions may have different semantics depending on theCharStream
index at the time the action is executed.Many lexer commands, including
type
,skip
, andmore
, do not check the input index during their execution. Actions like this are position-independent, and may be stored more efficiently as part of theLexerATNConfig.lexerActionExecutor
.- Returns:
true
if the lexer action semantics can be affected by the position of the inputCharStream
at the time it is executed; otherwise,false
.
-
execute
Execute the lexer action in the context of the specifiedLexer
.For position-dependent actions, the input stream must already be positioned correctly prior to calling this method.
- Parameters:
lexer
- The lexer instance.
-