public TextLocation ToTextLocation(ScanStream Lookup) { LineLocation found = null; // find the LineLocation on which the StreamIndex is located. foreach (var line in Lookup.Lines) { var loc = line.Location; if ((this.Value >= loc.StartIndex) && (this.Value <= loc.EndIndex)) { found = loc; break; } else if (loc.StartIndex > this.Value) { break; } } // location not found. if (found == null) { throw new ApplicationException("stream location " + this.Value.ToString() + " is not found."); } TextLocation textLoc = new TextLocation(found.LineId, this.Value - found.StartIndex); return(textLoc); }
public StreamLocation ToStreamLocation(ScanStream Lookup) { var lineLoc = Lookup.FindLineLocation(this.LineId); int ix = lineLoc.StartIndex + this.ColumnIndex; return(new StreamLocation(ix)); }