Struct SourcePos
Represents a (line, col) position in an input stream.
Implements
Inherited Members
- ValueType.ToString()
- object.GetType()
- object.Equals(object, object)
- object.ReferenceEquals(object, object)
Declaration
public readonly struct SourcePos : IEquatable<SourcePos>, IComparable<SourcePos>
Constructors
SourcePos(int, int)
Create a new SourcePos with the specified 1-indexed line and column number.
Declaration
public SourcePos(int line, int col)
Parameters
Type | Name | Description |
---|---|---|
line |
The 1-indexed line number. |
|
col |
The 1-indexed column number. |
Properties
Col
Gets the column of the position in the input stream The value is 1-indexed: a Col value of 1 refers to the first column of the line.
Declaration
public int Col { get; }
Property Value
Type | Description |
---|---|
The column. |
Line
Gets the line of the position in the input stream. The value is 1-indexed: a Line value of 1 refers to the first line of the input document.
Declaration
public int Line { get; }
Property Value
Type | Description |
---|---|
The line. |
Methods
Add(SourcePosDelta)
Add a SourcePosDelta to this SourcePos.
Declaration
public SourcePos Add(SourcePosDelta other)
Parameters
Type | Name | Description |
---|---|---|
other |
The SourcePosDelta to add to this SourcePos. |
Returns
Type | Description |
---|---|
A SourcePos representing the composition of this and |
CompareTo(SourcePos)
Represents a (line, col) position in an input stream.
Declaration
public int CompareTo(SourcePos other)
Parameters
Type | Name | Description |
---|---|---|
other |
Returns
Type | Description |
---|---|
Equals(SourcePos)
Represents a (line, col) position in an input stream.
Declaration
public bool Equals(SourcePos other)
Parameters
Type | Name | Description |
---|---|---|
other |
Returns
Type | Description |
---|---|
Equals(object?)
Represents a (line, col) position in an input stream.
Declaration
public override bool Equals(object? obj)
Parameters
Type | Name | Description |
---|---|---|
obj |
Returns
Type | Description |
---|---|
Overrides
GetHashCode()
Represents a (line, col) position in an input stream.
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
Overrides
IncrementCol()
Creates a SourcePos with the column number incremented by one.
Declaration
public SourcePos IncrementCol()
Returns
Type | Description |
---|---|
A SourcePos with the column number incremented by one. |
NewLine()
Creates a SourcePos with the line number incremented by one and the column number reset to 1.
Declaration
public SourcePos NewLine()
Returns
Type | Description |
---|---|
A SourcePos with the line number incremented by one and the column number reset to 1. |
Plus(SourcePosDelta)
Add a SourcePosDelta to this SourcePos.
Declaration
public SourcePos Plus(SourcePosDelta other)
Parameters
Type | Name | Description |
---|---|---|
other |
The SourcePosDelta to add to this SourcePos. |
Returns
Type | Description |
---|---|
A SourcePos representing the composition of this and |
Operators
operator +(SourcePos, SourcePosDelta)
Add a SourcePosDelta to this SourcePos.
Declaration
public static SourcePos operator +(SourcePos left, SourcePosDelta right)
Parameters
Type | Name | Description |
---|---|---|
left |
The SourcePos. |
|
right |
The SourcePosDelta to add to this SourcePos. |
Returns
Type | Description |
---|---|
A SourcePos representing the composition of |
operator ==(SourcePos, SourcePos)
Equality operator.
Declaration
public static bool operator ==(SourcePos left, SourcePos right)
Parameters
Type | Name | Description |
---|---|---|
left |
The left SourcePos. |
|
right |
The right SourcePos. |
Returns
Type | Description |
---|---|
operator >(SourcePos, SourcePos)
Comparison operator.
Declaration
public static bool operator >(SourcePos left, SourcePos right)
Parameters
Type | Name | Description |
---|---|---|
left |
The left SourcePos. |
|
right |
The right SourcePos. |
Returns
Type | Description |
---|---|
operator >=(SourcePos, SourcePos)
Comparison operator.
Declaration
public static bool operator >=(SourcePos left, SourcePos right)
Parameters
Type | Name | Description |
---|---|---|
left |
The left SourcePos. |
|
right |
The right SourcePos. |
Returns
Type | Description |
---|---|
operator !=(SourcePos, SourcePos)
Inequality operator.
Declaration
public static bool operator !=(SourcePos left, SourcePos right)
Parameters
Type | Name | Description |
---|---|---|
left |
The left SourcePos. |
|
right |
The right SourcePos. |
Returns
Type | Description |
---|---|
operator <(SourcePos, SourcePos)
Comparison operator.
Declaration
public static bool operator <(SourcePos left, SourcePos right)
Parameters
Type | Name | Description |
---|---|---|
left |
The left SourcePos. |
|
right |
The right SourcePos. |
Returns
Type | Description |
---|---|
operator <=(SourcePos, SourcePos)
Comparison operator.
Declaration
public static bool operator <=(SourcePos left, SourcePos right)
Parameters
Type | Name | Description |
---|---|---|
left |
The left SourcePos. |
|
right |
The right SourcePos. |
Returns
Type | Description |
---|---|