C# 클래스 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.

파일 보기 프로젝트 열기: sharwell/antlr4cs 1 사용 예제들

Private Properties

프로퍼티 타입 설명
Append Antlr4.Runtime.Atn.LexerActionExecutor

공개 메소드들

메소드 설명
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.

비공개 메소드들

메소드 설명
Append ( Antlr4 lexerActionExecutor, ILexerAction lexerAction ) : Antlr4.Runtime.Atn.LexerActionExecutor

메소드 상세

Equals() 공개 메소드

public Equals ( object obj ) : bool
obj object
리턴 bool

Execute() 공개 메소드

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. ///
리턴 void

FixOffsetBeforeMatch() 공개 메소드

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. ///
리턴 Antlr4.Runtime.Atn.LexerActionExecutor

GetHashCode() 공개 메소드

public GetHashCode ( ) : int
리턴 int

LexerActionExecutor() 공개 메소드

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