From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by sympa.inria.fr (Postfix) with ESMTPS id 77C717ED7A for ; Thu, 20 Sep 2012 17:55:13 +0200 (CEST) Received-SPF: None (mail4-smtp-sop.national.inria.fr: no sender authenticity information available from domain of philippe.veber@gmail.com) identity=pra; client-ip=209.85.220.182; receiver=mail4-smtp-sop.national.inria.fr; envelope-from="philippe.veber@gmail.com"; x-sender="philippe.veber@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail4-smtp-sop.national.inria.fr: domain of philippe.veber@gmail.com designates 209.85.220.182 as permitted sender) identity=mailfrom; client-ip=209.85.220.182; receiver=mail4-smtp-sop.national.inria.fr; envelope-from="philippe.veber@gmail.com"; x-sender="philippe.veber@gmail.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail4-smtp-sop.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-vc0-f182.google.com) identity=helo; client-ip=209.85.220.182; receiver=mail4-smtp-sop.national.inria.fr; envelope-from="philippe.veber@gmail.com"; x-sender="postmaster@mail-vc0-f182.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AlABAC87W1DRVdy2mGdsb2JhbABFq1+IYQGITggjAQEBAQEICQ0HFCeCIAEBAQMBEgIsARsdAQMBCwYFCw0uIQEBEQEFARwGEwgah04BAwkGC5tICQOMJYJ1hQwKGScNWYh0AQUMii5ihkIDlA+BVYEUigMCgykWKYQJ X-IronPort-AV: E=Sophos;i="4.80,454,1344204000"; d="scan'208";a="156416393" Received: from mail-vc0-f182.google.com ([209.85.220.182]) by mail4-smtp-sop.national.inria.fr with ESMTP/TLS/RC4-SHA; 20 Sep 2012 17:55:11 +0200 Received: by vcbfw7 with SMTP id fw7so4742823vcb.27 for ; Thu, 20 Sep 2012 08:55:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=wsAw1Lnb06R2yEqETR+VGGPkqbZAGtFOeu+fXRIzos4=; b=ckk+4QKLtG/Oxn4YI+3r8MkenLt83AOxqnFL+bXm5RX6HkLbaQbNgZMbRNEPBc++PE cWahl1En7JzkBYd+0UezYhh+nvstO5Es50B8fqW3JOvriaIv7p6BbhGFDsbYFzQ4roTI rPT/cqtu/7C7ROXoOUBizYQUaOC4M7YhWjz9jGJKLvkDg9mFaWWj/onZiMEtB1DfVQiV TwKl2DsGc9PUmFrygQqFD6PG21mPMH516eaiGkVzjOS27nDEzRvKmatYhnEYUfSkJghL lRKh+BnJ0ofovWYufZHSKd8PkYKk9kO4TBiDiYQzJa747UCUatE1Gofg+AaV6VEGfFIh czRQ== Received: by 10.52.92.98 with SMTP id cl2mr1020302vdb.101.1348156510615; Thu, 20 Sep 2012 08:55:10 -0700 (PDT) MIME-Version: 1.0 Received: by 10.221.0.135 with HTTP; Thu, 20 Sep 2012 08:54:50 -0700 (PDT) In-Reply-To: References: From: Philippe Veber Date: Thu, 20 Sep 2012 17:54:50 +0200 Message-ID: To: Gabriel Scherer Cc: caml users Content-Type: multipart/alternative; boundary=20cf307f3144eab67304ca24251d X-Validation-by: philippe.veber@gmail.com Subject: Re: [Caml-list] Using menhir for a camlp4 quotation: a compilation issue --20cf307f3144eab67304ca24251d Content-Type: text/plain; charset=ISO-8859-1 Thanks for your suggestion Gabriel! If I change the extension of my parser to mlypack, ocamlbuild fails to use it correctly: [gesundheit:~/w/ocaml-r 17:05]$make ocaml setup.ml -build Finished, 0 targets (0 cached) in 00:00:00. + ocamlfind ocamlc -c -g -package camlp4 -package camlp4.extend -package camlp4.lib -package camlp4.quotations -package camlp4.quotations.o -syntax camlp4o -I src/syntax -o src/syntax/r_lang_lexer.cmo src/syntax/ r_lang_lexer.ml File "src/syntax/r_lang_lexer.mll", line 4, characters 2-22: Error: Unbound module R_lang_parser_y It's not clear to me either what the mlypack are supposed to be. I'll try to patch the non-modular menhir function in ocamlbuild/ocaml_tools.ml as you suggest. Thanks again! ph. 2012/9/20 Gabriel Scherer > I'm not familiar with this part of ocamlbuild, but a look at > ocamlbuild/ocaml_tools.ml suggest that the different rule named > "menhir_modular" (which creates stuff from a file with extension > ".mlypack" rather than ".mly", and which I have never used) has a > slightly more expression -ocamlc option, that includes (T > ocamlc_tags), which includes in particular the tags for the .mlypack > file. > > You could try to see if, naming your grammar file .mlypack and adding > a "foo.mlypack: package(camlp4.lib)" to your _tags, you at least get a > satisfying menhir invocation. From there, you could either find out > what this "modular menhir" mode is and how to use it in your case, or > suggest patching ocamlbuild to use this (T ocamlc_tags) also in simple > menhir invocations. > > On Thu, Sep 20, 2012 at 3:45 PM, Philippe Veber > wrote: > > 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 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. > > > > > --20cf307f3144eab67304ca24251d Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Thanks for your suggestion Gabriel! If I change the extension of my parser = to mlypack, ocamlbuild fails to use it correctly:

[gesundheit:~/w/ocaml-r 17:05]$make
ocam= l setup.ml -build
Finished, 0 targets (0 cached) in 00:00:00.
+ ocamlfind ocamlc -c -g -pa= ckage camlp4 -package camlp4.extend -package camlp4.lib -package camlp4.quo= tations -package camlp4.quotations.o -syntax camlp4o -I src/syntax -o src/s= yntax/r_lang_lexer.cmo src/syntax/r_lang= _lexer.ml
File "src/syntax/r_lang_lexer.mll", line 4, characters 2-22:
E= rror: Unbound module R_lang_parser_y

It's not clear to me= either what the mlypack are supposed to be. I'll try to patch the non-= modular menhir function in ocamlbuild/oca= ml_tools.ml as you suggest.

Thanks again!
ph.

2012/9/20 Gabrie= l Scherer <gabriel.scherer@gmail.com>
I'm not familiar with this part of ocamlbuild, but a look at
ocamlbuild/ocaml_tools.= ml suggest that the different rule named
"menhir_modular" (which creates stuff from a file with extension<= br> ".mlypack" rather than ".mly", and which I have never u= sed) has a
slightly more expression -ocamlc option, that includes (T
ocamlc_tags), which includes in particular the tags for the .mlypack
file.

You could try to see if, naming your grammar file .mlypack and adding
a "foo.mlypack: package(camlp4.lib)" to your _tags, you at least = get a
satisfying menhir invocation. From there, you could either find out
what this "modular menhir" mode is and how to use it in your case= , or
suggest patching ocamlbuild to use this (T ocamlc_tags) also in simple
menhir invocations.

On Thu, Sep 20, 2012 at 3:45 PM, Philippe Veber
<philippe.veber@gmail.com> wrote:
> Dear camlers,
>
> I'm currently trying to implement a camlp4 quotation whose content= s will be
> parsed using ocamllex and menhir. Everything went unexpectedly well un= til I
> tried to add antiquotations. Following Tiphaine Turpin's format sy= ntax
> extension (
https://forge.ocamlcore.org/projects/format/), an antiq= uotation
> is parsed as a token in ocamllex, and this token is defined in my pars= er as:
>
> %token <Camlp4.PreCast.Syntax.Ast.expr> EXPR
>
> The thing is when I try to compile my project with ocamlbuild I get th= e
> following error:
>
> [gesundheit:~/w/ocaml-r 14:46]$make
> ocaml setup.ml -buil= d
> 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 opti= on for
> camlp4 libs:
>
> [gesundheit:~/w/ocaml-r/_build 15:22]$menhir --ocamlc 'ocamlfind o= camlc -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 cod= e in ocamlbuild
> that generates the call to menhir:
>
> let menhir mly env build =3D
> =A0 let mly =3D env mly in
> =A0 let menhir =3D if !Options.ocamlyacc =3D N then V"MENHIR"= ; else
> !Options.ocamlyacc in
> =A0 Ocaml_compiler.prepare_compile build mly;
> =A0 Cmd(S[menhir;
> =A0 =A0 =A0 =A0 A"--ocamlc"; Quote(S[!Options.ocamlc; ocaml_= include_flags mly]);
> =A0 =A0 =A0 =A0 T(tags_of_pathname mly++"ocaml"++"parse= r"++"menhir");
> =A0 =A0 =A0 =A0 A"--infer"; Px mly])
>
> I fail to see in this function a hook which I could use to inject the<= br> > missing argument. Would any one know a workaround to use tokens that h= ave
> hold a value whose type is not defined in the standard library?
>
> Cheers,
> =A0 Philippe.
>
>

--20cf307f3144eab67304ca24251d--