Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
Aleph::Source_Span Struct Reference

Half-open byte range inside a source file. More...

#include <ah-source.H>

Collaboration diagram for Aleph::Source_Span:
[legend]

Public Member Functions

bool is_valid () const noexcept
 Returns whether the span belongs to a registered file.
 
bool empty () const noexcept
 Returns whether the span contains no bytes.
 
size_t size () const noexcept
 Returns the span length in bytes.
 
bool contains (const Source_Offset offset) const noexcept
 Returns whether offset lies inside the half-open range.
 
std::string to_string () const
 Formats the span as #file:[begin,end).
 

Public Attributes

Source_File_Id file_id = 0
 Stable file identifier; 0 means invalid.
 
Source_Offset begin = 0
 Inclusive begin byte offset.
 
Source_Offset end = 0
 Exclusive end byte offset.
 

Detailed Description

Half-open byte range inside a source file.

Spans are stable, cheap value objects used by tokens, AST nodes, symbols, and diagnostics. The range is [begin, end), so empty spans are allowed.

Definition at line 99 of file ah-source.H.

Member Function Documentation

◆ contains()

bool Aleph::Source_Span::contains ( const Source_Offset  offset) const
inlinenoexcept

Returns whether offset lies inside the half-open range.

Definition at line 124 of file ah-source.H.

References Aleph::and, begin, end, and offset.

◆ empty()

bool Aleph::Source_Span::empty ( ) const
inlinenoexcept

Returns whether the span contains no bytes.

Definition at line 112 of file ah-source.H.

References begin, and end.

◆ is_valid()

◆ size()

size_t Aleph::Source_Span::size ( ) const
inlinenoexcept

Returns the span length in bytes.

Definition at line 118 of file ah-source.H.

References begin, and end.

Referenced by Aleph::Source_Manager::slice().

◆ to_string()

std::string Aleph::Source_Span::to_string ( ) const
inline

Formats the span as #file:[begin,end).

Definition at line 130 of file ah-source.H.

References begin, Aleph::blossom_maximum_cardinality_matching(), end, file_id, is_valid(), and out.

Referenced by Aleph::Compiler_Token::to_string().

Member Data Documentation

◆ begin

Source_Offset Aleph::Source_Span::begin = 0

◆ end

Source_Offset Aleph::Source_Span::end = 0

◆ file_id


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