Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Menhir handling #199

Open
Ninjapouet opened this issue Mar 13, 2023 · 3 comments
Open

Menhir handling #199

Ninjapouet opened this issue Mar 13, 2023 · 3 comments
Assignees
Labels
enhancement New feature or request

Comments

@Ninjapouet
Copy link

Following the PR #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.

@Ninjapouet Ninjapouet added the enhancement New feature or request label Mar 13, 2023
@Ninjapouet Ninjapouet self-assigned this Mar 13, 2023
@lefessan
Copy link
Member

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
Copy link
Member

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
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants