god::scan_error#
Note
Declared in <god/scanner.hpp>
-
class scan_error#
Represents an error encountered while scanning
Members
-
std::array<std::string, 3> context_lines#
Three string ‘lines’ used for error reporting context.
-
std::uint32_t line#
The line index at the moment of error.
-
std::uint32_t column#
The column index at the moment of error.
-
std::string message = "undocumented scanner error"#
The message displayed alongside the error context.
-
int return_code = 1#
The exit code to use when the program dies.
Constructors
-
inline scan_error(const std::deque<std::string> &plines, const position &pcursor)#
Contructor with only lines and cursor.
- Parameters:
plines – Constant reference to the deque of input string ‘lines’
pcursor – Constant reference to the cursor at the moment of error
-
inline scan_error(std::string pmessage, const std::deque<std::string> &plines, const position &pcursor)#
Extended constructor with added context message.
- Parameters:
pmessage – The message to display alongside the error
plines – Constant reference to the deque of input string ‘lines’
pcursor – Constant reference to the position objection of the error
Methods
-
inline bool operator==(const scan_error &other) const noexcept#
Boolean comparison overload.
- Parameters:
other – Another scan_error to compare
- Returns:
true if they are identical, false otherwise
-
std::array<std::string, 3> context() const noexcept#
Obtain context about the error.
- Returns:
3 strings worth of context
-
scan_error &msg(std::string str) noexcept#
Set the error’s message.
- Parameters:
str – The new error message to set
- Returns:
A reference to the scan_error, chainable
-
std::string_view msg() const noexcept#
Get the error’s message.
- Returns:
the error message as a string_view
-
scan_error &code(int c) noexcept#
Set the error’s code.
- Parameters:
c – The new error code to set
- Returns:
A reference to the scan_error, chainable
-
int code() const noexcept#
Get the error’s code.
- Returns:
The return_code
-
void quit() const noexcept#
Exit with return_code.
-
void send() const noexcept#
Print the error message and exit with return_code.
-
void panic() const noexcept#
Print the error message and exit with return_code.
-
void die() const noexcept#
Print the error message and exit with return_code.
-
std::array<std::string, 3> context_lines#