#include "gsc/runtimeError.hpp"
#include <string>
Go to the source code of this file.
|
void | report (const int &line, const std::string &where, const std::string &message) |
| Report an error in the given line and location.
|
|
void | error (const int &line, const std::string &message) |
| Report an error in the given line.
|
|
void | error (const Token &token, const std::string &message) |
| Report an error in the given token.
|
|
void | runtimeError (const RuntimeError &error) |
| Report a runtime error given a RuntimeError object.
|
|
◆ error() [1/2]
void error |
( |
const int & |
line, |
|
|
const std::string & |
message |
|
) |
| |
Report an error in the given line.
- Parameters
-
line | The line number where the error occurred. |
message | The error message to display. |
- Note
- This function sets the global variable
hadError
to true and writes in stderr.
- See also
- report
Definition at line 12 of file error.cpp.
12 {
14}
void report(const int &line, const std::string &where, const std::string &message)
Report an error in the given line and location.
◆ error() [2/2]
void error |
( |
const Token & |
token, |
|
|
const std::string & |
message |
|
) |
| |
Report an error in the given token.
- Parameters
-
token | The token where the error occurred. |
message | The error message to display. |
- Note
- This function sets the global variable
hadError
to true and writes in stderr.
- See also
- report
Definition at line 16 of file error.cpp.
16 {
19 } else {
21 }
22}
std::string getLexeme() const
TokenType getType() const
◆ report()
void report |
( |
const int & |
line, |
|
|
const std::string & |
where, |
|
|
const std::string & |
message |
|
) |
| |
Report an error in the given line and location.
- Parameters
-
line | The line number where the error occurred. |
where | The location of the error. |
message | The error message to display. |
- Note
- This function sets the global variable
hadError
to true and writes in stderr.
Definition at line 4 of file error.cpp.
5 {
6 std::cerr << "[line " << line << "] Error " << where << ": " << message
7 << "\n";
8
10}
◆ runtimeError()
Report a runtime error given a RuntimeError object.
- Parameters
-
- Note
- This function sets the global variable
hadRuntimeError
to true and writes in stderr.
Definition at line 24 of file error.cpp.
24 {
25 std::cerr <<
error.getMessage() <<
"\n[line " <<
error.getToken()->getLine()
26 << "]" << std::endl;
28}
void error(const int &line, const std::string &message)
Report an error in the given line.
◆ hadError
◆ hadRuntimeError
bool hadRuntimeError = false |
|
inline |