ArkScript
A small, fast, functional and scripting language for video games
|
Classes | |
struct | LineColorContextCounts |
Functions | |
ARK_API void | makeContext (std::ostream &os, const std::string &code, std::size_t target_line, std::size_t col_start, std::size_t sym_size, bool colorize) |
Helper to create a colorized context to report errors to the user. | |
ARK_API 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. | |
bool | isPairableChar (const char c) |
void | colorizeLine (const std::string &line, LineColorContextCounts &line_color_context_counts, std::ostream &ss) |
template<typename T > | |
void | helper (std::ostream &os, const std::string &message, const bool colorize, const std::string &filename, const std::string &code, const T &expr, const std::size_t line, std::size_t column, const std::size_t sym_size) |
void Ark::Diagnostics::colorizeLine | ( | const std::string & | line, |
LineColorContextCounts & | line_color_context_counts, | ||
std::ostream & | ss ) |
Definition at line 29 of file Exceptions.cpp.
References isPairableChar(), Ark::Diagnostics::LineColorContextCounts::open_curly_braces, Ark::Diagnostics::LineColorContextCounts::open_parentheses, and Ark::Diagnostics::LineColorContextCounts::open_square_braces.
Referenced by makeContext().
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 170 of file Exceptions.cpp.
References ARK_NO_NAME_FILE, Ark::CodeError::col, Ark::CodeError::expr, Ark::CodeError::filename, helper(), Ark::CodeError::line, Ark::Utils::readFile(), and Ark::CodeError::symbol.
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 std::string & | code, | ||
const T & | expr, | ||
const std::size_t | line, | ||
std::size_t | column, | ||
const std::size_t | sym_size ) |
Definition at line 133 of file Exceptions.cpp.
References ARK_NO_NAME_FILE, helper(), makeContext(), and Ark::Utils::splitString().
Referenced by generate(), helper(), and makeContextWithNode().
|
inline |
Definition at line 24 of file Exceptions.cpp.
Referenced by colorizeLine().
void Ark::Diagnostics::makeContext | ( | std::ostream & | os, |
const std::string & | code, | ||
std::size_t | target_line, | ||
std::size_t | col_start, | ||
std::size_t | sym_size, | ||
bool | colorize ) |
Helper to create a colorized context to report errors to the user.
os | stream in which the error will be written |
code | content of the source file where the error is |
target_line | line where the error is |
col_start | where the error starts on the given line |
sym_size | bad expression that triggered the error |
colorize | generate colors or not |
Definition at line 86 of file Exceptions.cpp.
References colorizeLine(), and Ark::Utils::splitString().
Referenced by 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 148 of file Exceptions.cpp.
References ARK_NO_NAME_FILE, Ark::internal::Node::col(), Ark::internal::Node::filename(), helper(), Ark::internal::Node::isStringLike(), Ark::internal::Node::line(), Ark::Utils::readFile(), Ark::internal::Node::repr(), and Ark::internal::Node::string().
Referenced by Ark::internal::Compiler::compilerWarning().