start
parent
433de4d309
commit
cb3527a247
|
@ -3,7 +3,12 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.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);
|
||||||
|
}
|
||||||
|
|
||||||
%}
|
%}
|
||||||
|
|
||||||
|
|
|
@ -6,10 +6,7 @@
|
||||||
extern int CURRENT_LINE_NUMBER;
|
extern int CURRENT_LINE_NUMBER;
|
||||||
extern char *yytext;
|
extern char *yytext;
|
||||||
|
|
||||||
void yyerror(const char *s) {
|
extern void yyerror(const char *s);
|
||||||
fprintf(stderr, "\033[91mError at line %i\033[0m", CURRENT_LINE_NUMBER);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
extern int yylex();
|
extern int yylex();
|
||||||
extern FILE *yyin;
|
extern FILE *yyin;
|
||||||
%}
|
%}
|
||||||
|
@ -36,7 +33,6 @@ content:
|
||||||
%%
|
%%
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
CURRENT_LINE_NUMBER = 1;
|
|
||||||
|
|
||||||
if (argc > 1) {
|
if (argc > 1) {
|
||||||
FILE *f = fopen(argv[1], "r");
|
FILE *f = fopen(argv[1], "r");
|
||||||
|
|
Loading…
Reference in New Issue