Gyoji Compiler
|
Container for errors reported. More...
#include <errors.hpp>
Public Member Functions | |
Errors (TokenStream &_token_stream) | |
~Errors () | |
void | add_error (Gyoji::owned< Error > error) |
void | add_simple_error (const SourceReference &src_ref, std::string _error_title, std::string _error_message) |
void | print () const |
size_t | size () const |
const Error & | get (size_t n) const |
Container for errors reported.
The errors object is a container for any errors reported during the lex, parse, lowering, analysis, or code-generation layers. Each error is associated with one oe more messages with each message referencing the specific SourceReference where the error occurred.
Errors::Errors | ( | TokenStream & | _token_stream | ) |
References the token stream in order to allow the error reporting to gather the surrounding source lines and provide additional context to reported errors.
Errors::~Errors | ( | ) |
Move along, nothing to see here.
void Errors::add_error | ( | Gyoji::owned< Error > | error | ) |
Adds an error to the error list.
void Errors::add_simple_error | ( | const SourceReference & | src_ref, |
std::string | _error_title, | ||
std::string | _error_message | ||
) |
Adds a 'simple' error with only one message and one source location to the error list. This is used for things like 'variable not declared' where the error only needs to reference a single source location and say something about it.
const Error & Errors::get | ( | size_t | n | ) | const |
This returns a reference to a single specific error.
void Errors::print | ( | ) | const |
This is the main mechanism where errors are reported in a human-readable way, pointing out the context and specific location of the error.
size_t Errors::size | ( | ) | const |
This returns the number of errors reported so far.