From: Philippe Veber <philippe.veber@gmail.com>
To: caml users <caml-list@inria.fr>
Subject: [Caml-list] Using menhir for a camlp4 quotation: a compilation issue
Date: Thu, 20 Sep 2012 15:45:21 +0200 [thread overview]
Message-ID: <CAOOOohR+2sOk-_xgLzy7g2d-9geKMKfdfw8YxoY7PaFwqgfH9Q@mail.gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 2060 bytes --]
Dear camlers,
I'm currently trying to implement a camlp4 quotation whose contents will be
parsed using ocamllex and menhir. Everything went unexpectedly well until I
tried to add antiquotations. Following Tiphaine Turpin's format syntax
extension (https://forge.ocamlcore.org/projects/format/), an antiquotation
is parsed as a token in ocamllex, and this token is defined in my parser as:
%token <Camlp4.PreCast.Syntax.Ast.expr> EXPR
The thing is when I try to compile my project with ocamlbuild I get the
following error:
[gesundheit:~/w/ocaml-r 14:46]$make
ocaml setup.ml -build
Finished, 0 targets (0 cached) in 00:00:00.
+ menhir --ocamlc 'ocamlfind ocamlc -I src/syntax' --infer
src/syntax/r_lang_parser_y.mly
File "src/syntax/r_lang_parser_y.mly", line 7, characters 40-44:
Warning: the token EXPR is unused.
File "src/syntax/r_lang_parser_y.mly", line 7, characters 8-38:
Error: Unbound module Camlp4
...
Now I can easily (but manually) fix this by adding the missing -I option
for camlp4 libs:
[gesundheit:~/w/ocaml-r/_build 15:22]$menhir --ocamlc 'ocamlfind ocamlc -I
src/syntax -I +camlp4' --infer src/syntax/r_lang_parser_y.mly
File "src/syntax/r_lang_parser_y.mly", line 7, characters 40-44:
Warning: the token EXPR is unused.
[gesundheit:~/w/ocaml-r/_build 15:22]$
My question is how do I tell ocamlbuild to add this option directly? I fear
the response is "you cannot", if I refer to the piece of code in ocamlbuild
that generates the call to menhir:
let menhir mly env build =
let mly = env mly in
let menhir = if !Options.ocamlyacc = N then V"MENHIR" else
!Options.ocamlyacc in
Ocaml_compiler.prepare_compile build mly;
Cmd(S[menhir;
A"--ocamlc"; Quote(S[!Options.ocamlc; ocaml_include_flags mly]);
T(tags_of_pathname mly++"ocaml"++"parser"++"menhir");
A"--infer"; Px mly])
I fail to see in this function a hook which I could use to inject the
missing argument. Would any one know a workaround to use tokens that have
hold a value whose type is not defined in the standard library?
Cheers,
Philippe.
[-- Attachment #2: Type: text/html, Size: 4474 bytes --]
next reply other threads:[~2012-09-20 13:45 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-20 13:45 Philippe Veber [this message]
2012-09-20 14:18 ` Gabriel Scherer
2012-09-20 15:54 ` Philippe Veber
2012-09-20 16:11 ` Benoit Montagu
2012-09-20 16:30 ` Philippe Veber
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAOOOohR+2sOk-_xgLzy7g2d-9geKMKfdfw8YxoY7PaFwqgfH9Q@mail.gmail.com \
--to=philippe.veber@gmail.com \
--cc=caml-list@inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox