Class SourceSpan

java.lang.Object
com.maroontress.clione.SourceSpan

public final class SourceSpan extends Object
The representation of the contiguous range of the source file.

Note that the SourceSpan instance is an immutable object.

  • Constructor Details

    • SourceSpan

      public SourceSpan(SourceLocation start, SourceLocation end)
      Creates a new instance.
      Parameters:
      start - The start location of the range.
      end - The end location of the range.
    • SourceSpan

      public SourceSpan(SourceLocation where)
      Creates a new instance representing the single character.
      Parameters:
      where - The start and end location of the range.
    • SourceSpan

      public SourceSpan(SourceSpan first, SourceSpan last)
      Creates a new instance representing the range between the specified SourceSpans (that includes both of them).
      Parameters:
      first - The start span.
      last - The end span.
  • Method Details

    • getStart

      public SourceLocation getStart()
      Returns the start location of this range.
      Returns:
      The start location.
    • getEnd

      public SourceLocation getEnd()
      Returns the end location of this range.
      Returns:
      The end location.
    • toString

      public String toString()
      Returns a new string representation of this range that is easy for a person to read.

      This method returns a string equal to the value of either:

      • Ln1:xx--Ln2:xx
      • Ln1:m1--m2
      • Ln1:m1

      where n1, n2, m1, m2, and xx are positive integers, n1 < n2, m1 < m2, n1 and n2 represent the line number, and m1, m2, and xx represent the column number.

      Overrides:
      toString in class Object
      Returns:
      The new string representation of this token.