Language of your choice: library documentation
An wrapper around ISourceFile that applies line remapping information (if the source file uses it).
A preprocessor that supports #line may wrap the original ISourceFile in one of these, even when the source file doesn't use #line.
Call Remaps.AddRemap() and, optionally, Remaps.EndRemap(), to add each mapping.
ISourceFile includes IIndexPositionMapper which allows reverse-mapping from line/position back to index. However, a position derived from #line information may be ambiguous (does not always have a unique reverse mapping), and I'd rather avoid the work of reverse mapping anyway. So this class does not perform reverse mapping, but forward mappings return SourcePosAndIndex which are automatically recognized by LineToIndex which thereby recovers the original index.
|Properties inherited from Loyc.Syntax.ISourceFile|
|Properties inherited from Loyc.Syntax.IIndexToLine|
|Gets the file name used in results returned by IndexToLine(int). More...|
|SourceFileWithLineRemaps (ISourceFile original)|
|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)|
|SourcePos||IndexToLine (int index)|
|Returns the position in a source file of the specified index. More...|
|Public Member Functions inherited from Loyc.WrapperBase< ISourceFile >|
|override bool||Equals (object obj)|
|Returns true iff the parameter 'obj' is a wrapper around the same object that this object wraps. More...|
|override int||GetHashCode ()|
|Returns the hashcode of the wrapped object. More...|
|override string||ToString ()|
|Returns ToString() of the wrapped object. More...|
|Protected Member Functions inherited from Loyc.WrapperBase< ISourceFile >|
|WrapperBase (T wrappedObject)|
|Protected fields inherited from Loyc.WrapperBase< ISourceFile >|
|Protected static fields inherited from Loyc.WrapperBase< ISourceFile >|
|static readonly EqualityComparer< T >||TComp|
Returns the position in a source file of the specified index.
If index is negative, this should return a SourcePos where Line and PosInLine are zero (signifying an unknown location). If index is beyond the end of the file, this should retun the final position in the file.
Returns the index in a source file of the beginning of the specified line, where the first line is number 1, not 0.
If lineNo is zero, this method should return -1 (signifying an unknown location). If lineNo is larger than the largest line number, this method should return the index of end-of-file.