Reputation: 5490
I have a big project built with traditional makefile. I would like to add a mechanism of error handling like this project to my project.
In the sample project, a module UnitActionsParser
is generated by the following rules of dune:
;; The following two rules create a copy of the file parser.mly named
;; unitActionsParser.mly. This is a copy of the grammar where the semantic
;; actions have been removed and replaced with unit values. It is compiled
;; by Menhir's table back-end to obtain the module UnitActionsParser.
;; The use of [--external-tokens Parser] is required for the two parsers
;; to share a single [token] type. This makes them usable with the same
;; lexer.
(rule
(action
(with-stdout-to unitActionsParser.mly
(run menhir
%{dep:parser.mly}
--only-preprocess-u
))))
(menhir
(modules unitActionsParser)
(flags --table --external-tokens Parser)
)
At the moment, the makefile
of my project contains like:
OCAMLYACC= $(OCAMLPREFIX)menhir -v
%.ml %.mli: %.mly
$(OCAMLYACC) $*.mly
So now, I'm wondering how to build such a UnitActionsParser
module. The best would be to modify my makefile
, does anyone know how to do that? Otherwise, we could also add it manually in the first place. I tried in the command line $ menhir --table --external-tokens Parser
, but it returned me Usage: menhir <options> <filenames>
. Could anyone help?
Upvotes: 1
Views: 246
Reputation: 18902
You can add the rule directly to your Makefile. The direct translation of the dune
file would be
unitActionsParser.mly: parser.mly
$(OCAMLYACC) --only-preprocess-u $< > $@
Upvotes: 2