27 lines
424 B
Plaintext
27 lines
424 B
Plaintext
%{
|
|
#include "test.tab.h"
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
|
|
int CURRENT_LINE_NUMBER = 0;
|
|
|
|
void yyerror(const char *s) {
|
|
fprintf(stderr, "\033[91mError at line %i\033[0m", CURRENT_LINE_NUMBER);
|
|
exit(1);
|
|
}
|
|
|
|
%}
|
|
|
|
%%
|
|
"{" { return LBRACE; }
|
|
"}" { return RBRACE; }
|
|
\n { CURRENT_LINE_NUMBER++; }
|
|
[^{}]+ {
|
|
yylval.str = strdup(yytext);
|
|
return TEXT;
|
|
}
|
|
%%
|
|
|
|
int yywrap() {
|
|
return 1;
|
|
} |