Struct SourceLocation
Namespace: OceanApocalypse.RSML.Toolchain.Abstractions.Sources
Assembly: RSML.Toolchain.Abstractions.dll
Specifies the location of an item in a IBuffer or IScanner.
public readonly struct SourceLocation : IEquatable<SourceLocation>, IEquatable<Int32>, IFormattable, IComparable<SourceLocation>, IComparable<Int32>
Implements
IEquatable<SourceLocation>, IEquatable<Int32>, IFormattable, IComparable<SourceLocation>, IComparable<Int32>
Inherited Members
Object.Equals(Object?), Object.Equals(Object?, Object?), Object.GetHashCode(), Object.GetType(), Object.ReferenceEquals(Object?, Object?), Object.ToString()
Constructors
SourceLocation(Int32, Int32, Int32)
Specifies the location of an item in a IBuffer or IScanner.
public SourceLocation(Int32 index, Int32 line, Int32 column)
Parameters
index Int32
The 0-based index.
line Int32
The 0-based line number.
column Int32
The 0-based column number (the index relative to the start of the line).
Fields
Empty
An empty source location.
public static readonly SourceLocation Empty
Field Value
Properties
Column
The 0-based column number, which is the index of the item relative to the start of the line it is in.
public Int32 Column { get; }
Property Value
Index
The absolute 0-based index of the item in the source.
public Int32 Index { get; }
Property Value
Line
The 0-based line number, counting from the start of the source.
public Int32 Line { get; }
Property Value
Methods
CompareTo(Int32)
Compares the index of the location to another index.
public Int32 CompareTo(Int32 other)
Parameters
other Int32
The index to compare against.
Returns
CompareTo(SourceLocation)
Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object.
public Int32 CompareTo(SourceLocation other)
Parameters
other SourceLocation
An object to compare with this instance.
Returns
A value that indicates the relative order of the objects being compared. The return value has these meanings:
| Value | Meaning |
|---|---|
| Less than zero | This instance precedes `other` in the sort order. |
| Zero | This instance occurs in the same position in the sort order as `other`. |
| Greater than zero | This instance follows `other` in the sort order. |
Equals(Object?)
Indicates whether this instance and a specified object are equal.
public override Boolean Equals(Object? obj)
Parameters
obj Object?
The object to compare with the current instance.
Returns
true if obj and this instance are the same type and represent the same value; otherwise, false.
Equals(SourceLocation)
Checks if two SourceLocations are equal to each other.
public Boolean Equals(SourceLocation other)
Parameters
other SourceLocation
The other SourceLocation.
Returns
True if equals.
Equals(Int32)
Checks if two indexes are equal to each other.
public Boolean Equals(Int32 other)
Parameters
other Int32
The other location's index.
Returns
True if equals.
GetHashCode()
Returns the hash code for this instance.
public override Int32 GetHashCode()
Returns
A 32-bit signed integer that is the hash code for this instance.
ToString()
Returns a generic string representation of the current instance.
public override String ToString()
Returns
The string representation.
ToString(String?, IFormatProvider?)
Given a format, tries to return a string that uses said format as a basis for the representation.
If it fails, it defaults to ToString.
public String ToString(String? format, IFormatProvider? formatProvider)
Parameters
format String?
The format. Available formats are: CTOR (constructor-like string) and JSON (struct as JSON).
formatProvider IFormatProvider?
Unused. Don't bother assigning it anything.
Returns
The string representation.
Operators
operator ==(SourceLocation, SourceLocation)
Checks if two SourceLocations are equal to each other.
public static Boolean operator ==(SourceLocation left, SourceLocation right)
Parameters
left SourceLocation
right SourceLocation
Returns
True if equals.
operator >(SourceLocation, SourceLocation)
Checks if left is strictly greater than right.
public static Boolean operator >(SourceLocation left, SourceLocation right)
Parameters
left SourceLocation
right SourceLocation
Returns
operator >=(SourceLocation, SourceLocation)
Checks if left is greather than or equal to right.
public static Boolean operator >=(SourceLocation left, SourceLocation right)
Parameters
left SourceLocation
right SourceLocation
Returns
operator !=(SourceLocation, SourceLocation)
Checks if two SourceLocations are different from each other.
public static Boolean operator !=(SourceLocation left, SourceLocation right)
Parameters
left SourceLocation
right SourceLocation
Returns
True if different.
operator <(SourceLocation, SourceLocation)
Checks if left is strictly less than right.
public static Boolean operator <(SourceLocation left, SourceLocation right)
Parameters
left SourceLocation
right SourceLocation
Returns
operator <=(SourceLocation, SourceLocation)
Checks if left is less than or equal to right.
public static Boolean operator <=(SourceLocation left, SourceLocation right)
Parameters
left SourceLocation
right SourceLocation