Struct ParsePosition
Denotes a position of a parser
public record struct ParsePosition : IComparable<ParsePosition>, IEquatable<ParsePosition>
- Implements
- Inherited Members
Constructors
ParsePosition(int, int)
Denotes a position of a parser
public ParsePosition(int Line, int Col)
Parameters
Properties
Col
The column of the position
public int Col { readonly get; set; }
Property Value
Line
The line of the position
public int Line { readonly get; set; }
Property Value
Methods
CompareTo(ParsePosition)
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 int CompareTo(ParsePosition other)
Parameters
other
ParsePositionAn object to compare with this instance.
Returns
- int
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.
Proceed(int)
Proceeds the position by the given number of characters
public ParsePosition Proceed(int chars)
Parameters
chars
intthe numbers of characters to proceed
Returns
- ParsePosition
The updated parser position
Operators
operator +(ParsePosition, ParsePositionDelta)
Adds the given delta to the current position
public static ParsePosition operator +(ParsePosition pos, ParsePositionDelta delta)
Parameters
pos
ParsePositionthe origin position
delta
ParsePositionDeltathe position delta
Returns
- ParsePosition
the updated position
operator >(ParsePosition, ParsePosition)
Decides which of the two positions is greater
public static bool operator >(ParsePosition pos1, ParsePosition pos2)
Parameters
pos1
ParsePositionthe first position
pos2
ParsePositionthe second position
Returns
- bool
true, if the first position is greater, otherwise false
operator >=(ParsePosition, ParsePosition)
Decides which of the two positions is greater or equal
public static bool operator >=(ParsePosition pos1, ParsePosition pos2)
Parameters
pos1
ParsePositionthe first position
pos2
ParsePositionthe second position
Returns
- bool
true, if the first position is greater or equal, otherwise false
operator <(ParsePosition, ParsePosition)
Decides which of the two positions is smaller
public static bool operator <(ParsePosition pos1, ParsePosition pos2)
Parameters
pos1
ParsePositionthe first position
pos2
ParsePositionthe second position
Returns
- bool
true, if the first position is smaller, otherwise false
operator <=(ParsePosition, ParsePosition)
Decides which of the two positions is smaller or equal
public static bool operator <=(ParsePosition pos1, ParsePosition pos2)
Parameters
pos1
ParsePositionthe first position
pos2
ParsePositionthe second position
Returns
- bool
true, if the first position is smaller or equal, otherwise false
operator -(ParsePosition, ParsePosition)
Subtracts two parse positions
public static ParsePositionDelta operator -(ParsePosition to, ParsePosition from)
Parameters
to
ParsePositionthe forward position
from
ParsePositionthe backward position
Returns
- ParsePositionDelta
The delta between the given positions