Skip to content

jbuilder doesn't support menhir with --infer #305

@vsiles

Description

@vsiles

Hi ! I'm trying to move from ocamlbuild to jbuilder, but I can't invoke menhir with the --infer flag:

$ jbuilder build foobar.exe
      menhir parser.{ml,mli} (exit 1)
(cd _build/default && .../menhir --infer --explain parser.mly)
File "parser.mly", line 3, characters 13-19
Error: Unbound module Syntax

The following configuration

(menhir
 ((flags (--explain))
  (modules (parser))))

(ocamllex (lexer))

(executable
    ((name foobar)
     (libraries (core))))

works but

(menhir
 ((flags (--infer --explain))
  (modules (parser))))

(ocamllex (lexer))
(executable
    ((name foobar)
     (libraries (core))))

doesn't.

The issue is described in menhir manual: by using --infer, some calls to ocamlc are done to typecheck the file, so some modules have to be compiled before the parser. It is advised to use --depend to get the correct dependencies.

For the record, my parser.mly starts with:

%{
  open Lexing
  module S = Syntax
%}

and I use S.Fobaar in the mly file (see here)
I'm using jbuilder 1.0+beta14 on ubuntu 16.04.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions