Enhanced C#
Language of your choice: library documentation
|
Adds the AfterNewline method to SourceFile. More...
Adds the AfterNewline method to SourceFile.
When implementing a lexer, the most efficient approach to building the list of line breaks is to save the location of each newline as it is encountered while lexing, rather than doing a separate pass over the file just to find line breaks. This class supports this optimization.
CharSource | : | ICharSource |
Public Member Functions | |
LexerSourceFile (CharSource source, SourcePos startingPos=null) | |
LexerSourceFile (CharSource source, string fileName) | |
void | AfterNewline (int index) |
Allows a lexer to record the index of the character after each line break, in the order they exist in the file or string. More... | |
Public Member Functions inherited from Loyc.Syntax.SourceFile< CharSource > | |
SourceFile (CharSource source, SourcePos startingPos=null) | |
SourceFile (CharSource source, string fileName) | |
Public Member Functions inherited from Loyc.Syntax.IndexPositionMapper< CharSource > | |
IndexPositionMapper (CharSource source, SourcePos startingPos=null) | |
Initializes CharIndexPositionMapper. More... | |
IndexPositionMapper (CharSource source, string fileName) | |
SourcePos | IndexToLine (int index) |
Returns the position in a source file of the specified index. More... | |
int | LineToIndex (int lineNo) |
Returns the index in a source file of the beginning of the specified line, where the first line is number 1, not 0. More... | |
int | LineToIndex (LineAndCol pos) |
Additional Inherited Members | |
Properties inherited from Loyc.Syntax.SourceFile< CharSource > | |
CharSource | Text [get] |
Properties inherited from Loyc.Syntax.IndexPositionMapper< CharSource > | |
string | FileName [get] |
int | LineCount [get] |
Properties inherited from Loyc.Syntax.ISourceFile | |
ICharSource | Text [get] |
string | FileName [get] |
Protected Member Functions inherited from Loyc.Syntax.IndexPositionMapper< CharSource > | |
void | Reset (CharSource source, string fileName) |
Reinitializes the object (as though the constructor were called again). More... | |
void | Reset (CharSource source, SourcePos startingPos=null) |
SourcePos | NewSourcePos (int Line, int PosInLine) |
void | ReadUntilAfter (int toIndex) |
bool | AdvanceAfterNextNewline (ref int index) |
Protected fields inherited from Loyc.Syntax.SourceFile< CharSource > | |
new CharSource | _source |
Protected fields inherited from Loyc.Syntax.IndexPositionMapper< CharSource > | |
CharSource | _source |
InternalList< int > | _lineOffsets = InternalList<int>.Empty |
bool | _offsetsComplete = false |
SourcePos | _startingPos = null |
|
inline |
Allows a lexer to record the index of the character after each line break, in the order they exist in the file or string.
index | Index of the first character after the newline. |
A lexer is not required to call this method; if the lexer doesn't call it, the list of line breaks (which is used to map indexes to line numbers and vice versa) will be built on-demand when one calls methods such as IndexToLine
.