%{
#include <stdio.h>
#include <stdlib.h>
#include "y.tab.h" // Header generated by yacc
%}
%%
[0-9]+      { yylval = atoi(yytext); return NUMBER; }
[+]         { return PLUS; }
[-]         { return MINUS; }
[*]         { return MULTIPLY; }
[/]         { return DIVIDE; }
\n          { return EOL; }
[ \t]       ; // Ignore whitespace
.           { printf("Invalid character: %s\n", yytext); }
%%

int main() {
    printf("Enter a mathematical expression (e.g., 3 + 4):\n");
    if (yyparse() == 0) {
        printf("Parsed successfully!\n");
    } else {
        printf("Parsing failed.\n");
    }
    return 0;
}

int yyerror(char *s) {
    fprintf(stderr, "Error: %s\n", s);
    return 0;
}