Merge pull request #1150 from rgrinberg/ocamllex-jbuild

Correctly parse ocamllex in jbuild
This commit is contained in:
Rudi Grinberg 2018-08-20 20:09:18 +03:00 committed by GitHub
commit 5b6496fac1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 51 additions and 12 deletions

View File

@ -17,6 +17,9 @@ next
- Improve error message for `dune utop` without a library name (#1154, fix - Improve error message for `dune utop` without a library name (#1154, fix
#1149, @emillon) #1149, @emillon)
- Fix parsing `ocamllex` stanza in jbuild files (#1150, @rgrinberg)
1.1.1 (08/08/2018) 1.1.1 (08/08/2018)
------------------ ------------------

View File

@ -1485,18 +1485,19 @@ module Rule = struct
} }
let ocamllex_jbuild = let ocamllex_jbuild =
enter peek_exn >>= function
(if_list | List (_, Atom (_, _) :: _) ->
~then_:( enter (
record repeat string >>| fun modules ->
(let%map modules = field "modules" (list string) { modules
and mode = Mode.field in ; mode = Standard
{ modules; mode })) }
~else_:( )
repeat string >>| fun modules -> | _ ->
{ modules record
; mode = Standard (let%map modules = field "modules" (list string)
})) and mode = Mode.field in
{ modules; mode })
let ocamllex_dune = let ocamllex_dune =
if_eos if_eos

View File

@ -570,6 +570,14 @@
test-cases/ocamldep-multi-stanzas test-cases/ocamldep-multi-stanzas
(progn (run %{exe:cram.exe} -test run.t) (diff? run.t run.t.corrected))))) (progn (run %{exe:cram.exe} -test run.t) (diff? run.t run.t.corrected)))))
(alias
(name ocamllex-jbuild)
(deps (package dune) (source_tree test-cases/ocamllex-jbuild))
(action
(chdir
test-cases/ocamllex-jbuild
(progn (run %{exe:cram.exe} -test run.t) (diff? run.t run.t.corrected)))))
(alias (alias
(name odoc) (name odoc)
(deps (package dune) (source_tree test-cases/odoc)) (deps (package dune) (source_tree test-cases/odoc))
@ -875,6 +883,7 @@
(alias ocaml-config-macro) (alias ocaml-config-macro)
(alias ocaml-syntax) (alias ocaml-syntax)
(alias ocamldep-multi-stanzas) (alias ocamldep-multi-stanzas)
(alias ocamllex-jbuild)
(alias odoc) (alias odoc)
(alias odoc-unique-mlds) (alias odoc-unique-mlds)
(alias output-obj) (alias output-obj)
@ -970,6 +979,7 @@
(alias ocaml-config-macro) (alias ocaml-config-macro)
(alias ocaml-syntax) (alias ocaml-syntax)
(alias ocamldep-multi-stanzas) (alias ocamldep-multi-stanzas)
(alias ocamllex-jbuild)
(alias output-obj) (alias output-obj)
(alias package-dep) (alias package-dep)
(alias path-variables) (alias path-variables)

View File

@ -0,0 +1,8 @@
{}
rule f = parse
| _ { () }
{
print_endline "bar"
}

View File

@ -0,0 +1,8 @@
{}
rule f = parse
| _ { () }
{
print_endline "foo"
}

View File

@ -0,0 +1,7 @@
(ocamllex
((modules (foo))))
(ocamllex (bar))
(executable
((name foo)))

View File

@ -0,0 +1,2 @@
$ dune exec ./foo.exe
foo