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, ILineColumnFile 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, ILineColumnFile startingPos=null) | |
SourceFile (CharSource source, string fileName) | |
SourceFile (ICharSource source, ILineColumnFile startingPos=null) | |
SourceFile (ICharSource source, string fileName) | |
Public Member Functions inherited from Loyc.Syntax.IndexPositionMapper< CharSource > | |
IndexPositionMapper (CharSource source, ILineColumnFile startingPos=null) | |
Initializes CharIndexPositionMapper. More... | |
IndexPositionMapper (CharSource source, string fileName) | |
LineColumnFile | 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 (ILineAndColumn pos) |
IndexPositionMapper (IListSource< char > source, SourcePos startingPos=null) | |
IndexPositionMapper (IListSource< char > source, string fileName) | |
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.IHasFileName | |
string | FileName [get] |
Properties inherited from Loyc.Syntax.ISourceFile | |
ICharSource | Text [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, ILineColumnFile startingPos=null) |
LineColumnFile | 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 |
ILineColumnFile | _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
.