%{ #include "toy.tab.h" extern int yylval; %} %% [0-9]+ { yylval = atoi(yytext); return NUMBER; } [ \t] { /* ignore whitespace */ } \n { return 0; } . { return yytext[0]; } %% void yyerror( const char *message ) { fprintf( stderr, "%s: at '%s'\n", message, yytext ); } int main() { while( !yyparse() ) { } return 0; }