fixes, more information in errors

This commit is contained in:
ProgramSnail 2023-05-05 11:59:02 +03:00
parent a11ddbd25f
commit b686fe00fb
10 changed files with 356 additions and 65 deletions

View file

@ -1,11 +1,31 @@
#pragma once
#include "interpreter_tree.hpp"
#include <iostream>
#include <pthread.h>
namespace error_handling {
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";
inline void PrintPosition(std::ostream& out,
std::pair<size_t, size_t> start_position,
std::pair<size_t, size_t> end_position) {
out << '['
<< start_position.first
<< ", "
<< start_position.second
<< "] - ["
<< end_position.first
<< ", "
<< end_position.second
<< ']';
}
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 ";
PrintPosition(std::cout, start_position, end_position);
std::cout << ".\n";
exit(1);
}
@ -14,8 +34,11 @@ inline void HandleInternalError(const std::string& message, const std::string& p
exit(1);
}
inline void HandleTypecheckError(const std::string& message) { // TODO: place in code
std::cout << "Typecheck Error: " << message << ".\n";
inline void HandleTypecheckError(const std::string& message,
const interpreter::tokens::BaseNode& node) { // TODO: place in code
std::cout << "Typecheck Error: " << message << " at ";
PrintPosition(std::cout, node.start_position, node.end_position);
std::cout << ".\n";
exit(1);
}