| 1 |
Test the ability of `(modules ..)` to contain dynamic forms such as |
| 2 |
`(:include)` and variables such as `%{read-lines:...}` in the `ocamlyacc` |
| 3 |
stanza. |
| 4 |
|
| 5 |
$ make_dune_project 3.22 |
| 6 |
|
| 7 |
$ mkdir -p gen |
| 8 |
|
| 9 |
We define rules that create files (in the syntax expected by `modules`) that |
| 10 |
each contain a single module name: |
| 11 |
|
| 12 |
$ cat >gen/dune <<EOF |
| 13 |
> (rule (with-stdout-to lst (echo my_parser))) |
| 14 |
> EOF |
| 15 |
|
| 16 |
`.mly` unit present in the working tree. `lib.ml` references it |
| 17 |
|
| 18 |
$ cat >my_parser.mly <<'EOF' |
| 19 |
> %token EOF |
| 20 |
> %start main |
| 21 |
> %type <unit> main |
| 22 |
> %% |
| 23 |
> main: |
| 24 |
> | EOF { () } |
| 25 |
> EOF |
| 26 |
|
| 27 |
$ cat >lib.ml <<'EOF' |
| 28 |
> let _ = My_parser.main |
| 29 |
> EOF |
| 30 |
|
| 31 |
The `ocamlyacc` stanza uses `%{read-lines:..}` inside the `(modules ..)` field: |
| 32 |
|
| 33 |
$ cat >dune <<EOF |
| 34 |
> (library |
| 35 |
> (name lib)) |
| 36 |
> (ocamlyacc |
| 37 |
> (modules %{read-lines:gen/lst})) |
| 38 |
> EOF |
| 39 |
|
| 40 |
$ dune build lib.cma |