result / optional return type modifiers for functions (one for all returns)

This commit is contained in:
ProgramSnail 2023-07-29 14:48:45 +03:00
parent 68463509d8
commit 195a26f9b7
10 changed files with 74 additions and 36 deletions

View file

@ -16,15 +16,18 @@ inline void print_position(std::ostream &out,
<< ']';
}
inline void
handle_internal_error(const std::string &message,
std::optional<const nodes::Node *> node = std::nullopt) {
std::cerr << "\x1b[1;31mInternal Error:\x1b[0m " << message;
if (node.has_value()) {
std::cerr << " at ";
print_position(std::cerr, node.value()->get_start_position(),
node.value()->get_end_position());
}
inline void handle_internal_error(const std::string &message,
const nodes::Node &node) {
std::cerr << "\x1b[1;31mInternal Error:\x1b[0m " << message << " at ";
print_position(std::cerr, node.get_start_position(), node.get_end_position());
std::cerr << ".\n";
exit(1);
}
inline void handle_internal_error(const std::string &message,
parser::ParseTree::Node node) {
std::cerr << "\x1b[1;31mInternal Error:\x1b[0m " << message << " at ";
print_position(std::cerr, node.get_start_point(), node.get_end_point());
std::cerr << ".\n";
exit(1);
}