|
FE 0.15.0
A C++23 toolkit for writing compiler/interpreter frontends.
|
Location within a Src: the half-open byte range [Loc::begin, Loc::end). More...
#include <fe/loc.h>
Public Types | |
| enum class | Style { Full , RowCol , Row , MSVC } |
| How much of a Loc a diagnostic spells out; see Diag::loc_style. More... | |
Public Member Functions | |
| constexpr | Loc () noexcept=default |
| Creates an invalid Location. | |
| constexpr | Loc (const Src *src, Pos begin, Pos end) noexcept |
| constexpr | Loc (const Src *src, Pos pos) noexcept |
The empty Location at pos. | |
| constexpr | Loc (Pos begin, Pos end) noexcept |
| constexpr | Loc (Pos pos) noexcept |
| constexpr Loc | anew_begin () const noexcept |
| constexpr Loc | anew_end () const noexcept |
| constexpr uint32_t | size () const noexcept |
| constexpr Loc | operator+ (Pos pos) const noexcept |
| constexpr Loc | operator+ (Loc loc) const noexcept |
| The hull of both Locations. | |
| constexpr Loc | operator& (Loc loc) const noexcept |
| The overlap of both Locations - invalid if they are disjoint or sit in different files. | |
| constexpr | operator bool () const noexcept |
| Is a valid Location? | |
| constexpr bool | operator== (Loc other) const noexcept |
| void | dump () const |
Public Attributes | |
| const Src * | src = {} |
| Pos | begin = {} |
| Pos | end = {} |
| It's called end because - just like an STL iterator - it refers to the byte one past the last one within this Location. | |
Friends | |
| std::ostream & | operator<< (std::ostream &os, Loc loc) |
| Streams as path:row:col-row:col, resolved through Loc::src - or as raw offsets if it has none. | |
Location within a Src: the half-open byte range [Loc::begin, Loc::end).
It's only two machine words on a 64 bit arch, so pass around as value. An empty range is a Location between two characters - what you want to point at when something is missing rather than wrong; see Loc::anew_end.
|
strong |
How much of a Loc a diagnostic spells out; see Diag::loc_style.
| Enumerator | |
|---|---|
| Full | path:row:col-row:col - the whole range. |
| RowCol | path:row:col |
| Row | path:row |
| MSVC | path(row,col) |
|
constexprdefaultnoexcept |
Creates an invalid Location.
Referenced by anew_begin(), anew_end(), Loc(), fe::Error::n(), operator&(), operator+(), operator+(), operator<<, and operator==().
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
| void fe::Loc::dump | ( | ) | const |
|
inlineexplicitconstexprnoexcept |
The overlap of both Locations - invalid if they are disjoint or sit in different files.
Dual to operator+; since an invalid Loc is falsy, if (a & b) also reads as "do they overlap?". An empty Loc overlaps nothing, not even itself.
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
Definition at line 65 of file loc.h.
References begin, end, and fe::Pos::off.
Referenced by fe::Lexer< K, S >::view().
|
friend |
| Pos fe::Loc::begin = {} |
Definition at line 92 of file loc.h.
Referenced by anew_begin(), Loc(), Loc(), operator bool(), operator&(), operator+(), operator+(), operator==(), size(), fe::Parser< Tok, Tag, K, S >::tracker(), and fe::Lexer< K, S >::view().
| Pos fe::Loc::end = {} |
It's called end because - just like an STL iterator - it refers to the byte one past the last one within this Location.
Definition at line 93 of file loc.h.
Referenced by fe::Lexer< K, S >::accept_while(), anew_end(), Loc(), Loc(), fe::Lexer< K, S >::next(), operator&(), operator==(), and size().
| const Src* fe::Loc::src = {} |
Definition at line 91 of file loc.h.
Referenced by anew_begin(), anew_end(), Loc(), Loc(), operator&(), operator+(), operator+(), and operator==().