inline-test.opp.exp 695 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13
Warning: you are using the standard library and/or the %inline keyword. We
recommend switching on --infer in order to avoid obscure type error messages.
%start prog
%token <int> INT
%token EOF
%token PLUS
%token TIMES
%left PLUS 
%left TIMES 
%type <int> prog
%%

prog:
14 15
| x = exp _2 = EOF
    {                ( x )}
16 17 18

exp:
| x = INT
19 20
    {                     ( x )}
| lhs = exp _10 = PLUS rhs = exp
21
    {let op =
22
  let _1 = _10 in
23
                   ( fun x y -> x + y )
24
in
25 26
                                    ( op lhs rhs )}
| lhs = exp _10 = TIMES rhs = exp
27
    {let op =
28
  let _1 = _10 in
29
                    ( fun x y -> x * y )
30
in
31
                                    ( op lhs rhs )}
32 33 34 35 36

%%