nixd
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Friends | List of all members
nixf::LexerCursor Class Reference

A point in the source file. More...

#include <Range.h>

Public Member Functions

 LexerCursor ()=default
 
 LexerCursor (const LexerCursor &)=default
 
LexerCursoroperator= (const LexerCursor &)=default
 
 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.
 
int64_t line () const
 Line number, starting from 0.
 
int64_t column () const
 Column number, starting from 0.
 
Position position () const
 Position in the source file. (Line + Column)
 
std::size_t offset () const
 Offset in the source file, starting from 0.
 

Static Public Member Functions

static LexerCursor unsafeCreate (int64_t Line, int64_t Column, std::size_t Offset)
 Create a cursor at the given position. (Line, Column, Offset)
 

Friends

class Lexer
 
bool operator== (const LexerCursor &LHS, const LexerCursor &RHS)
 

Detailed Description

A point in the source file.

This class is used to represent a point in the source file. And it shall be constructed by Lexer, to keep Line & Column information correct.

See also
Lexer::consume(std::size_t)

Definition at line 57 of file Range.h.

Constructor & Destructor Documentation

◆ LexerCursor() [1/3]

nixf::LexerCursor::LexerCursor ( )
default

◆ LexerCursor() [2/3]

nixf::LexerCursor::LexerCursor ( const LexerCursor & )
default

◆ LexerCursor() [3/3]

nixf::LexerCursor::LexerCursor ( LexerCursor && )
default

Member Function Documentation

◆ column()

int64_t nixf::LexerCursor::column ( ) const
inline

Column number, starting from 0.

Definition at line 96 of file Range.h.

Referenced by isAt().

◆ isAt()

bool nixf::LexerCursor::isAt ( int64_t Line,
int64_t Column,
std::size_t Offset ) const
inline

Check if the point is at the given position.

Definition at line 84 of file Range.h.

References column(), and line().

◆ line()

int64_t nixf::LexerCursor::line ( ) const
inline

Line number, starting from 0.

Currently we only accept LF as the line terminator.

Definition at line 93 of file Range.h.

Referenced by isAt().

◆ offset()

std::size_t nixf::LexerCursor::offset ( ) const
inline

Offset in the source file, starting from 0.

Definition at line 102 of file Range.h.

Referenced by nixf::Node::src(), and nixd::toLSPPosition().

◆ operator=()

LexerCursor & nixf::LexerCursor::operator= ( const LexerCursor & )
default

◆ position()

Position nixf::LexerCursor::position ( ) const
inline

Position in the source file. (Line + Column)

Definition at line 99 of file Range.h.

Referenced by nixf::LexerCursorRange::range().

◆ unsafeCreate()

static LexerCursor nixf::LexerCursor::unsafeCreate ( int64_t Line,
int64_t Column,
std::size_t Offset )
inlinestatic

Create a cursor at the given position. (Line, Column, Offset)

Note
This function does not guarantee the correctness of Line & Column.

Definition at line 74 of file Range.h.

Friends And Related Symbol Documentation

◆ Lexer

friend class Lexer
friend

Definition at line 61 of file Range.h.

◆ operator==

bool operator== ( const LexerCursor & LHS,
const LexerCursor & RHS )
friend

Definition at line 66 of file Range.h.


The documentation for this class was generated from the following file: