![]() |
ArkScript
A small, lisp-inspired, functional scripting language
|
Classes | |
struct | ErrorLocation |
struct | LineColorContextCounts |
class | Printer |
Source printer for diagnostics. More... | |
struct | Window |
Functions | |
ARK_API void | makeContext (const ErrorLocation &loc, std::ostream &os, const std::optional< CodeErrorContext > &maybe_context, bool colorize) |
Helper to create a colorized context to report errors to the user. | |
std::string | makeContextWithNode (const std::string &message, const internal::Node &node) |
Helper used by the compiler to generate a colorized context from a node. | |
ARK_API void | generate (const CodeError &e, std::ostream &os=std::cout, bool colorize=true) |
Generate a diagnostic from an error and print it to the standard output. | |
void | showFileLocation (std::ostream &os, const ErrorLocation &loc) |
void | hintWithContext (std::ostream &os, const std::optional< CodeErrorContext > &maybe_context, const bool colorize) |
void | helper (std::ostream &os, const std::string &message, const bool colorize, const std::string &filename, const internal::FileSpan &at, const std::optional< CodeErrorContext > &maybe_context=std::nullopt) |
bool | isPairableChar (const char c) |
void | colorizeLine (const std::string &line, LineColorContextCounts &ctx, std::ostream &os) |
void Ark::Diagnostics::colorizeLine | ( | const std::string & | line, |
LineColorContextCounts & | ctx, | ||
std::ostream & | os ) |
Definition at line 20 of file PrettyPrinting.cpp.
References isPairableChar(), Ark::Diagnostics::LineColorContextCounts::open_curly_braces, Ark::Diagnostics::LineColorContextCounts::open_parentheses, and Ark::Diagnostics::LineColorContextCounts::open_square_braces.
Referenced by Ark::Diagnostics::Printer::printLine().
void Ark::Diagnostics::generate | ( | const CodeError & | e, |
std::ostream & | os = std::cout, | ||
bool | colorize = true ) |
Generate a diagnostic from an error and print it to the standard output.
e | code error |
os | output stream |
colorize | generate colors or not |
Definition at line 218 of file Diagnostics.cpp.
References Ark::CodeError::additional_context, Ark::CodeErrorContext::at, Ark::CodeError::context, Ark::CodeErrorContext::filename, and helper().
Referenced by Ark::Welder::computeAST(), Ark::Welder::generateBytecode(), Formatter::run(), and Formatter::runWithString().
void Ark::Diagnostics::helper | ( | std::ostream & | os, |
const std::string & | message, | ||
const bool | colorize, | ||
const std::string & | filename, | ||
const internal::FileSpan & | at, | ||
const std::optional< CodeErrorContext > & | maybe_context = std::nullopt ) |
Definition at line 189 of file Diagnostics.cpp.
References helper(), makeContext(), and Ark::Utils::splitString().
Referenced by generate(), helper(), and makeContextWithNode().
void Ark::Diagnostics::hintWithContext | ( | std::ostream & | os, |
const std::optional< CodeErrorContext > & | maybe_context, | ||
const bool | colorize ) |
Definition at line 25 of file Diagnostics.cpp.
References Ark::Diagnostics::Printer::GhostLinePrefix.
Referenced by makeContext().
|
nodiscard |
Definition at line 15 of file PrettyPrinting.cpp.
Referenced by colorizeLine().
void Ark::Diagnostics::makeContext | ( | const ErrorLocation & | loc, |
std::ostream & | os, | ||
const std::optional< CodeErrorContext > & | maybe_context, | ||
bool | colorize ) |
Helper to create a colorized context to report errors to the user.
loc | error location |
os | stream in which the error will be written |
maybe_context | optional context, parent of the error |
colorize | generate colors or not |
Definition at line 43 of file Diagnostics.cpp.
References Ark::internal::FilePos::column, Ark::Diagnostics::Printer::coversLine(), Ark::Diagnostics::Printer::current(), Ark::Diagnostics::Printer::currentLine(), Ark::Diagnostics::ErrorLocation::end, Ark::Diagnostics::Printer::extendWindow(), Ark::Diagnostics::ErrorLocation::filename, Ark::Diagnostics::Printer::GhostLinePrefix, Ark::Diagnostics::Printer::hasContent(), hintWithContext(), Ark::Diagnostics::Printer::isTargetLine(), Ark::internal::FilePos::line, Ark::Diagnostics::ErrorLocation::maybeEndLine(), Ark::Diagnostics::Printer::printLine(), showFileLocation(), Ark::Diagnostics::ErrorLocation::start, and Ark::Diagnostics::ErrorLocation::wholeLineIsError().
Referenced by Ark::VM::backtrace(), and helper().
std::string Ark::Diagnostics::makeContextWithNode | ( | const std::string & | message, |
const internal::Node & | node ) |
Helper used by the compiler to generate a colorized context from a node.
message | error message to be included in the context |
node | AST node with the error |
Definition at line 204 of file Diagnostics.cpp.
References Ark::internal::Node::filename(), helper(), and Ark::internal::Node::position().
Referenced by Ark::internal::ASTLowerer::warning().
void Ark::Diagnostics::showFileLocation | ( | std::ostream & | os, |
const ErrorLocation & | loc ) |
Definition at line 19 of file Diagnostics.cpp.
References ARK_NO_NAME_FILE, Ark::Diagnostics::ErrorLocation::filename, Ark::internal::FilePos::line, and Ark::Diagnostics::ErrorLocation::start.
Referenced by makeContext().