private static void ValidateLocations(SourceLocation start, SourceLocation end) {
     if (start.IsValid && end.IsValid) {
         if (start > end) {
             throw new ArgumentException("Start and End must be well ordered");
         }
     } else {
         if (start.IsValid || end.IsValid) {
             throw new ArgumentException("Start and End must both be valid or both invalid");
         }
     }
 }
 public TokenInfo(JSToken tokenKind, SourceLocation start, SourceLocation end) {
     TokenKind = tokenKind;
     Start = start;
     End = end;
 }
 public LocationResolver(List<int> newLineLocations, SourceLocation initialLocation) {
     _newLineLocations = newLineLocations;
     _initialLocation = initialLocation;
 }
        /// <summary>
        /// Compares two specified location values.
        /// </summary>
        /// <param name="left">One location to compare.</param>
        /// <param name="right">The other location to compare.</param>
        /// <returns>0 if the locations are equal, -1 if the left one is less than the right one, 1 otherwise.</returns>
        public static int Compare(SourceLocation left, SourceLocation right)
        {
            if (left < right) return -1;
            if (left > right) return 1;

            return 0;
        }
 /// <summary>
 /// Constructs a new span with a specific start and end location.
 /// </summary>
 /// <param name="start">The beginning of the span.</param>
 /// <param name="end">The end of the span.</param>
 public SourceSpan(SourceLocation start, SourceLocation end) {
     ValidateLocations(start, end);
     this._start = start;
     this._end = end;
 }
Exemplo n.º 6
0
 /// <summary>
 /// Constructs a new span with a specific start and end location.
 /// </summary>
 /// <param name="start">The beginning of the span.</param>
 /// <param name="end">The end of the span.</param>
 public SourceSpan(SourceLocation start, SourceLocation end)
 {
     ValidateLocations(start, end);
     this._start = start;
     this._end   = end;
 }
Exemplo n.º 7
0
 public LocationResolver(List <int> newLineLocations, SourceLocation initialLocation)
 {
     _newLineLocations = newLineLocations;
     _initialLocation  = initialLocation;
 }