mirror of
https://codeberg.org/ProgramSnail/lang_2023.git
synced 2025-12-07 07:28:44 +00:00
fixes, colored errors
This commit is contained in:
parent
4b4756b657
commit
047ead6fa3
11 changed files with 166 additions and 195 deletions
|
|
@ -23,38 +23,36 @@ inline void PrintPosition(std::ostream& out,
|
|||
inline void HandleParsingError(const std::string& message,
|
||||
std::pair<size_t, size_t> start_position,
|
||||
std::pair<size_t, size_t> end_position) {
|
||||
std::cout << "Parsing Error: " << message << " at ";
|
||||
std::cout << "\x1b[1;31mParsing Error:\x1b[0m " << message << " at ";
|
||||
PrintPosition(std::cout, start_position, end_position);
|
||||
std::cout << ".\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
inline void HandleGeneralError(const std::string& message) {
|
||||
std::cout << "General Error: " << message << ".\n";
|
||||
std::cout << "\x1b[1;31mGeneral Error:\x1b[0m " << message << ".\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
inline void HandleInternalError(const std::string& message, const std::string& place) {
|
||||
std::cout << "Internal Error: " << message << " at " << place << ".\n";
|
||||
std::cout << "\x1b[1;31mInternal Error:\x1b[0m " << message << " at " << place << ".\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
inline void HandleTypecheckError(const std::string& message,
|
||||
const interpreter::tokens::BaseNode& node) { // TODO: place in code
|
||||
std::cout << "Typecheck Error: " << message << " at ";
|
||||
const interpreter::tokens::BaseNode& node) {
|
||||
std::cout << "\x1b[1;31mTypecheck Error:\x1b[0m " << message << " at ";
|
||||
PrintPosition(std::cout, node.start_position, node.end_position);
|
||||
std::cout << ".\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
inline void HandleRuntimeError(const std::string& message,
|
||||
const interpreter::tokens::BaseNode& node) { // TODO: place in code
|
||||
std::cout << "Runtime Error: " << message << " at ";
|
||||
const interpreter::tokens::BaseNode& node) {
|
||||
std::cout << "\x1b[1;31mRuntime Error:\x1b[0m " << message << " at ";
|
||||
PrintPosition(std::cout, node.start_position, node.end_position);
|
||||
std::cout << ".\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// ...
|
||||
|
||||
} // namespace error_handling
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue