%{ #include int yylex(void); void yyerror(char *) }% %token INTEGER %% program: program expr '\n' {printf("%d\n",$2);} | ; expr: INTEGER {$$ = $1;} | expr '+' expr {$$ = $1 + $2;} | expr '-' expr {$$ = $1 -$2;} ; %% void yyerror(char *S) { fprintf(stderr,"%s\n",S); }