Skip to content

include_subdirs + ocamllex + menhir #1372

@Niols

Description

@Niols

Hello,

I was trying today to split a project in several subdirectories behaving as if they were one (Because of a dependency, we cannot split in one module per subdirectory). So I tried using the (include_subdirs unqualified) stanza.

But then I got lost trying to tell Dune how to compile my lexer and parser (ocamllex and manhir). This is basically the structure that causes the problem:

src
├── dir
│   ├── dune
│   ├── lexer.mll
│   └── parser.mly
├── dune
└── main.ml

where src/dune contains:

(include_subdirs unqualified)

(executable
 (name main)
 (public_name sdkjfbh)
 (flags :standard -w -27-33))

and src/dir/dune contains:

(ocamllex lexer)
(menhir (modules parser))

With that architecture, I get the following error when trying to dune build:

Error: I can't determine what library/executable the files produced by this stanza are part of.

I have tried several things to solve my problem:

  • adding a (include_subdirs unqualified) stanza to src/dir/dune, but this hides the modules from src/dir to the others (which is the expected behaviour, but I had to try)

  • moving the (menhir ...) stanza to src/dune using a qualified path: (menhir (modules dir/parser)). In that case, I get Error: Unbound module Parser in lexer.mll (when lexer.mll has a dependency in parser.mly, in order to use the token type for instance`).

  • moving both the stanzas in src/dune. But then, I get Error: No rule found for lexer.mll and Error: No rule found for parser.mly. If I use a qualified path for the parser, I get rid of the latter but nor the former. And I can't use a qualified path for the lexer without getting Error: dir/lexer.ml does not denote a file in the current directory.

Is there something I didn't try? Is there a way to do this at all? Thank you by advance :-) and I hope I'm not just adding noise

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