protected void Reset(CharSource source, SourcePos startingPos = null) { _source = source; _lineOffsets = InternalList <int> .Empty; _lineOffsets.Add(0); _startingPos = startingPos; }
public override bool Equals(object obj) { SourcePos other = obj as SourcePos; if (other == null) { return(false); } return(other._fileName == _fileName && base.Equals(obj)); }
public SourcePos IndexToLine(int index) { SourcePos pos = _obj.IndexToLine(index); int line = pos.Line; string fn = pos.FileName; if (Remaps.Remap(ref line, ref fn)) { return(new SourcePosAndIndex(index, fn ?? FileName, line, pos.PosInLine)); } return(pos); }
public SourceFile(CharSource source, SourcePos startingPos = null) : base(source, startingPos) { _source = source; }
/// <summary>Initializes CharIndexPositionMapper.</summary> /// <param name="source">An immutable list of characters.</param> /// <param name="startingPos">Optional. The first character of <c>source</c> /// will be considered to have the file name and line number specified by /// this object. If this is null, IndexToLine() will return a blank file /// name ("").</param> public IndexPositionMapper(IListSource <char> source, SourcePos startingPos = null) { _source = source; _lineOffsets.Add(0); _startingPos = startingPos; }
/// <summary>Initializes CharIndexPositionMapper.</summary> /// <param name="source">An immutable list of characters.</param> /// <param name="startingPos">Optional. The first character of <c>source</c> /// will be considered to have the file name and line number specified by /// this object. If this is null, IndexToLine() will return a blank file /// name ("").</param> public IndexPositionMapper(CharSource source, SourcePos startingPos = null) { Reset(source, startingPos); }