1 %{
2 #include <stdlib.h>
3 #include "parser.tab.h" // generated by bison; includes macros, tokens (e.g. NUMBER)
4 extern int yylval; // necessary for grammar variables
5 %}
6
7 %%
8
9 "+" |
10 "-" |
11 "*" |
12 "/" |
13 "(" |
14 ")" |
15 "%" { return yytext[0]; }
16 "\n" { return yytext[0]; }
17
18 [0-9]+ { yylval = atoi(yytext);
19 return NUMBER; }