%{ #include "test.tab.h" #include #include 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; }