Dependency cycle problem

Hey :slight_smile:

I am currently working on a prototype for a parser generator in OCaml. If I have a grammar description in a file I can generate an .ml file with the actual parser code like so:

abc -o parser

This will generate the file All of this works fine as long as I do it manually on the command line. Now I want to integrate it with dune to automate the generation of the .ml file. In my current setup, I have a lexer in lexer.mll and the grammar in I have tried the following:

(target parser)
(action (run abc %{deps} -o %{target}))))

(modules lexer)
(enabled_if %{}))

However, this results in:

Error: Dependency cycle between:
Computing directory contents of _build/default/examples/arith
→ %{read:parser} at examples/arith/dune:12
→ Computing directory contents of _build/default/examples/arith

Now I have also tried to put the grammar into a different directory and use a subdir stanza, however, that still did not work. Is there a way of specifying the order in which the different stanzas shall be invoked?

Thanks for any input!

You don’t need the enabled_if: the ocamllex stanza only generates the lexer code and does not compile it, so it does not need to have access to will only be necessary in order to compile the generated code in, and then the dependencies will be found automatically by Dune so you won’t have to write anything special for it.


That worked like a charm! Thank you :slight_smile: