forked from ocaml/ocaml
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow building FLambda parser in Dune (#495)
Unfortunately, I couldn't find a nice way to regenerate `flambda_parser.ml`, etc. conditionally, which is important because it requires not just Menhir but precisely the correct version of Menhir (the same one the library was built with). So one has to change the mode from `fallback` to `promote` manually. But after that, you get all the benefits of `dune build -w` when editing the parser or lexer.
- Loading branch information
1 parent
960583e
commit 3bd0288
Showing
4 changed files
with
79 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
; Using user actions rather than (ocamllex) and (menhir) because the Makefile | ||
; runs ocamllex and menhir from this directory rather than the workspace root, | ||
; meaning the generated source is annotated with the bare filename. | ||
|
||
; These rules are disabled by default because you need precisely the correct | ||
; version of Menhir installed. Comment out (mode fallback) and uncomment (mode | ||
; promote) in each stanza if you make changes to the Flambda | ||
; parser. | ||
|
||
(rule | ||
(mode fallback) | ||
;(mode promote) | ||
(target flambda_lex.ml) | ||
(deps flambda_lex.mll) | ||
(action (run ocamllex -q %{deps}))) | ||
|
||
(rule | ||
(mode fallback) | ||
;(mode promote) | ||
(target flambda_parser.ml) | ||
(deps flambda_parser_in.ml) | ||
(action (with-stdin-from %{deps} | ||
(with-stdout-to %{target} | ||
(run sed "s/MenhirLib/CamlinternalMenhirLib/g"))))) | ||
|
||
(rule | ||
(mode fallback) | ||
;(mode promote) | ||
(target flambda_parser.mli) | ||
(deps flambda_parser_in.mli) | ||
(action (with-stdin-from %{deps} | ||
(with-stdout-to %{target} | ||
(run sed "s/MenhirLib/CamlinternalMenhirLib/g"))))) | ||
|
||
(rule | ||
(targets flambda_parser_in.ml | ||
flambda_parser_in.mli) | ||
(deps flambda_parser.mly) | ||
(action (run menhir --table %{deps} --base flambda_parser_in))) | ||
|
||
; NOTE: flambda_parser.messages is massively out of date. No need to activate | ||
; this rule unless you've fixed it (thanks!). | ||
(rule | ||
(mode fallback) | ||
;(mode promote) | ||
(target flambda_parser_messages.ml) | ||
(deps flambda_parser.messages flambda_parser.mly) | ||
(action (with-stdout-to %{target} | ||
(run menhir --compile-errors %{deps})))) | ||
|
||
(alias (name list-errors)) | ||
|
||
(rule | ||
(alias list-errors) | ||
(target flambda_parser.new-messages) | ||
(deps flambda_parser.mly) | ||
(mode promote) | ||
(action (with-stdout-to %{target} | ||
(run menhir --list-errors %{deps})))) | ||
|
||
(alias (name check-errors)) | ||
|
||
(rule | ||
(alias check-errors) | ||
(deps flambda_parser.mly | ||
flambda_parser.messages | ||
flambda_parser.new-messages) | ||
(action (run menhir flambda_parser.mly | ||
--compare-errors flambda_parser.messages | ||
--compare-errors flambda_parser.new-messages))) |