%{ #include #include "expr.h" extern int yylex(void); extern int yyerror(const char *s); static void breakpoint(void) { } %} %token INTEGER %token STRING %token '(' ')' %left MATCH MULTIPLICATION %left '+' '-' %left COMPARISON AND OR %start expr %% expr : STRING { } | INTEGER { } | '(' expr ')' { printf("a parenthesized expression\n"); } | expr MATCH expr { printf("match two\n"); } | expr MULTIPLICATION expr { printf("multiplicationish\n"); } | expr '+' expr { $$.u.i = $1.u.i + $3.u.i; printf("%d\n", $$.u.i); } | expr '-' expr { $$.u.i = $1.u.i - $3.u.i; printf("%d\n", $$.u.i); } | expr COMPARISON expr { printf("compare\n"); } | expr AND expr { printf("and\n"); } | expr OR expr { printf("or\n"); } ;