%{ #include #include #include "proj1.tab.h" #define ERROR 13 int mylineno = 1; void yyerror(const char *msg); %} %% char { return CHAR; } else { return ELSE; } \n { mylineno++; } . { /* Ignore everything else */ } %% void yyerror(const char *msg) { printf("// ERROR : %s on line %d at %s\n", msg, mylineno, yytext); } // yyerror