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
#1149, @emillon)
- Fix parsing `ocamllex` stanza in jbuild files (#1150, @rgrinberg)
1.1.1 (08/08/2018)
------------------

View File

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

View File

@ -570,6 +570,14 @@
test-cases/ocamldep-multi-stanzas
(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
(name odoc)
(deps (package dune) (source_tree test-cases/odoc))
@ -875,6 +883,7 @@
(alias ocaml-config-macro)
(alias ocaml-syntax)
(alias ocamldep-multi-stanzas)
(alias ocamllex-jbuild)
(alias odoc)
(alias odoc-unique-mlds)
(alias output-obj)
@ -970,6 +979,7 @@
(alias ocaml-config-macro)
(alias ocaml-syntax)
(alias ocamldep-multi-stanzas)
(alias ocamllex-jbuild)
(alias output-obj)
(alias package-dep)
(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