예제 #1
0
        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);
        }
예제 #2
0
        public StreamLocation ToStreamLocation(ScanStream Lookup)
        {
            var lineLoc = Lookup.FindLineLocation(this.LineId);
            int ix      = lineLoc.StartIndex + this.ColumnIndex;

            return(new StreamLocation(ix));
        }