Enhanced C#
Language of your choice: library documentation
Public Member Functions | List of all members
Loyc.Syntax.Lexing.LexerSourceFile< CharSource > Class Template Reference

Adds the AfterNewline method to SourceFile. More...


Source file:
Inheritance diagram for Loyc.Syntax.Lexing.LexerSourceFile< CharSource >:
Loyc.Syntax.SourceFile< CharSource > Loyc.Syntax.ISourceFile Loyc.Syntax.IndexPositionMapper< CharSource > Loyc.Syntax.ISourceFile Loyc.Syntax.IIndexPositionMapper Loyc.Syntax.IIndexPositionMapper Loyc.Syntax.IIndexPositionMapper Loyc.Syntax.IIndexToLine Loyc.Syntax.IIndexToLine Loyc.Syntax.IIndexToLine

Remarks

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.

Type Constraints
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)
 
 SourceFile (ICharSource source, SourcePos startingPos=null)
 
 SourceFile (ICharSource 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)
 
 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.IIndexToLine
string FileName [get]
 Gets the file name used in results returned by IndexToLine(int). More...
 
- 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, 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
 

Member Function Documentation

void Loyc.Syntax.Lexing.LexerSourceFile< CharSource >.AfterNewline ( int  index)
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.

Parameters
indexIndex 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.

Referenced by Loyc.Syntax.Lexing.BaseLexer< CharSrc >.AfterNewline().