OCamlPro / drom

drom is a wrapper over opam/dune in an attempt to provide a cargo-like user experience. It can be used to create full OCaml projects with sphinx and odoc documentation. It has specific knowledge of Github and will generate files for Github Actions CI and Github pages.
https://ocamlpro.github.io/drom
Other
184 stars 21 forks source link

Menhir handling #199

Open Ninjapouet opened 1 year ago

Ninjapouet commented 1 year ago

Following the PR https://github.com/OCamlPro/drom/pull/197, I suppose it would be nice to have a proper support to menhir as OCaml is often used DSL developments. I may suggest adding to package.toml something like

[menhir]
version = "X.Y"
tokens = {filename = "<filename>"; flags = "<flags>"}
parser = {filename = "<filename>"; flags = "<flags>"}

which would toggle the (use menhir "X.Y") in dune-project and generate the (menhir ...) stanzas according to the PR recommandations.

lefessan commented 1 year ago

In another project, I found:

dune-trailer = """(menhir (modules preproc_tokens grammar_common preproc_grammar)
        (merge_into preproc_grammar)
        (flags --table --external-tokens Preproc_tokens))
(menhir (modules preproc_tokens)
        (flags --only-tokens))
"""
lefessan commented 1 year ago

and worse:

(menhir (modules grammar_tokens grammar_common grammar)
        (merge_into grammar)
        (flags --inspection --cmly --table
           --external-tokens Grammar_tokens
           --unused-tokens))

(menhir (modules grammar_tokens)
        (flags --inspection --table --only-tokens))

(rule
  (targets text_keywords.ml)
  (enabled_if (<> %{profile} "release"))
  (deps    grammar.cmly)
  (mode    promote)
  (action
    (with-stdout-to %{targets}
       (run %{exe:./keywords/gen_keywords.exe} %{deps}
            --external-tokens Grammar_tokens))))

(rule
  (targets grammar_recover.ml)
  (enabled_if (<> %{profile} "release"))
  (deps    grammar.cmly)
  (mode    promote)
  (action
    (with-stdout-to %{targets}
       (run %{exe:./recover/gen_recover.exe} %{deps}))))

(rule
  (targets grammar_contexts.ml)
  (enabled_if (<> %{profile} "release"))
  (deps grammar.cmly)
  (mode promote)
  (action
    (with-stdout-to %{targets}
      (run %{exe:./context/gen_contexts.exe} %{deps}
        --external-tokens Grammar_tokens))))

(rule
  (targets grammar_context.ml)
  (enabled_if (<> %{profile} "release"))
  (deps    grammar.cmly)
  (mode    promote)
  (action
    (with-stdout-to %{targets}
       (run %{exe:./context/gen_context.exe} %{deps}))))

(rule
  (targets grammar_printer.ml)
  (enabled_if (<> %{profile} "release"))
  (deps    grammar.cmly)
  (mode    promote)
  (action
    (with-stdout-to %{targets}
       (run %{exe:./printer/gen_printer.exe} %{deps}))))
lefessan commented 1 year ago

Ok, the last rules are probably not really related to menhir itself, but use merlin stuff built for it...