Package org.antlr.v4.runtime.atn
Class LexerChannelAction
- java.lang.Object
-
- org.antlr.v4.runtime.atn.LexerChannelAction
-
- All Implemented Interfaces:
LexerAction
public final class LexerChannelAction extends Object implements LexerAction
Implements thechannel
lexer action by callingLexer.setChannel(int)
with the assigned channel.- Since:
- 4.2
- Author:
- Sam Harwell
-
-
Constructor Summary
Constructors Constructor Description LexerChannelAction(int channel)
Constructs a newchannel
action with the specified channel value.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object obj)
void
execute(Lexer lexer)
Execute the lexer action in the context of the specifiedLexer
.LexerActionType
getActionType()
Gets the serialization type of the lexer action.int
getChannel()
Gets the channel to use for theToken
created by the lexer.int
hashCode()
boolean
isPositionDependent()
Gets whether the lexer action is position-dependent.String
toString()
-
-
-
Constructor Detail
-
LexerChannelAction
public LexerChannelAction(int channel)
Constructs a newchannel
action with the specified channel value.- Parameters:
channel
- The channel value to pass toLexer.setChannel(int)
.
-
-
Method Detail
-
getChannel
public int getChannel()
Gets the channel to use for theToken
created by the lexer.- Returns:
- The channel to use for the
Token
created by the lexer.
-
getActionType
public LexerActionType getActionType()
Gets the serialization type of the lexer action.- Specified by:
getActionType
in interfaceLexerAction
- Returns:
- This method returns
LexerActionType.CHANNEL
.
-
isPositionDependent
public 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
.- Specified by:
isPositionDependent
in interfaceLexerAction
- Returns:
- This method returns
false
.
-
execute
public void execute(Lexer lexer)
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.
This action is implemented by calling
Lexer.setChannel(int)
with the value provided bygetChannel()
.- Specified by:
execute
in interfaceLexerAction
- Parameters:
lexer
- The lexer instance.
-
-