|
FE 0.15.0
A C++23 toolkit for writing compiler/interpreter frontends.
|
Collects diagnostics and hands each to the Diag that lays it out. More...
#include <fe/error.h>
Classes | |
| class | Bail |
| What Error::ack and Error::bail throw. More... | |
| struct | Note |
| A secondary message elaborating a Msg. More... | |
| struct | Msg |
| One Tag::Error or Tag::Warn together with the Notes that belong to it. More... | |
Public Types | |
| using | Tag = Diag::Tag |
Public Member Functions | |
| Error (const Driver &driver) | |
| A sink of your own; Driver::error is the one every frontend building block already reports to. | |
Getters | |
| const auto & | msgs () const |
| bool | empty () const |
| bool | ok () const |
| Nothing recorded that must stop the compilation? | |
| size_t | num_errors () const |
| size_t | num_warnings () const |
| size_t | num_notes () const |
| bool | truncated () const |
| Did Diag::max_errors drop anything? | |
Add a Message | |
Each of these yields the Error again, so a diagnostic, its Notes, and a closing Error::bail chain. | |
| Error & | msg (Loc loc, Tag tag, const std::function< std::string()> &fmt) |
| template<class... Args> | |
| Error & | msg (Loc loc, Tag tag, cite_string< Args... > s, Args &&... args) |
The backticks of s delimit a `citation` ; those of an argument are data and get escaped - see Cite. | |
| template<class... Args> | |
| Error & | e (Loc loc, cite_string< Args... > s, Args &&... args) |
| template<class... Args> | |
| Error & | w (Loc loc, cite_string< Args... > s, Args &&... args) |
| template<class... Args> | |
| Error & | n (cite_string< Args... > s, Args &&... args) |
| A = note: continuation of the diagnostic being built; it has no Loc of its own to point at. | |
| template<class... Args> | |
| Error & | n (Loc loc, cite_string< Args... > s, Args &&... args) |
A Note that points elsewhere; dropped when loc adds nothing. | |
Handle Errors/Warnings | |
| void | clear () |
| std::string | str (std::ostream &os=std::cerr) const |
Renders everything collected so far the way it would appear on os; os only decides the coloring. | |
| size_t | report (std::ostream &os=std::cerr) |
Streams everything collected so far to os and claims it. | |
| void | bail (std::ostream &os=std::cerr) |
Claims everything collected so far and throws it as a Bail rendered for os. | |
| void | ack (std::ostream &os=std::cerr) |
If errors occurred, Error::bail; otherwise Error::report any warnings to os. | |
Friends | |
| std::ostream & | operator<< (std::ostream &os, const Error &e) |
| Hands every Msg, its Notes, and the closing summary to Diag. | |
Collects diagnostics and hands each to the Diag that lays it out.
Error::ack once you are done: it throws an Error::Bail if anything went wrong.
| struct fe::Error::Note |
| struct fe::Error::Msg |
| using fe::Error::Tag = Diag::Tag |
|
inlineexplicit |
A sink of your own; Driver::error is the one every frontend building block already reports to.
driver's SrcMap and Error::msg renders through Diag::render, so driver must outlive this Error. Definition at line 68 of file error.h.
Referenced by e(), msg(), msg(), n(), n(), operator<<, and w().
| void fe::Error::ack | ( | std::ostream & | os = std::cerr | ) |
If errors occurred, Error::bail; otherwise Error::report any warnings to os.
| void fe::Error::bail | ( | std::ostream & | os = std::cerr | ) |
Claims everything collected so far and throws it as a Bail rendered for os.
Referenced by fe::Error::Bail::operator<<.
| void fe::Error::clear | ( | ) |
|
inline |
Definition at line 96 of file error.h.
References Error(), and msg().
Referenced by fe::Lexer< K, S >::char_err(), operator<<, fe::Parser< Tok, Tag, K, S >::syntax_err(), fe::Parser< Tok, Tag, K, S >::unanchored_err(), and fe::Lexer< K, S >::utf8_err().
|
inline |
Records the message fmt renders; see Diag::render. tag must be Tag::Error or Tag::Warn - a Tag::Note belongs to Error::note.
References Error().
|
inline |
|
inline |
A Note that points elsewhere; dropped when loc adds nothing.
A loc overlapping the primary one is already covered by its snippet and so points nowhere new. An invalid loc points nowhere and degrades to the = note: continuation above. The renderer gives loc a header line of its own, so phrase the message to stand alone.
Definition at line 106 of file error.h.
References Error().
|
inline |
|
inline |
Nothing recorded that must stop the compilation?
Definition at line 75 of file error.h.
References num_errors().
| size_t fe::Error::report | ( | std::ostream & | os = std::cerr | ) |
Streams everything collected so far to os and claims it.
| std::string fe::Error::str | ( | std::ostream & | os = std::cerr | ) | const |
Renders everything collected so far the way it would appear on os; os only decides the coloring.
|
inline |
Did Diag::max_errors drop anything?
|
inline |
|
friend |