public class LexerTypeAction extends Object implements LexerAction
type
lexer action by calling Lexer.setType(int)
with the assigned type.Constructor and Description |
---|
LexerTypeAction(int type)
Constructs a new
type action with the specified token type value. |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object obj) |
void |
execute(Lexer lexer)
Execute the lexer action in the context of the specified
Lexer . |
LexerActionType |
getActionType()
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 |
isPositionDependent()
Gets whether the lexer action is position-dependent.
|
String |
toString() |
public LexerTypeAction(int type)
type
action with the specified token type value.type
- The type to assign to the token using Lexer.setType(int)
.public int getType()
public LexerActionType getActionType()
getActionType
in interface LexerAction
LexerActionType.TYPE
.public boolean isPositionDependent()
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
.
isPositionDependent
in interface LexerAction
false
.public void execute(Lexer lexer)
Lexer
.
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 by getType()
.
execute
in interface LexerAction
lexer
- The lexer instance.Copyright © 1992–2021 ANTLR. All rights reserved.