#include #include "mrk/parser_internal.h" const char *unexpected_path_msg = "You should never see this error; please report it."; mrk_parser_err mrk_parser_err_code(mrk_parser *parser) { return parser->error.code; } const char *mrk_parser_err_msg(mrk_parser *parser) { switch (parser->error.code) { case mrk_parser_err_ok: parser->error.buf[0] = '\0'; break; case mrk_parser_err_unexpected_token: sprintf(parser->error.buf, "%lu:%lu: unexpected token type '%s' (%i)", parser->error.token.start_line + 1, parser->error.token.start_line_index + 1, mrk_token_type_names[parser->error.token.type], parser->error.token.type); break; case mrk_parser_err_unexpected_eat: sprintf( parser->error.buf, "%lu:%lu: unexpected token, expected type '%s' (%i) but got '%s' (%i)", parser->error.token.start_line + 1, parser->error.token.start_line_index + 1, mrk_token_type_names[parser->error.expected_token_type], parser->error.expected_token_type, mrk_token_type_names[parser->error.token.type], parser->error.token.type); break; case mrk_parser_unclosed_brackets: sprintf(parser->error.buf, "%lu:%lu: unclosed bracket", parser->error.token.start_line + 1, parser->error.token.start_line_index + 1); break; case mrk_parser_unexpected_path: return unexpected_path_msg; } return parser->error.buf; }