ilya
serr 2025-05-13 14:06:45 +03:00
parent 433de4d309
commit cb3527a247
2 changed files with 7 additions and 6 deletions

View File

@ -3,7 +3,12 @@
#include <stdio.h>
#include <string.h>
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);
}
%}

View File

@ -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");