I'm OCaml newbie and I'm trying to write a simple OCaml-like grammar, and I can't figure this out. My grammar allows something like this:
let sub = fun x -> fun y -> x - y;;
However, if I want to use the function so defined, I can write: (sub 7) 3
but I can't write sub 7 3
, which really bugs me. For some reason, it gets interpreted as if I wrote sub (7 3)
(which would treat 7
as a function with argument 3
). The relevant sections are:
/* other operators, then at the very end: */
%left APPLY
/* ... */
expr:
/* ... */
| expr expr %prec APPLY { Apply($1, $2) }
Thanks!