19namespace ErrorHandling {
32 const std::string& source_file,
36 const std::string& msg,
37 const std::vector<std::string>& include_chain,
38 std::shared_ptr<bpp::bpp_program> program,
40 bool is_warning =
false);
43 const std::vector<AST::ParserError>& errors,
44 const std::string& source_file,
45 const std::vector<std::string>& include_chain,
46 std::shared_ptr<bpp::bpp_program> program,
57 std::shared_ptr<bpp::bpp_program>
program;
61 template <bpp::detail::ErrorReportableListener Listener, bpp::detail::ASTNodePtrORToken T>
65 program = listener->get_program();
70 line = error_ctx->getPosition().line;
71 column = error_ctx->getPosition().column;
72 if (error_ctx->getEndPosition().line == error_ctx->getPosition().line) {
73 text_length = error_ctx->getEndPosition().column - error_ctx->getPosition().column;
76 line = error_ctx.getLine();
77 column = error_ctx.getCharPositionInLine();
78 text_length =
static_cast<uint32_t
>(error_ctx.getValue().length());
82 line = error_ctx.getLine();
83 column = error_ctx.getCharPositionInLine();
84 auto param = error_ctx.getValue();
86 if (param.type.has_value()) {
87 text_length += 1 +
static_cast<uint32_t
>(param.type.value().getValue().length());
89 text_length += 1 +
static_cast<uint32_t
>(param.name.getValue().length());
91 text_length =
static_cast<uint32_t
>(param.name.getValue().length());
99 template <bpp::detail::ErrorReportableListener Listener, bpp::detail::ASTNodePtrORToken T>
100 inline ErrorOrWarning(Listener* listener,
const T& error_ctx,
const std::string& msg) : std::runtime_error(msg) {
132 template <bpp::detail::ErrorReportableListener Listener, bpp::detail::ASTNodePtrORToken T>
150 explicit Warning(
const std::string& msg) =
delete;
152 template <bpp::detail::ErrorReportableListener Listener, bpp::detail::ASTNodePtrORToken T>
153 inline Warning(Listener* listener,
const T& error_ctx,
const std::string& msg) :
ErrorOrWarning(listener, error_ctx, msg) {
160std::string
utf8_substr(
const std::string& str, uint32_t start, uint32_t length);
Definition SyntaxError.h:50
uint32_t text_length
Definition SyntaxError.h:55
uint32_t line
Definition SyntaxError.h:53
bool lsp_mode
Definition SyntaxError.h:58
ErrorOrWarning(const std::string &msg)=delete
void set_from_listener(Listener *listener, T error_ctx)
Definition SyntaxError.h:62
std::shared_ptr< bpp::bpp_program > program
Definition SyntaxError.h:57
ErrorOrWarning(Listener *listener, const T &error_ctx, const std::string &msg)
Definition SyntaxError.h:100
uint32_t column
Definition SyntaxError.h:54
bool is_warning
Definition SyntaxError.h:59
void print() const
Definition SyntaxError.h:104
std::vector< std::string > include_chain
Definition SyntaxError.h:56
std::string source_file
Definition SyntaxError.h:52
An exception thrown when a syntax error is encountered This exception can be constructed from any lis...
Definition SyntaxError.h:127
SyntaxError(Listener *listener, const T &error_ctx, const std::string &msg)
Definition SyntaxError.h:133
SyntaxError(const std::string &msg)=delete
A compiler warning that is not fatal to compilation This type should never be thrown....
Definition SyntaxError.h:147
Warning(const std::string &msg)=delete
Warning(Listener *listener, const T &error_ctx, const std::string &msg)
Definition SyntaxError.h:153
uint32_t utf8_length(const std::string &str)
Definition SyntaxError.cpp:174
std::string equal_width_padding(const std::string &str, char padding_char)
Definition SyntaxError.cpp:188
void print_parser_errors(const std::vector< AST::ParserError > &errors, const std::string &source_file, const std::vector< std::string > &include_chain, std::shared_ptr< bpp::bpp_program > program, bool lsp_mode)
Definition SyntaxError.cpp:118
void print_syntax_error_or_warning(const std::string &source_file, uint32_t line, uint32_t column, uint32_t text_length, const std::string &msg, const std::vector< std::string > &include_chain, std::shared_ptr< bpp::bpp_program > program, bool lsp_mode, bool is_warning)
Print a syntax error or warning message to stderr.
Definition SyntaxError.cpp:23
std::string utf8_substr(const std::string &str, uint32_t start, uint32_t length)
Definition SyntaxError.cpp:145
Definition bash_case.cpp:9