5#include <llvm/Support/PrettyStackTrace.h>
6#include <llvm/Support/raw_ostream.h>
17inline auto what(
const std::exception_ptr& eptr = std::current_exception()) -> std::string_view {
19 throw std::bad_exception();
22 std::rethrow_exception(eptr);
23 }
catch (
const std::exception& e) {
25 }
catch (
const std::string& e) {
27 }
catch (
const char* e) {
30 return "[none available]";
37 return abi::__cxa_demangle(abi::__cxa_current_exception_type()->name(),
nullptr,
nullptr, &status);
42 auto exception = std::current_exception();
43 if (exception !=
nullptr) {
44 using enum llvm::raw_fd_ostream::Colors;
45 llvm::errs().changeColor(RED,
true) <<
"Uncaught exception resulted in termination!\n";
46 llvm::errs().changeColor(RED) <<
" Ultimately caught ";
48 llvm::errs().changeColor(RED) <<
" Additional info: ";
49 llvm::errs().changeColor(YELLOW) <<
what(exception) <<
"\n\n";
50 llvm::errs().resetColor();
62 void print(llvm::raw_ostream& stream)
const override { stream <<
message <<
"\n"; };
71 void print(llvm::raw_ostream& stream)
const override { stream <<
message <<
"\n"; };
All nodes in the AST tree of the program inherit from this class.
auto current_exception_name() -> const char *
auto what(const std::exception_ptr &eptr=std::current_exception()) -> std::string_view
void print(llvm::raw_ostream &stream) const override
ASTStackTrace(std::string message, const ast::AST &ast)
ASTStackTrace(std::string message)
ParserStackTrace(std::string message, const Token &token)
ParserStackTrace(std::string message)
void print(llvm::raw_ostream &stream) const override
A categorized token in source code, created by the tokenizer. These tokens are consumed by the lexer.