diff --git a/source/main.c b/source/main.c index 70d7eb3..24d6214 100644 --- a/source/main.c +++ b/source/main.c @@ -14,6 +14,18 @@ char * language = NULL; char * verbatim = NULL; char * top = NULL; +void yyerror(const char * const fmt, ...) { + extern int yylineno; + va_list args; + va_start(args, fmt); + + fprintf(stderr, "%s:%d: error: ", input_file_name, yylineno); + vfprintf(stderr, fmt, args); + fputc('\n', stderr); + + va_end(args); +} + void put_rule_table(const char * const name, rule_type_t type_mask) { char * sprint_buffer; int sprint_r; diff --git a/source/tbsp.y b/source/tbsp.y index 6e029ea..3d693c4 100644 --- a/source/tbsp.y +++ b/source/tbsp.y @@ -1,7 +1,7 @@ %{ #include "tbsp.yy.h" - void yyerror([[maybe_unused]] const char * const s); + void yyerror(const char * const s, ...); extern char * language; extern char * top; @@ -110,10 +110,6 @@ code_section rule_vector_t rules; -void yyerror(const char * const s) { - printf("error: %s", s); -} - void tbsp_tab_init(void) { kv_init(rules); }