Package org.antlr.v4.runtime.atn
Class LexerTypeAction
java.lang.Object
org.antlr.v4.runtime.atn.LexerTypeAction
- All Implemented Interfaces:
LexerAction
Implements the
type
lexer action by calling Lexer.setType(int)
with the assigned type.- Since:
- 4.2
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionLexerTypeAction
(int type) Constructs a newtype
action with the specified token type value. -
Method Summary
Modifier and TypeMethodDescriptionboolean
void
Execute the lexer action in the context of the specifiedLexer
.Gets the serialization type of the lexer action.int
getType()
Gets the type to assign to a token created by the lexer.int
hashCode()
boolean
Gets whether the lexer action is position-dependent.toString()
-
Field Details
-
type
private final int type
-
-
Constructor Details
-
LexerTypeAction
public LexerTypeAction(int type) Constructs a newtype
action with the specified token type value.- Parameters:
type
- The type to assign to the token usingLexer.setType(int)
.
-
-
Method Details
-
getType
public int getType()Gets the type to assign to a token created by the lexer.- Returns:
- The type to assign to a token created by the lexer.
-
getActionType
Gets the serialization type of the lexer action.- Specified by:
getActionType
in interfaceLexerAction
- Returns:
- This method returns
LexerActionType.TYPE
.
-
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
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.setType(int)
with the value provided bygetType()
.- Specified by:
execute
in interfaceLexerAction
- Parameters:
lexer
- The lexer instance.
-
hashCode
public int hashCode() -
equals
-
toString
-