mirror of
https://codeberg.org/ProgramSnail/lang_2023.git
synced 2026-01-25 13:07:13 +00:00
likn_symbols _visitor done, but it is not tested yet
This commit is contained in:
parent
3c643d2759
commit
3d74b1383e
10 changed files with 236 additions and 427 deletions
|
|
@ -1,29 +1,24 @@
|
|||
#pragma once
|
||||
|
||||
#include <iostream>
|
||||
|
||||
enum class ErrorVisitor {
|
||||
BuildVisitor,
|
||||
PrintVisitor,
|
||||
FindSymbolsVisitor,
|
||||
// ...
|
||||
};
|
||||
namespace error_handling {
|
||||
|
||||
// TODO
|
||||
inline void handle_error(std::string message, ErrorVisitor visitor) { // TODO: add place in code
|
||||
std::string visitor_str;
|
||||
switch (visitor) {
|
||||
case ErrorVisitor::BuildVisitor:
|
||||
visitor_str = "Build Visitor";
|
||||
break;
|
||||
case ErrorVisitor::PrintVisitor:
|
||||
visitor_str = "Print Visitor";
|
||||
break;
|
||||
case ErrorVisitor::FindSymbolsVisitor:
|
||||
visitor_str = "Find Symbols Visitor";
|
||||
break;
|
||||
// ...
|
||||
default:
|
||||
break;
|
||||
}
|
||||
std::cerr << "Error: " << message << " in " << visitor_str;
|
||||
inline void HandleParsingError(const std::string& message, std::pair<size_t, size_t> place) {
|
||||
std::cout << "Parsing Error: " << message << " at (" << place.first << ", " << place.second << ").\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
inline void HandleInternalError(const std::string& message, const std::string& place) {
|
||||
std::cout << "Internal Error: " << message << " at " << place << ".\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
inline void HandleTypecheckError(const std::string& message) { // TODO: place in code
|
||||
std::cout << "Typecheck Error: " << message << ".\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// ...
|
||||
|
||||
} // namespace error_handling
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue