TL;DR
I am working with dune
and have the option (include_subdirs qualified)
.
I’m trying to move the files related to parsing (Syntax.mly
, Ast.ml
, Tokens.mll
) to a subdirectory Parsing
. Unfortunately Ast.ml
specifically is not found when building and I can’t figure out why.
Details
My original project structure was
--- lib/
|--- dune
|--- Ast.ml
|--- Syntax.mly
|--- Tokens.mll
'--- ...
with
;; lib/dune
...
(include_subdirs qualified)
(ocamllex Tokens)
(menhir (modules Syntax))
(* lib/Syntax.mly *)
%{ open Ast }%
...
This works but is unsatisfactory.
My current project structure is
--- lib/
|--- dune
|--- Ast.ml
|--- Parsing/
| |--- dune
| |--- Syntax.mly
| '--- Tokens.mll
'--- ...
with
;; lib/dune
...
(include_subdirs qualified)
;; lib/Parsing/dune
(ocamllex Tokens)
(menhir (modules Syntax))
(* lib/Parsing/Syntax.mly *)
%{ open Ast }%
...
This still works.
My desired project structure is
--- lib/
|--- dune
|--- Parsing/
| |--- dune
| |--- Ast.ml
| |--- Syntax.mly
| '--- Tokens.mll
'--- ...
with
;; lib/dune
...
(include_subdirs qualified)
;; lib/Parsing/dune
(ocamllex Tokens)
(menhir (modules Syntax))
(* lib/Parsing/Syntax.mly *)
%{ open ??? }%
...
but I don’t know what to put in place of ???
in lib/Parsing/Syntax.mly
to make this build.
If I open Ast
then I get
File "lib/Parsing/Syntax.mly", line 2, characters 9-12:
Error: Unbound module Ast
while if I try open Parsing.Ast
then I get instead
Error: Dependency cycle between:
_build/default/lib/Parsing/Syntax__mock.mli.inferred
-> _build/default/lib/Parsing/Syntax.mli
-> _build/default/lib/.demo.objs/parsing__Syntax.intf.d
-> _build/default/lib/.demo.objs/parsing__Syntax.intf.all-deps
-> _build/default/lib/.demo.objs/parsing__Tokens.impl.all-deps
-> _build/default/lib/.demo.objs/Syntax__mock.impl.all-deps
-> _build/default/lib/Parsing/Syntax__mock.mli.inferred
-> required by alias lib/Parsing/all
-> required by alias default
Is there a way to refer to files in the current subdirectory in the .mly
?
Related (?) resources
Threads that seem related but actually don’t address this specific issue:
(include_subdirs qualified)
clashes with nested Menhir parsers (this concerns the stanza, not the code itself)- include_subdirs + ocamllex + menhir (unqualified)
1 post - 1 participant