Hey
I am currently working on a prototype for a parser generator in OCaml. If I have a grammar description in a file parser.abc I can generate an .ml file with the actual parser code like so:
abc parser.abc -o parser
This will generate the file parser.ml. 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 parser.abc. I have tried the following:
(rule
(target parser)
(deps parser.abc)
(action (run abc %{deps} -o %{target}))))
(ocamllex
(modules lexer)
(enabled_if %{read:parser.ml}))
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!