|
FE 0.13.1
Header-only C++ frontend library
|
Namespaces | |
| namespace | cli |
| A small command-line parser for a single command - no subcommands. | |
| namespace | dl |
| namespace | lct |
| namespace | sys |
| namespace | term |
| Lightweight stream-based terminal colors for diagnostics and CLI output. | |
| namespace | utf8 |
| UTF-8 helpers for decoding byte streams, encoding char32_t values, and running ASCII-style character classification on char32_t. | |
Classes | |
| class | Arena |
| An arena pre-allocates so-called pages of size Arena::page_size_. More... | |
| struct | basic_ostream_formatter |
| Make types that support ostream operators available for std::format. More... | |
| class | Bitset |
| A dynamically growing set of bits with small storage optimization. More... | |
| class | CodeDiag |
| The Diag a Driver installs by default: colors a `citation` and drops its backticks - or keeps them verbatim without color; \` is a literal backtick. More... | |
| struct | Dbg |
| The debug info of an entity: where it came from and what it was called. More... | |
| class | DbgKey |
| Opaque handle to a Dbg interned in a Driver; see Driver::dbg. More... | |
| class | Diag |
| How a diagnostic lays out - and how much of it an Error keeps. More... | |
| struct | Driver |
| Use/derive from this class for "global" variables that you need all over the place. More... | |
| class | Error |
| Collects diagnostics and hands each to the Diag that lays it out. More... | |
| struct | is_bit_enum |
| class | Join |
Join elements of range with sep. More... | |
| class | Lexer |
The blueprint for a lexer with a buffer of K tokens to peek into the future (Lexer::ahead). More... | |
| struct | Loc |
| Location within a Src: the half-open byte range [Loc::begin, Loc::end). More... | |
| class | Log |
| Facility to log what you are doing. More... | |
| class | Parser |
The blueprint for a recursive descent/ ascent parser using a K lookahead of Tokens. More... | |
| struct | PathHash |
| Hashes a std::filesystem::path - consistent with its operator==, which compares lexically. More... | |
| struct | Pos |
| Byte offset into a Src; pass around as value. More... | |
| class | Profiler |
| Records wall-clock timings for (possibly nested) named Profiler::Spans and reports them in various formats. More... | |
| class | Restore |
| RAII guard that restores a value at the end of the scope. More... | |
| class | Restore< T, nullptr, nullptr > |
Restores ref to its current value at the end of the scope. More... | |
| class | Ring |
A ring buffer with N elements. More... | |
| class | Ring< T, 1 > |
| Specialization if N == 1 - doesn't need a ring. More... | |
| class | Ring< T, 2 > |
| Specialization if N == 2; doesn't need a ring, we just copy. More... | |
| class | RuntimeCast |
| Inherit from this class using CRTP, for some nice dynamic_cast-style wrappers. More... | |
| struct | Snippet |
| The underlined source excerpt that goes below a diagnostic. More... | |
| class | Span |
| This is a thin wrapper for std::span<T, N> with the following additional features: More... | |
| class | Src |
| The content of one source file together with the offsets its rows start at. More... | |
| class | SrcMap |
| Interns the text - and the std::filesystem::path - of every file a Loc may point into. More... | |
| class | StreamFn |
| Wrap a callable f(std::ostream&) -> std::ostream& so it streams via operator<< and std::format. More... | |
| class | Sym |
| A Symbol just wraps a pointer to Sym::String, so pass Sym itself around as value. More... | |
| class | SymPool |
| Hash set where all strings - wrapped in Symbol - live in. More... | |
| class | Tab |
| Keeps track of indentation level during output. More... | |
| class | Vector |
| This is a thin wrapper for absl::InlinedVector<T, N, A> which is a drop-in replacement for std::vector<T, A>. More... | |
| class | Worklist |
| A worklist that pushes each element at most once. More... | |
| class | XTrie |
| Hash-consed sets of D*. More... | |
Concepts | |
| concept | BitEnum |
| concept | Formattable |
| concept | Nodeable |
| concept | NodeSetable |
| Like Nodeable, but for a class that spans a set of node kinds instead of a single one. | |
| concept | Queuelike |
| Something which behaves like std::queue. | |
| concept | Stacklike |
| Something which behaves like std::stack or std::priority_queue. | |
| concept | Vectorlike |
| Something which behaves like std::vector or std::array. | |
Typedefs | |
| using | ostream_formatter = basic_ostream_formatter<char> |
| template<class T, size_t N = std::dynamic_extent> | |
| using | View = Span<const T, N> |
| template<class V> | |
| using | PathMap = std::unordered_map<std::filesystem::path, V, PathHash> |
Maps a std::filesystem::path to V. | |
| template<class Set> | |
| using | BFSWorklist = Worklist<Set, std::queue<detail::WorklistElem<Set>>> |
| template<class Set> | |
| using | DFSWorklist = Worklist<Set, std::stack<detail::WorklistElem<Set>>> |
DbgMap/DbgSet | |
| template<class V> | |
| using | DbgMap = std::unordered_map<Dbg, V, Dbg::Hash, Dbg::Eq> |
| using | DbgSet = std::unordered_set<Dbg, Dbg::Hash, Dbg::Eq> |
SymMap/SymSet | |
Set/Map is keyed by pointer - which is hashed in SymPool. | |
| template<class V> | |
| using | SymMap = std::unordered_map<Sym, V, Sym::Hash, Sym::Eq> |
| using | SymSet = std::unordered_set<Sym, Sym::Hash, Sym::Eq> |
Functions | |
| template<class T = std::logic_error, class... Args> | |
| void | throwf (std::format_string< Args... > fmt, Args &&... args) |
| Throws a T (a std::logic_error by default) whose message is std::format(fmt, args...). | |
| void | unreachable () |
| void | breakpoint () |
| Raise a breakpoint in the debugger. | |
| FE_API std::ostream & | operator<< (std::ostream &, Diag::Tag) |
| template<fe::BitEnum E> | |
| constexpr bool | has_flag (E value, E flag) noexcept |
| template<class F> | |
| StreamFn (F) -> StreamFn< F > | |
| template<class R> | |
| Join (R &&, std::string_view=", ") -> Join< R > | |
| template<class T> | |
| Restore (T &, T) -> Restore< T > | |
| The primary template has no two-argument constructor to deduce this one from. | |
| template<size_t I, class T, size_t N> requires (N != std::dynamic_extent) | |
| constexpr decltype(auto) | get (Span< T, N > span) noexcept |
Utility Functions | |
| template<class D, class S> requires (std::is_trivially_copyable_v<S> && std::is_trivially_copyable_v<D>) | |
| constexpr D | bitcast_resize (const S &src) noexcept |
A bitcast from src of type S to D, supporting different sizes. | |
| constexpr std::uint64_t | pad (std::uint64_t offset, std::uint64_t align) noexcept |
Rounds offset up to the next multiple of align. | |
| constexpr bool | is_aligned (std::uint64_t offset, std::uint64_t align) noexcept |
Algorithms | |
| template<std::random_access_iterator I, class T, class L = std::less<>> | |
| constexpr I | binary_find (I begin, I end, const T &val, L lt={}) noexcept |
| template<std::ranges::random_access_range R, class T, class L = std::less<>> requires std::ranges::common_range<R> | |
| constexpr auto | binary_find (R &&r, const T &val, L lt={}) noexcept |
| constexpr std::string_view | subview (std::string_view s, size_t i, size_t n=std::string_view::npos) noexcept |
Like std::string::substr, but works on std::string_view and clamps i instead of throwing. | |
| void | find_and_replace (std::string &str, std::string_view what, std::string_view repl) |
Replaces all occurrences of what with repl. | |
Helpers for Containers | |
| template<Stacklike S> | |
| S::value_type | pop (S &s) |
| template<Queuelike Q> | |
| Q::value_type | pop (Q &q) |
| template<class C, class K> | |
| auto | lookup (C &container, const K &key) |
| Yields pointer to element (or the element itself if it is already a pointer), if found and nullptr otherwise. | |
| template<class C, class K> | |
| decltype(auto) | assert_lookup (C &container, const K &key) |
Looks up key in container, asserts that it exists, and returns a reference to the mapped value. | |
| template<class C, class... Args> | |
| auto | assert_emplace (C &container, Args &&... args) |
Invokes emplace on container, asserts that insertion actually happened, and returns the iterator. | |
Bit operations for enum classs | |
Provides all kind of bit and comparison operators for an enum class Use like this: | |
| template<fe::BitEnum E> | |
| constexpr auto | to_underlying (E e) noexcept |
Bit Mixers | |
These finalizers scramble a single word. They are bijective, i.e., they don't introduce any collisions on their own - they merely spread the input bits. | |
| constexpr uint32_t | murmur3 (uint32_t h) noexcept |
| MurmurHash3's 32-bit finalizer fmix32. | |
| constexpr uint64_t | splitmix64 (uint64_t h) noexcept |
| SplitMix64's 64-bit finalizer. | |
| constexpr size_t | hash (size_t h) noexcept |
Mixes h with murmur3 or splitmix64 - whichever matches sizeof(size_t). | |
Deduction Guides | |
| template<class I, class E> | |
| Span (I, E) -> Span< std::remove_reference_t< std::iter_reference_t< I > > > | |
| template<class T, size_t N> | |
| Span (T(&)[N]) -> Span< T, N > | |
| template<class T, size_t N> | |
| Span (std::array< T, N > &) -> Span< T, N > | |
| template<class T, size_t N> | |
| Span (const std::array< T, N > &) -> Span< const T, N > | |
| template<class R> | |
| Span (R &&) -> Span< std::remove_reference_t< std::ranges::range_reference_t< R > > > | |
| template<Vectorlike Vec> | |
| Span (Vec &) -> Span< typename Vec::value_type, std::dynamic_extent > | |
| template<Vectorlike Vec> | |
| Span (const Vec &) -> Span< const typename Vec::value_type, std::dynamic_extent > | |
| template<class I, class A = std::allocator<typename std::iterator_traits<I>::value_type>> | |
| Vector (I, I, A=A()) -> Vector< typename std::iterator_traits< I >::value_type, Default_Inlined_Size< typename std::iterator_traits< I >::value_type >, A > | |
erase | |
| template<class T, size_t N, class A, class U> | |
| Vector< T, N, A >::size_type | erase (Vector< T, N, A > &c, const U &value) |
| template<class T, size_t N, class A, class Pred> | |
| Vector< T, N, A >::size_type | erase_if (Vector< T, N, A > &c, Pred pred) |
Variables | |
| template<class T> | |
| static constexpr size_t | Default_Inlined_Size = std::max((size_t)1, 4 * sizeof(size_t) / sizeof(T)) |
| Use up to 4 words (i.e., 4 * sizeof(size_t)) of inlined storage, rounded up. | |
FNV-1 Hash | |
See Wikipedia. Use hash_begin to seed a hash chain and hash_combine to fold in one value after another: auto h = fe::hash_begin(x);
constexpr size_t hash_begin() noexcept Seeds a hash chain with the FNV-1 offset basis. Definition hash.h:64 constexpr size_t hash_combine(size_t seed, T v) noexcept Mixes v into seed word-wise, reusing the FNV-1 prime as multiplier. Definition hash.h:68
| |
| constexpr size_t | fnv1_offset = sizeof(size_t) == 4 ? size_t(UINT32_C(2166136261)) : size_t(UINT64_C(14695981039346656037)) |
| FNV-1 magic numbers for sizeof(size_t). | |
| constexpr size_t | fnv1_prime = sizeof(size_t) == 4 ? size_t(UINT32_C( 16777619)) : size_t(UINT64_C( 1099511628211)) |
| constexpr size_t | hash_begin () noexcept |
| Seeds a hash chain with the FNV-1 offset basis. | |
| template<std::integral T> | |
| constexpr size_t | hash_combine (size_t seed, T v) noexcept |
Mixes v into seed word-wise, reusing the FNV-1 prime as multiplier. | |
| template<std::integral T> | |
| constexpr size_t | hash_begin (T v) noexcept |
| Shorthand for hash_combine(hash_begin(), v). | |
| using fe::BFSWorklist = Worklist<Set, std::queue<detail::WorklistElem<Set>>> |
Definition at line 78 of file worklist.h.
| using fe::DbgMap = std::unordered_map<Dbg, V, Dbg::Hash, Dbg::Eq> |
| using fe::DFSWorklist = Worklist<Set, std::stack<detail::WorklistElem<Set>>> |
Definition at line 80 of file worklist.h.
| using fe::ostream_formatter = basic_ostream_formatter<char> |
| using fe::PathMap = std::unordered_map<std::filesystem::path, V, PathHash> |
Maps a std::filesystem::path to V.
| using fe::SymMap = std::unordered_map<Sym, V, Sym::Hash, Sym::Eq> |
| using fe::SymSet = std::unordered_set<Sym, Sym::Hash, Sym::Eq> |
| auto fe::assert_emplace | ( | C & | container, |
| Args &&... | args ) |
Invokes emplace on container, asserts that insertion actually happened, and returns the iterator.
Definition at line 63 of file container.h.
References assert_emplace(), and assert_unused.
Referenced by assert_emplace().
|
nodiscard |
Looks up key in container, asserts that it exists, and returns a reference to the mapped value.
Definition at line 55 of file container.h.
References assert_lookup().
Referenced by assert_lookup().
|
nodiscardconstexprnoexcept |
Definition at line 59 of file algo.h.
References binary_find().
Referenced by binary_find(), and binary_find().
|
nodiscardconstexprnoexcept |
Definition at line 69 of file algo.h.
References binary_find().
|
constexprnoexcept |
A bitcast from src of type S to D, supporting different sizes.
Keeps the low-order bytes on either endianness: a wider D zero-fills the rest, a narrower one truncates.
Definition at line 26 of file algo.h.
References bitcast_resize().
Referenced by bitcast_resize().
|
inline |
Raise a breakpoint in the debugger.
Definition at line 41 of file assert.h.
References breakpoint().
Referenced by breakpoint().
|
inline |
Replaces all occurrences of what with repl.
Definition at line 81 of file algo.h.
References find_and_replace().
Referenced by find_and_replace().
|
constexprnoexcept |
|
constexprnoexcept |
flag must have at least one bit set; has_flag(value, E{}) would be vacuously true. flag is a runtime value, so this is a runtime assert rather than a static_assert (in a constexpr evaluation a zero flag turns it into a compile-time error all the same). Definition at line 47 of file enum.h.
References has_flag(), and to_underlying().
Referenced by has_flag().
|
constexprnoexcept |
Mixes h with murmur3 or splitmix64 - whichever matches sizeof(size_t).
Definition at line 37 of file hash.h.
References hash(), murmur3(), and splitmix64().
Referenced by hash(), and hash_combine().
|
constexprnoexcept |
Seeds a hash chain with the FNV-1 offset basis.
Definition at line 64 of file hash.h.
References fnv1_offset, and hash_begin().
Referenced by fe::Bitset::hash(), hash_begin(), hash_begin(), fe::Dbg::Hash::operator()(), and fe::XTrie< D, K, N >::Data::Hash::operator()().
|
constexprnoexcept |
Shorthand for hash_combine(hash_begin(), v).
Definition at line 74 of file hash.h.
References hash_begin(), and hash_combine().
|
constexprnoexcept |
Mixes v into seed word-wise, reusing the FNV-1 prime as multiplier.
Definition at line 68 of file hash.h.
References fnv1_prime, hash(), and hash_combine().
Referenced by fe::Bitset::hash(), hash_begin(), hash_combine(), fe::Dbg::Hash::operator()(), and fe::XTrie< D, K, N >::Data::Hash::operator()().
|
nodiscardconstexprnoexcept |
| fe::Join | ( | R && | , |
| std::string_view | = ", " ) -> Join< R > |
|
nodiscard |
Yields pointer to element (or the element itself if it is already a pointer), if found and nullptr otherwise.
Constness of container carries over to the result.
Definition at line 45 of file container.h.
References lookup().
Referenced by lookup().
|
constexprnoexcept |
| FE_API std::ostream & fe::operator<< | ( | std::ostream & | , |
| Diag::Tag | ) |
References operator<<().
Referenced by operator<<().
|
nodiscardconstexprnoexcept |
|
nodiscard |
Definition at line 34 of file container.h.
References pop().
|
nodiscard |
Definition at line 27 of file container.h.
References pop().
Referenced by pop(), pop(), and fe::Worklist< Set, C >::pop().
| fe::Restore | ( | T & | , |
| T | ) -> Restore< T > |
The primary template has no two-argument constructor to deduce this one from.
| fe::Span | ( | const std::array< T, N > & | ) | -> Span< const T, N > |
| fe::Span | ( | const Vec & | ) | -> Span< const typename Vec::value_type, std::dynamic_extent > |
| fe::Span | ( | I | , |
| E | ) -> Span< std::remove_reference_t< std::iter_reference_t< I > > > |
| fe::Span | ( | R && | ) | -> Span< std::remove_reference_t< std::ranges::range_reference_t< R > > > |
| fe::Span | ( | std::array< T, N > & | ) | -> Span< T, N > |
| fe::Span | ( | T(&) | [N] | ) | -> Span< T, N > |
| fe::Span | ( | Vec & | ) | -> Span< typename Vec::value_type, std::dynamic_extent > |
|
constexprnoexcept |
SplitMix64's 64-bit finalizer.
Definition at line 27 of file hash.h.
References splitmix64().
Referenced by hash(), and splitmix64().
| fe::StreamFn | ( | F | ) | -> StreamFn< F > |
|
nodiscardconstexprnoexcept |
| void fe::throwf | ( | std::format_string< Args... > | fmt, |
| Args &&... | args ) |
Throws a T (a std::logic_error by default) whose message is std::format(fmt, args...).
Use this for unrecoverable errors that should surface as a proper exception with a formatted message.
Definition at line 15 of file assert.h.
References throwf().
Referenced by fe::RuntimeCast< B >::expect(), and throwf().
|
constexprnoexcept |
Definition at line 28 of file enum.h.
References to_underlying().
Referenced by has_flag(), operator&(), operator^(), operator|(), and to_underlying().
|
inline |
Definition at line 31 of file assert.h.
References unreachable().
Referenced by fe::Log::level2acro(), fe::Log::level2color(), fe::XTrie< D, K, N >::Set::iterator::operator*(), fe::XTrie< D, K, N >::Set::iterator::operator++(), unreachable(), and fe::term::use_color().
| fe::Vector | ( | I | , |
| I | , | ||
| A | = A() ) -> Vector< typename std::iterator_traits< I >::value_type, Default_Inlined_Size< typename std::iterator_traits< I >::value_type >, A > |
References Default_Inlined_Size.
Referenced by fe::XTrie< D, K, N >::create(), and fe::XTrie< D, K, N >::create().
|
staticconstexpr |
|
inlineconstexpr |
FNV-1 magic numbers for sizeof(size_t).
Definition at line 59 of file hash.h.
Referenced by hash_begin().
|
inlineconstexpr |
Definition at line 60 of file hash.h.
Referenced by hash_combine().