%{ #include "polynomials.tab.h" #include void yyerror(const char *s); %} %option noyywrap %% [ \t]+ { /* skip whitespace */ } \n { return 0; /* EOF */ } [0-9]+ { yylval.num = atoi(yytext); return NUMBER; } [a-zA-Z] { yylval.var = yytext[0]; return VARIABLE; } "+" { return PLUS; } "-" { return MINUS; } "*" { return MULTIPLY; } "(" { return LPAREN; } ")" { return RPAREN; } . { yyerror("Unexpected character"); } %%