diff --git a/analyzers/test/test.l b/analyzers/test/test.l index 3cb7338..76e5112 100644 --- a/analyzers/test/test.l +++ b/analyzers/test/test.l @@ -3,7 +3,12 @@ #include #include -int CURRENT_LINE_NUMBER; +int CURRENT_LINE_NUMBER = 0; + +void yyerror(const char *s) { + fprintf(stderr, "\033[91mError at line %i\033[0m", CURRENT_LINE_NUMBER); + exit(1); +} %} diff --git a/analyzers/test/test.y b/analyzers/test/test.y index 3c4989c..186576f 100644 --- a/analyzers/test/test.y +++ b/analyzers/test/test.y @@ -6,10 +6,7 @@ extern int CURRENT_LINE_NUMBER; extern char *yytext; -void yyerror(const char *s) { - fprintf(stderr, "\033[91mError at line %i\033[0m", CURRENT_LINE_NUMBER); - exit(1); -} +extern void yyerror(const char *s); extern int yylex(); extern FILE *yyin; %} @@ -36,7 +33,6 @@ content: %% int main(int argc, char **argv) { - CURRENT_LINE_NUMBER = 1; if (argc > 1) { FILE *f = fopen(argv[1], "r");