Yume
Public Member Functions | Public Attributes | List of all members
yume::Loc Struct Reference

Represents a location in source code, as a range starting at a line and column and ending at some other line and column of some file. More...

#include <token.hpp>

Collaboration diagram for yume::Loc:
Collaboration graph
[legend]

Public Member Functions

constexpr auto operator<=> (const Loc &other) const noexcept=default
 
constexpr auto operator+ (const Loc &other) const noexcept -> Loc
 Create a new location representing the "union" of two locations. More...
 
auto to_string () const -> string
 
auto valid () const -> bool
 
auto single () const -> Loc
 Return a new Loc which refers to the first character of the current Loc. More...
 

Public Attributes

int begin_line
 
int begin_col
 
int end_line
 
int end_col
 
const char * file
 

Detailed Description

Represents a location in source code, as a range starting at a line and column and ending at some other line and column of some file.

Lines are 1-indexed, meaning a line number of 0 as either the beginning or end represents an unknown location. The range is inclusive, meaning a location representing just a single character would have its begin line and column be equal to its end line and column. There is no way to store a location representing "zero characters".

Definition at line 26 of file token.hpp.

Member Function Documentation

◆ operator+()

constexpr auto yume::Loc::operator+ ( const Loc other) const -> Loc
inlineconstexprnoexcept

Create a new location representing the "union" of two locations.

The new location will have the beginning line and column of whichever location has a beginning earlier in the file, and an ending line and column of whichever location has an ending later in the file.

Definition at line 39 of file token.hpp.

References begin_col, begin_line, end_col, end_line, file, and YUME_ASSERT.

◆ operator<=>()

constexpr auto yume::Loc::operator<=> ( const Loc other) const
constexprdefaultnoexcept

◆ single()

auto yume::Loc::single ( ) const -> Loc
inline

Return a new Loc which refers to the first character of the current Loc.

Definition at line 73 of file token.hpp.

References begin_col, begin_line, and file.

Referenced by yume::diagnostic::Note::emit().

◆ to_string()

auto yume::Loc::to_string ( ) const -> string
inline

Definition at line 47 of file token.hpp.

References begin_col, begin_line, end_col, end_line, file, and valid().

◆ valid()

auto yume::Loc::valid ( ) const -> bool
inline

Definition at line 70 of file token.hpp.

References begin_line, and end_line.

Referenced by yume::diagnostic::Note::emit(), and to_string().

Member Data Documentation

◆ begin_col

int yume::Loc::begin_col

Definition at line 28 of file token.hpp.

Referenced by yume::diagnostic::Note::emit(), operator+(), single(), and to_string().

◆ begin_line

int yume::Loc::begin_line

Definition at line 27 of file token.hpp.

Referenced by yume::diagnostic::Note::emit(), operator+(), single(), to_string(), and valid().

◆ end_col

int yume::Loc::end_col

Definition at line 30 of file token.hpp.

Referenced by operator+(), and to_string().

◆ end_line

int yume::Loc::end_line

Definition at line 29 of file token.hpp.

Referenced by operator+(), to_string(), and valid().

◆ file

const char* yume::Loc::file

Definition at line 31 of file token.hpp.

Referenced by operator+(), single(), and to_string().


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