14 Position(int64_t Line, int64_t Column) : Line(Line), Column(Column) {}
16 [[nodiscard]] int64_t
line()
const {
return Line; }
17 [[nodiscard]] int64_t
column()
const {
return Column; }
20 return LHS.Line == RHS.Line && LHS.Column == RHS.Column;
24 return LHS.Line < RHS.Line ||
25 (LHS.Line == RHS.Line && LHS.Column < RHS.Column);
29 return LHS < RHS || LHS == RHS;
48 return Begin <= Pos.Begin && Pos.End <= End;
62 LexerCursor(int64_t Line, int64_t Column, std::size_t Offset)
63 : Line(Line), Column(Column), Offset(Offset) {}
67 return LHS.Line == RHS.Line && LHS.Column == RHS.Column &&
68 LHS.Offset == RHS.Offset;
76 return {Line, Column, Offset};
84 [[nodiscard]]
bool isAt(int64_t Line, int64_t Column,
85 std::size_t Offset)
const {
86 return this->
line() == Line && this->
column() == Column &&
87 this->Offset == Offset;
93 [[nodiscard]] int64_t
line()
const {
return Line; }
96 [[nodiscard]] int64_t
column()
const {
return Column; }
102 [[nodiscard]] std::size_t
offset()
const {
return Offset; }
113 : LCur(LCur), RCur(RCur) {}
LexerCursorRange()=default
LexerCursorRange(LexerCursor Pos)
LexerCursorRange(LexerCursor LCur, LexerCursor RCur)
PositionRange range() const
bool contains(const LexerCursorRange &Pos) const
A point in the source file.
friend bool operator==(const LexerCursor &LHS, const LexerCursor &RHS)
int64_t column() const
Column number, starting from 0.
LexerCursor & operator=(const LexerCursor &)=default
std::size_t offset() const
Offset in the source file, starting from 0.
static LexerCursor unsafeCreate(int64_t Line, int64_t Column, std::size_t Offset)
Create a cursor at the given position. (Line, Column, Offset)
LexerCursor(LexerCursor &&)=default
bool isAt(int64_t Line, int64_t Column, std::size_t Offset) const
Check if the point is at the given position.
Position position() const
Position in the source file. (Line + Column)
int64_t line() const
Line number, starting from 0.
LexerCursor(const LexerCursor &)=default
bool contains(const PositionRange &Pos) const
Check if the range contains another range.
PositionRange(Position Begin, Position End)
PositionRange(Position Pos)
friend bool operator==(const Position &LHS, const Position &RHS)
friend bool operator<=(const Position &LHS, const Position &RHS)
friend bool operator<(const Position &LHS, const Position &RHS)
Position(int64_t Line, int64_t Column)