Using external type declarations with OCamlyacc

Viewed 1872

I have a type expr in an expr.ml file. In parser.mly (OCamlyacc file), I define the expr rule and give the type :

    %start expr
    %type <expr> expr

However, I get :

    File "parser.mli", line 34, characters 48-52:
    Error: Unbound type constructor expr

I tried adding

    %{
      open Expr
    %}

at the beginning of the .mly file but it still doesn't work. How may I define this expr type in an external file and use it as the return value of my rule? Thanks.

3 Answers
Related