|
FE 0.16.1
Fast, Effecient FrontEnds
|
Namespaces | |
| 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 | Cite |
| A borrowed fragment whose backticks stay markup; format_cite escapes every other argument. More... | |
| class | Cited |
| An owning message fragment that spells `citations` of its own; what format_cite yields. More... | |
| class | Cli |
| A small command-line parser for a single command - no subcommands. 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 and \\ a literal backslash. 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... | |
| class | Patricia |
| Hash-consed, immutable sets of D*, ordered by an unsigned id the elements carry themselves. 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... | |
| struct | StrHash |
| Hashes the characters of a string; transparent, so std::string keys may be looked up by std::string_view. 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 | SymTab |
A fixed-capacity Symbol -> V map for a closed set of Size entries: filled once, then only looked up - a Lexer's reserved words, say. More... | |
| class | Tab |
| Keeps track of indentation level during output. More... | |
| class | Vector |
| This is a thin wrapper for ankerl::svector<T, N, A> which is a drop-in replacement for std::vector<T, A>. More... | |
| class | VectorQueue |
| A FIFO queue over a Vector. More... | |
| class | VLA |
CRTP base that gives Self one VLA per element type in Self::VLA_Types directly behind it in memory - the C flexible array member, generalized to several arrays of different type. 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 | Diagnosable |
| Every frontend building block reports into the Error of S::driver. | |
| concept | Formattable |
| concept | Lexable |
What fe::Parser needs of its CRTP child S beyond fe::Diagnosable: the Lexer to pull Tokens from. | |
| 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 | Token |
| What fe::Parser needs of its Token type: a Tag and a Loc, copied in and out of the lookahead by value. | |
| concept | Vectorlike |
| Something which behaves like std::vector or std::array. | |
| concept | VLAed |
Does T carry VLAs? | |
Typedefs | |
| using | ostream_formatter = basic_ostream_formatter<char> |
| template<class T, size_t N = std::dynamic_extent> | |
| using | View = Span<const T, N> |
| Read-only Span; use Span itself, if you want to write through its elements. | |
| 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, VectorQueue<detail::WorklistElem<Set>>> |
| template<class Set> | |
| using | DFSWorklist = Worklist<Set, std::stack<detail::WorklistElem<Set>, Vector<detail::WorklistElem<Set>>>> |
| template<class... Args> | |
| using | cite_string |
| < | |
DbgMap/DbgSet | |
| template<class V> | |
| using | DbgMap = ankerl::unordered_dense::map<Dbg, V, Dbg::Hash, Dbg::Eq> |
| using | DbgSet = ankerl::unordered_dense::set<Dbg, Dbg::Hash, Dbg::Eq> |
StrMap/StrSet | |
Keyed by std::string but also looked up by std::string_view or const char* without building a std::string. | |
| template<class V> | |
| using | StrMap = ankerl::unordered_dense::map<std::string, V, StrHash, std::equal_to<>> |
| using | StrSet = ankerl::unordered_dense::set<std::string, StrHash, std::equal_to<>> |
SymMap/SymSet | |
Set/Map is keyed by pointer - which is hashed in SymPool. | |
| template<class V> | |
| using | SymMap = ankerl::unordered_dense::map<Sym, V, Sym::Hash, Sym::Eq> |
| using | SymSet = ankerl::unordered_dense::set<Sym, Sym::Hash, Sym::Eq> |
Functions | |
| 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<std::integral T> | |
| constexpr size_t | hash_combine (size_t seed, T v) noexcept |
Folds v into seed like ankerl::unordered_dense hashes a tuple: one 128-bit multiply, halves xored. | |
| 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 |
| template<class T = std::logic_error, class... Args> | |
| void | throwf (cite_string< Args... > fmt, Args &&... args) |
| < | |
| template<class... Args> | |
| Cited | format_cite (cite_string< Args... > fmt, Args &&... args) |
| < | |
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={}) |
| 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={}) |
| 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) |
| auto | lookup (auto &container, const auto &key) |
Yields a pointer to the value mapped to key (or the value itself if it is a pointer) or nullptr if not found. | |
| decltype(auto) | assert_lookup (auto &container, const auto &key) |
Looks up key in container, asserts that it exists, and returns a reference to the mapped value. | |
| auto | assert_emplace (auto &container, auto &&... 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 |
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 > | |
Variables | |
| template<class T> | |
| static constexpr size_t | Default_Inlined_Size = std::max((size_t)1, 4 * sizeof(size_t) / sizeof(T)) |
| Aims at 4 words (i.e., 4 * sizeof(size_t)) of inlined storage; svector's one-byte tag makes the object a word larger. | |
| using fe::BFSWorklist = Worklist<Set, VectorQueue<detail::WorklistElem<Set>>> |
Definition at line 115 of file worklist.h.
| using fe::term::cite_string |
<
A borrowed fragment whose backticks stay markup; format_cite escapes every other argument.
A literal and a Cited convert implicitly - both are text someone wrote as markup. Runtime text has to say so: spell it Cite(s), so data never becomes markup by accident. A const char* - a ternary of two literals, say - counts as runtime text and needs Cite(s) too.
| using fe::DbgMap = ankerl::unordered_dense::map<Dbg, V, Dbg::Hash, Dbg::Eq> |
| using fe::DbgSet = ankerl::unordered_dense::set<Dbg, Dbg::Hash, Dbg::Eq> |
| using fe::DFSWorklist = Worklist<Set, std::stack<detail::WorklistElem<Set>, Vector<detail::WorklistElem<Set>>>> |
Definition at line 117 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::StrMap = ankerl::unordered_dense::map<std::string, V, StrHash, std::equal_to<>> |
| using fe::StrSet = ankerl::unordered_dense::set<std::string, StrHash, std::equal_to<>> |
| using fe::SymMap = ankerl::unordered_dense::map<Sym, V, Sym::Hash, Sym::Eq> |
| using fe::SymSet = ankerl::unordered_dense::set<Sym, Sym::Hash, Sym::Eq> |
| auto fe::assert_emplace | ( | auto & | container, |
| auto &&... | args ) |
Invokes emplace on container, asserts that insertion actually happened, and returns the iterator.
Definition at line 61 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 54 of file container.h.
References assert_lookup().
Referenced by assert_lookup().
|
nodiscardconstexpr |
Definition at line 59 of file algo.h.
References binary_find().
Referenced by binary_find(), and binary_find().
|
nodiscardconstexpr |
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 12 of file assert.h.
References breakpoint().
Referenced by breakpoint(), and fe::Log::level2color().
|
inline |
Replaces all occurrences of what with repl.
Definition at line 74 of file algo.h.
References find_and_replace().
Referenced by find_and_replace().
| Cited fe::term::format_cite | ( | cite_string< Args... > | fmt, |
| Args &&... | args ) |
<
An owning message fragment that spells `citations` of its own; what format_cite yields.
Return this from a helper that assembles a fragment, and it stays valid wherever a Cite may go.
Definition at line 242 of file term.h.
Referenced by fe::Parser< Tok, Tag, K, S >::expect(), fe::RuntimeCast< B >::expect(), and fe::Parser< Tok, Tag, K, S >::tag2str_().
|
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 |
Folds v into seed like ankerl::unordered_dense hashes a tuple: one 128-bit multiply, halves xored.
Each step avalanches, so a chain needs no finalizer and suits a hasher that declares is_avalanching. Seed a chain with 0:
Definition at line 26 of file hash.h.
References hash_combine().
Referenced by fe::Bitset::hash(), hash_combine(), and fe::XTrie< D, K, N >::Data::Hash::operator()().
|
nodiscardconstexprnoexcept |
| fe::Join | ( | R && | , |
| std::string_view | = ", " ) -> Join< R > |
|
nodiscard |
Yields a pointer to the value mapped to key (or the value itself if it is a pointer) or nullptr if not found.
Constness of container carries over to the result.
Definition at line 45 of file container.h.
References lookup().
Referenced by lookup().
| FE_API std::ostream & fe::operator<< | ( | std::ostream & | , |
| Diag::Tag | ) |
References operator<<().
Referenced by operator<<().
|
nodiscardconstexprnoexcept |
|
nodiscard |
Definition at line 35 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 > |
| fe::StreamFn | ( | F | ) | -> StreamFn< F > |
| void fe::throwf | ( | cite_string< Args... > | fmt, |
| Args &&... | args ) |
<
std::format for a message that follows that convention; assemble a fragment of your own with it.
The Cited it yields is markup wherever it is used as an argument again - no re-wrapping needed. Throws a T (a std::logic_error by default) whose message is format_cite(fmt, args...). Use this for unrecoverable errors that should surface as a proper exception with a formatted message. The message is rendered here, so - like fe::Error::Bail - the what() is finished text a generic handler may print as is, not markup someone else still has to resolve. Colors follow term::auto_detached, just like the message fe::Log builds in a detached buffer.
Definition at line 274 of file term.h.
References fe::term::Red, fe::term::render_cite(), fe::term::Reset, and 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().