public final class LexerIndexedCustomAction extends java.lang.Object implements LexerAction
LexerAction
is used for tracking input offsets
for position-dependent actions within a LexerActionExecutor
.
This action is not serialized as part of the ATN, and is only required for
position-dependent lexer actions which appear at a location other than the
end of a rule. For more information about DFA optimizations employed for
lexer actions, see LexerActionExecutor.append(org.antlr.v4.runtime.atn.LexerActionExecutor, org.antlr.v4.runtime.atn.LexerAction)
and
LexerActionExecutor.fixOffsetBeforeMatch(int)
.
Constructor and Description |
---|
LexerIndexedCustomAction(int offset,
LexerAction action)
Constructs a new indexed custom action by associating a character offset
with a
LexerAction . |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object obj) |
void |
execute(Lexer lexer)
Execute the lexer action in the context of the specified
Lexer . |
LexerAction |
getAction()
Gets the lexer action to execute.
|
LexerActionType |
getActionType()
Gets the serialization type of the lexer action.
|
int |
getOffset()
Gets the location in the input
CharStream at which the lexer
action should be executed. |
int |
hashCode() |
boolean |
isPositionDependent()
Gets whether the lexer action is position-dependent.
|
public LexerIndexedCustomAction(int offset, LexerAction action)
LexerAction
.
Note: This class is only required for lexer actions for which
LexerAction.isPositionDependent()
returns true
.
offset
- The offset into the input CharStream
, relative to
the token start index, at which the specified lexer action should be
executed.action
- The lexer action to execute at a particular offset in the
input CharStream
.public int getOffset()
CharStream
at which the lexer
action should be executed. The value is interpreted as an offset relative
to the token start index.CharStream
at which the lexer
action should be executed.public LexerAction getAction()
LexerAction
object which executes the lexer action.public LexerActionType getActionType()
getActionType
in interface LexerAction
getActionType()
on the LexerAction
returned by getAction()
.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
true
.public void execute(Lexer lexer)
Lexer
.
For position-dependent actions, the input stream must already be positioned correctly prior to calling this method.
This method calls execute(org.antlr.v4.runtime.Lexer)
on the result of getAction()
using the provided lexer
.
execute
in interface LexerAction
lexer
- The lexer instance.public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object