C# Class Antlr4.Runtime.Atn.LexerActionExecutor

Represents an executor for a sequence of lexer actions which traversed during the matching operation of a lexer rule (token).
Represents an executor for a sequence of lexer actions which traversed during the matching operation of a lexer rule (token).

The executor tracks position information for position-dependent lexer actions efficiently, ensuring that actions appearing only at the end of the rule do not cause bloating of the Antlr4.Runtime.Dfa.DFA created for the lexer.

Show file Open project: sharwell/antlr4cs Class Usage Examples

Private Properties

Property Type Description
Append Antlr4.Runtime.Atn.LexerActionExecutor

Public Methods

Method Description
Equals ( object obj ) : bool
Execute ( Lexer lexer, ICharStream input, int startIndex ) : void

Execute the actions encapsulated by this executor within the context of a particular Antlr4.Runtime.Lexer .

This method calls Antlr4.Runtime.IIntStream.Seek(int) to set the position of the input Antlr4.Runtime.ICharStream prior to calling ILexerAction.Execute(Antlr4.Runtime.Lexer) on a position-dependent action. Before the method returns, the input position will be restored to the same position it was in when the method was invoked.

FixOffsetBeforeMatch ( int offset ) : Antlr4.Runtime.Atn.LexerActionExecutor

Creates a LexerActionExecutor which encodes the current offset for position-dependent lexer actions.

Normally, when the executor encounters lexer actions where ILexerAction.IsPositionDependent() returns , it calls Antlr4.Runtime.IIntStream.Seek(int) on the input Antlr4.Runtime.ICharStream to set the input position to the end of the current token. This behavior provides for efficient DFA representation of lexer actions which appear at the end of a lexer rule, even when the lexer rule matches a variable number of characters.

Prior to traversing a match transition in the ATN, the current offset from the token start index is assigned to all position-dependent lexer actions which have not already been assigned a fixed offset. By storing the offsets relative to the token start index, the DFA representation of lexer actions which appear in the middle of tokens remains efficient due to sharing among tokens of the same length, regardless of their absolute position in the input stream.

If the current executor already has offsets assigned to all position-dependent lexer actions, the method returns this .

GetHashCode ( ) : int
LexerActionExecutor ( ILexerAction lexerActions ) : Antlr4.Runtime

Constructs an executor for a sequence of ILexerAction actions.

Private Methods

Method Description
Append ( Antlr4 lexerActionExecutor, ILexerAction lexerAction ) : Antlr4.Runtime.Atn.LexerActionExecutor

Method Details

Equals() public method

public Equals ( object obj ) : bool
obj object
return bool

Execute() public method

Execute the actions encapsulated by this executor within the context of a particular Antlr4.Runtime.Lexer .

This method calls Antlr4.Runtime.IIntStream.Seek(int) to set the position of the input Antlr4.Runtime.ICharStream prior to calling ILexerAction.Execute(Antlr4.Runtime.Lexer) on a position-dependent action. Before the method returns, the input position will be restored to the same position it was in when the method was invoked.

public Execute ( Lexer lexer, ICharStream input, int startIndex ) : void
lexer Lexer The lexer instance.
input ICharStream /// The input stream which is the source for the current token. /// When this method is called, the current /// /// for /// /// should be the start of the following token, i.e. 1 /// character past the end of the current token. ///
startIndex int /// The token start index. This value may be passed to /// /// to set the /// /// position to the beginning /// of the token. ///
return void

FixOffsetBeforeMatch() public method

Creates a LexerActionExecutor which encodes the current offset for position-dependent lexer actions.

Normally, when the executor encounters lexer actions where ILexerAction.IsPositionDependent() returns , it calls Antlr4.Runtime.IIntStream.Seek(int) on the input Antlr4.Runtime.ICharStream to set the input position to the end of the current token. This behavior provides for efficient DFA representation of lexer actions which appear at the end of a lexer rule, even when the lexer rule matches a variable number of characters.

Prior to traversing a match transition in the ATN, the current offset from the token start index is assigned to all position-dependent lexer actions which have not already been assigned a fixed offset. By storing the offsets relative to the token start index, the DFA representation of lexer actions which appear in the middle of tokens remains efficient due to sharing among tokens of the same length, regardless of their absolute position in the input stream.

If the current executor already has offsets assigned to all position-dependent lexer actions, the method returns this .

public FixOffsetBeforeMatch ( int offset ) : Antlr4.Runtime.Atn.LexerActionExecutor
offset int /// The current offset to assign to all position-dependent /// lexer actions which do not already have offsets assigned. ///
return Antlr4.Runtime.Atn.LexerActionExecutor

GetHashCode() public method

public GetHashCode ( ) : int
return int

LexerActionExecutor() public method

Constructs an executor for a sequence of ILexerAction actions.
public LexerActionExecutor ( ILexerAction lexerActions ) : Antlr4.Runtime
lexerActions ILexerAction The lexer actions to execute.
return Antlr4.Runtime