FE 0.6.0
A header-only C++ library for writing frontends
Loading...
Searching...
No Matches
fe Namespace Reference

Namespaces

namespace  format
 
namespace  utf8
 

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...
 
struct  Driver
 Use/derive from this class for "global" variables that you need all over the place. More...
 
struct  is_bit_enum
 
class  Lexer
 The blueprint for a lexer with a buffer of K tokens to peek into the future (Lexer::ahead). More...
 
struct  Loc
 Location in a File. More...
 
class  Parser
 The blueprint for a recursive descent/ ascent parser using a K lookahead of Tokens. More...
 
struct  Pos
 Position in a source file; pass around as value. 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...
 
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...
 

Concepts

concept  Nodeable
 
concept  BitEnum
 

Typedefs

using ostream_formatter = basic_ostream_formatter<char>
 
Sym

Set/Map is keyed by pointer - which is hashed in SymPool.

template<class V >
using SymMap = std::unordered_map<Sym, V>
 
using SymSet = std::unordered_set<Sym>
 

Functions

void unreachable ()
 
void breakpoint ()
 Raise breaokpoint in debugger.
 
std::ostream & operator<< (std::ostream &os, Pos pos)
 
std::ostream & operator<< (std::ostream &os, Loc loc)
 
Bit operations for enum classs

Provides all kind of bit and comparison operators for an enum class E.

Note that the bit operators return E's underlying type and not the original enum E. This is because the result may not be a valid enum value. For the same reason, it doesn't make sense to declare operators such as &=. Use like this:

using fe::operator&;
using fe::operator|;
using fe::operator^;
using fe::operator<=>;
using fe::operator==;
using fe::operator!=;
enum class MyEnum : unsigned {
A = 1 << 0,
B = 1 << 1,
C = 1 << 2,
};
template<> struct fe::is_bit_enum<MyEnum> : std::true_type { };
template<BitEnum E>
constexpr auto operator& (E x, E y)
 
template<BitEnum E>
constexpr auto operator& (std::underlying_type_t< E > x, E y)
 
template<BitEnum E>
constexpr auto operator& (E x, std::underlying_type_t< E > y)
 
template<BitEnum E>
constexpr auto operator| (E x, E y)
 
template<BitEnum E>
constexpr auto operator| (std::underlying_type_t< E > x, E y)
 
template<BitEnum E>
constexpr auto operator| (E x, std::underlying_type_t< E > y)
 
template<BitEnum E>
constexpr auto operator^ (E x, E y)
 
template<BitEnum E>
constexpr auto operator^ (std::underlying_type_t< E > x, E y)
 
template<BitEnum E>
constexpr auto operator^ (E x, std::underlying_type_t< E > y)
 
template<BitEnum E>
constexpr std::strong_ordering operator<=> (std::underlying_type_t< E > x, E y)
 
template<BitEnum E>
constexpr std::strong_ordering operator<=> (E x, std::underlying_type_t< E > y)
 
template<BitEnum E>
constexpr bool operator== (std::underlying_type_t< E > x, E y)
 
template<BitEnum E>
constexpr bool operator!= (std::underlying_type_t< E > x, E y)
 
template<BitEnum E>
constexpr bool operator== (E x, std::underlying_type_t< E > y)
 
template<BitEnum E>
constexpr bool operator!= (E x, std::underlying_type_t< E > y)
 
out/outln/err/errln

Print to std::cout/std::cerr via std::format; the *ln variants conclude with std::endl.

template<class... Args>
void err (format::format_string< Args... > fmt, Args &&... args)
 
template<class... Args>
void out (format::format_string< Args... > fmt, Args &&... args)
 
template<class... Args>
void errln (format::format_string< Args... > fmt, Args &&... args)
 
template<class... Args>
void outln (format::format_string< Args... > fmt, Args &&... args)
 

Variables

is_enum
template<class T >
constexpr bool is_bit_enum_v = is_bit_enum<T>::value
 

Typedef Documentation

◆ ostream_formatter

Definition at line 40 of file format.h.

◆ SymMap

template<class V >
using fe::SymMap = std::unordered_map<Sym, V>

Definition at line 185 of file sym.h.

◆ SymSet

using fe::SymSet = std::unordered_set<Sym>

Definition at line 186 of file sym.h.

Function Documentation

◆ breakpoint()

void fe::breakpoint ( )
inline

Raise breaokpoint in debugger.

Definition at line 26 of file assert.h.

◆ err()

template<class... Args>
void fe::err ( format::format_string< Args... > fmt,
Args &&... args )

Definition at line 46 of file format.h.

◆ errln()

template<class... Args>
void fe::errln ( format::format_string< Args... > fmt,
Args &&... args )

Definition at line 48 of file format.h.

◆ operator!=() [1/2]

template<BitEnum E>
bool fe::operator!= ( E x,
std::underlying_type_t< E > y )
constexpr

Definition at line 55 of file enum.h.

◆ operator!=() [2/2]

template<BitEnum E>
bool fe::operator!= ( std::underlying_type_t< E > x,
E y )
constexpr

Definition at line 53 of file enum.h.

◆ operator&() [1/3]

template<BitEnum E>
auto fe::operator& ( E x,
E y )
constexpr

Definition at line 41 of file enum.h.

◆ operator&() [2/3]

template<BitEnum E>
auto fe::operator& ( E x,
std::underlying_type_t< E > y )
constexpr

Definition at line 43 of file enum.h.

◆ operator&() [3/3]

template<BitEnum E>
auto fe::operator& ( std::underlying_type_t< E > x,
E y )
constexpr

Definition at line 42 of file enum.h.

◆ operator<<() [1/2]

std::ostream & fe::operator<< ( std::ostream & os,
Loc loc )

Definition at line 14 of file loc.cpp.h.

◆ operator<<() [2/2]

std::ostream & fe::operator<< ( std::ostream & os,
Pos pos )

Definition at line 6 of file loc.cpp.h.

◆ operator<=>() [1/2]

template<BitEnum E>
std::strong_ordering fe::operator<=> ( E x,
std::underlying_type_t< E > y )
constexpr

Definition at line 51 of file enum.h.

◆ operator<=>() [2/2]

template<BitEnum E>
std::strong_ordering fe::operator<=> ( std::underlying_type_t< E > x,
E y )
constexpr

Definition at line 50 of file enum.h.

◆ operator==() [1/2]

template<BitEnum E>
bool fe::operator== ( E x,
std::underlying_type_t< E > y )
constexpr

Definition at line 54 of file enum.h.

◆ operator==() [2/2]

template<BitEnum E>
bool fe::operator== ( std::underlying_type_t< E > x,
E y )
constexpr

Definition at line 52 of file enum.h.

◆ operator^() [1/3]

template<BitEnum E>
auto fe::operator^ ( E x,
E y )
constexpr

Definition at line 47 of file enum.h.

◆ operator^() [2/3]

template<BitEnum E>
auto fe::operator^ ( E x,
std::underlying_type_t< E > y )
constexpr

Definition at line 49 of file enum.h.

◆ operator^() [3/3]

template<BitEnum E>
auto fe::operator^ ( std::underlying_type_t< E > x,
E y )
constexpr

Definition at line 48 of file enum.h.

◆ operator|() [1/3]

template<BitEnum E>
auto fe::operator| ( E x,
E y )
constexpr

Definition at line 44 of file enum.h.

◆ operator|() [2/3]

template<BitEnum E>
auto fe::operator| ( E x,
std::underlying_type_t< E > y )
constexpr

Definition at line 46 of file enum.h.

◆ operator|() [3/3]

template<BitEnum E>
auto fe::operator| ( std::underlying_type_t< E > x,
E y )
constexpr

Definition at line 45 of file enum.h.

◆ out()

template<class... Args>
void fe::out ( format::format_string< Args... > fmt,
Args &&... args )

Definition at line 47 of file format.h.

◆ outln()

template<class... Args>
void fe::outln ( format::format_string< Args... > fmt,
Args &&... args )

Definition at line 49 of file format.h.

◆ unreachable()

void fe::unreachable ( )
inline
See also
https://stackoverflow.com/a/65258501

Definition at line 19 of file assert.h.

Variable Documentation

◆ is_bit_enum_v

template<class T >
bool fe::is_bit_enum_v = is_bit_enum<T>::value
inlineconstexpr

Definition at line 12 of file enum.h.