Remove building with NOCRYPTO option
[minix3.git] / external / bsd / flex / dist / examples / manual / expr.y
blob1ac3092c99c49225d17a340d9ff3606a9a1315f5
1 /*
2 * expr.y : A simple yacc expression parser
3 * Based on the Bison manual example.
4 */
6 %{
7 #include <stdio.h>
8 #include <math.h>
12 %union {
13 float val;
16 %token NUMBER
17 %token PLUS MINUS MULT DIV EXPON
18 %token EOL
19 %token LB RB
21 %left MINUS PLUS
22 %left MULT DIV
23 %right EXPON
25 %type <val> exp NUMBER
28 input :
29 | input line
32 line : EOL
33 | exp EOL { printf("%g\n",$1);}
35 exp : NUMBER { $$ = $1; }
36 | exp PLUS exp { $$ = $1 + $3; }
37 | exp MINUS exp { $$ = $1 - $3; }
38 | exp MULT exp { $$ = $1 * $3; }
39 | exp DIV exp { $$ = $1 / $3; }
40 | MINUS exp %prec MINUS { $$ = -$2; }
41 | exp EXPON exp { $$ = pow($1,$3);}
42 | LB exp RB { $$ = $2; }
47 yyerror(char *message)
49 printf("%s\n",message);
52 int main(int argc, char *argv[])
54 yyparse();
55 return(0);