I read at ocamlyacc - Dune documentation that the extra text should be (ocamlyacc my_parser).
I first tried to add that extra command inside the library stanza, as follows :
The latter one is the correct syntax, but I think you should explain more about your project setup. The error message mentions a lib/ folder, but where does your dune file live?
Maybe you can even provide a small example to reproduce?
My dune setup is very basic. The main root directory contains a default dune-project file, and a lib subdirectory which contains the dune file which I have shown above. That’s it. There are several sub-directories and sub-sub-directories and so on in lib, but none of them contain a dune-related file.
The my_parser.mly file is in some sub-sub-(…) directory of lib (which are not mentioned in the error message, which makes sense because of the include_subdirs unqualified directive).
If so, I need to understand why dune gives me this No rule found message. By the way, putting “No rule found” or “no rule found error”
in the search field produces only unrelated results in the dune doc.
Yes, so this is the issue. If you have ocamlyacc foo then dune expects foo.mly to be in the same folder as the dune file.
This is why the error message says that there’s no rule to build lib/my_parser.mly because there’s neither a source file there nor a rule that would create a source file in that location.
Give it a try but personally I would create a dune file with (ocamlyacc my_parser) in the same folder as the my_parser.mly if you want to preserve the directory layout that you have.
Indeed, my idea fails with the error message Error: “blah/blah/my_parser.mli” does not denote a file in the current directory. Your idea works though, thanks !