Holds a filename (FileName), a line number (Line) and a position in the line (PosInLine), representing a position in a source code file.
Line and column numbering both start at one (1). Line=0 signifies nowhere in particular. Instances are immutable.
Inheritance: LineAndCol
Exemplo n.º 1
0
 protected void Reset(CharSource source, SourcePos startingPos = null)
 {
     _source      = source;
     _lineOffsets = InternalList <int> .Empty;
     _lineOffsets.Add(0);
     _startingPos = startingPos;
 }
Exemplo n.º 2
0
        public override bool Equals(object obj)
        {
            SourcePos other = obj as SourcePos;

            if (other == null)
            {
                return(false);
            }
            return(other._fileName == _fileName && base.Equals(obj));
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
 public SourceFile(CharSource source, SourcePos startingPos = null) : base(source, startingPos)
 {
     _source = source;
 }
Exemplo n.º 5
0
 /// <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;
 }
Exemplo n.º 6
0
 /// <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);
 }