caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] compiling static preprocessors
@ 2012-03-01 19:58 Thomas Gazagnaire
  2012-03-01 20:14 ` Wojciech Meyer
  2012-03-01 21:52 ` Jérémie Dimino
  0 siblings, 2 replies; 6+ messages in thread
From: Thomas Gazagnaire @ 2012-03-01 19:58 UTC (permalink / raw)
  To: caml-list

Dear camlp4 experts,

I'm trying to compile a static version of a preprocessor built from type-conv and sexplib.

I've tried:

ocamlc dynlink.cma unix.cma \
       -I +camlp4 camlp4lib.cma -linkall \
       Camlp4Parsers/Camlp4OCamlRevisedParser.cmo \
       Camlp4Parsers/Camlp4OCamlParser.cmo \
       Camlp4Parsers/Camlp4OCamlRevisedParserParser.cmo \
       Camlp4Parsers/Camlp4OCamlParserParser.cmo \
       Camlp4Printers/Camlp4AutoPrinter.cmo \
       Camlp4Bin.cmo \
       -I +site-lib/type-conv pa_type_conv.cma \
       -I +site-lib/sexplib pa_sexp_conv.cma \
       -o sexppp

I've taken the first lines by greping camlp4o.native in ocaml-3.12.1/_build/_log and I've appended what normally follows camlp4o when using sexplib.

The command succeeds at building sexppp, but unfortunately, the preprocessor doesn't work as expected: "./my_pp foo.ml" gives: "Parse error: [semi] expected after [str_item] (in [implem])" for any type followed by "with sexp" in foo.ml.

I am trying to do something crazy or is there a chance to make it work?

Cheers,
Thomas

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Caml-list] compiling static preprocessors
  2012-03-01 19:58 [Caml-list] compiling static preprocessors Thomas Gazagnaire
@ 2012-03-01 20:14 ` Wojciech Meyer
  2012-03-01 21:52 ` Jérémie Dimino
  1 sibling, 0 replies; 6+ messages in thread
From: Wojciech Meyer @ 2012-03-01 20:14 UTC (permalink / raw)
  To: Thomas Gazagnaire; +Cc: caml-list

Hi Thomas,

Unfortunately I don't have much time to reply right now, so please
excuse lack of information [i am not an camlp4 expert too] and I would
need to see what I did at wok, but as far as I remember mkcamlp4
command helped mi a lot with building custom preprocessors.

Cheers,
Wojciech


On Fri, Mar 2, 2012 at 3:58 AM, Thomas Gazagnaire
<thomas.gazagnaire@gmail.com> wrote:
> Dear camlp4 experts,
>
> I'm trying to compile a static version of a preprocessor built from type-conv and sexplib.
>
> I've tried:
>
> ocamlc dynlink.cma unix.cma \
>       -I +camlp4 camlp4lib.cma -linkall \
>       Camlp4Parsers/Camlp4OCamlRevisedParser.cmo \
>       Camlp4Parsers/Camlp4OCamlParser.cmo \
>       Camlp4Parsers/Camlp4OCamlRevisedParserParser.cmo \
>       Camlp4Parsers/Camlp4OCamlParserParser.cmo \
>       Camlp4Printers/Camlp4AutoPrinter.cmo \
>       Camlp4Bin.cmo \
>       -I +site-lib/type-conv pa_type_conv.cma \
>       -I +site-lib/sexplib pa_sexp_conv.cma \
>       -o sexppp
>
> I've taken the first lines by greping camlp4o.native in ocaml-3.12.1/_build/_log and I've appended what normally follows camlp4o when using sexplib.
>
> The command succeeds at building sexppp, but unfortunately, the preprocessor doesn't work as expected: "./my_pp foo.ml" gives: "Parse error: [semi] expected after [str_item] (in [implem])" for any type followed by "with sexp" in foo.ml.
>
> I am trying to do something crazy or is there a chance to make it work?
>
> Cheers,
> Thomas
>
> --
> Caml-list mailing list.  Subscription management and archives:
> https://sympa-roc.inria.fr/wws/info/caml-list
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
>


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Caml-list] compiling static preprocessors
  2012-03-01 19:58 [Caml-list] compiling static preprocessors Thomas Gazagnaire
  2012-03-01 20:14 ` Wojciech Meyer
@ 2012-03-01 21:52 ` Jérémie Dimino
  2012-03-01 22:25   ` Thomas Gazagnaire
  1 sibling, 1 reply; 6+ messages in thread
From: Jérémie Dimino @ 2012-03-01 21:52 UTC (permalink / raw)
  To: Thomas Gazagnaire; +Cc: caml-list

Le Thu, 1 Mar 2012 20:58:38 +0100,
Thomas Gazagnaire <thomas.gazagnaire@gmail.com> a écrit :

> ocamlc dynlink.cma unix.cma \
>        -I +camlp4 camlp4lib.cma -linkall \
>        Camlp4Parsers/Camlp4OCamlRevisedParser.cmo \
>        Camlp4Parsers/Camlp4OCamlParser.cmo \
>        Camlp4Parsers/Camlp4OCamlRevisedParserParser.cmo \
>        Camlp4Parsers/Camlp4OCamlParserParser.cmo \
>        Camlp4Printers/Camlp4AutoPrinter.cmo \
>        Camlp4Bin.cmo \
>        -I +site-lib/type-conv pa_type_conv.cma \
>        -I +site-lib/sexplib pa_sexp_conv.cma \
>        -o sexppp
>
> I've taken the first lines by greping camlp4o.native in
> ocaml-3.12.1/_build/_log and I've appended what normally follows
> camlp4o when using sexplib.
> 
> The command succeeds at building sexppp, but unfortunately, the
> preprocessor doesn't work as expected: "./my_pp foo.ml" gives: "Parse
> error: [semi] expected after [str_item] (in [implem])" for any type
> followed by "with sexp" in foo.ml.
> 
> I am trying to do something crazy or is there a chance to make it
> work?

It is because Camlp4Bin.cmo is linked before pa_type_conv.cma and
pa_sexp_conv.cma, and so side-effects of theses modules are not
yet performed when the camlp4 main function run.

Camlp4Bin.cmo must be the last file on the command line.

Cheers,

-- 
Jérémie


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Caml-list] compiling static preprocessors
  2012-03-01 21:52 ` Jérémie Dimino
@ 2012-03-01 22:25   ` Thomas Gazagnaire
  2012-03-01 22:32     ` Jérémie Dimino
  0 siblings, 1 reply; 6+ messages in thread
From: Thomas Gazagnaire @ 2012-03-01 22:25 UTC (permalink / raw)
  To: Jérémie Dimino; +Cc: caml-list

> Camlp4Bin.cmo must be the last file on the command line.

Thanks Jérémie, this indeed fixes part of the problem. Now, I get a new error message:

Fatal error: exception Not_found
Raised at file "camlp4/Camlp4/Struct/Grammar/Delete.ml", line 131, characters 16-25
Called from file "camlp4/Camlp4/Struct/Grammar/Delete.ml", line 146, characters 17-56
Called from file "lib/pa_type_conv.ml", line 421, characters 12-62

where pa_type_conv.ml:421 is:

    DELETE_RULE Gram str_item: "module"; a_UIDENT; module_binding0 END;

So I suppose the OCaml grammar is not yet registered when type-conv tries to remove the rule. Oh dear... Any thoughts on this one?

--
Thomas



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Caml-list] compiling static preprocessors
  2012-03-01 22:25   ` Thomas Gazagnaire
@ 2012-03-01 22:32     ` Jérémie Dimino
  2012-03-01 22:43       ` Thomas Gazagnaire
  0 siblings, 1 reply; 6+ messages in thread
From: Jérémie Dimino @ 2012-03-01 22:32 UTC (permalink / raw)
  To: Thomas Gazagnaire; +Cc: caml-list

Le Thu, 1 Mar 2012 23:25:25 +0100,
Thomas Gazagnaire <thomas.gazagnaire@gmail.com> a écrit :

> So I suppose the OCaml grammar is not yet registered when type-conv
> tries to remove the rule. Oh dear... Any thoughts on this one?

Ah yes, camlp4 modules initialization may be delayed, try to link
this code after camlp4 modules and before type-conv ones:

  Camlp4.Register.iter_and_take_callbacks
    (fun (name, callback)-> callback ())

-- 
Jérémie


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Caml-list] compiling static preprocessors
  2012-03-01 22:32     ` Jérémie Dimino
@ 2012-03-01 22:43       ` Thomas Gazagnaire
  0 siblings, 0 replies; 6+ messages in thread
From: Thomas Gazagnaire @ 2012-03-01 22:43 UTC (permalink / raw)
  To: Jérémie Dimino; +Cc: caml-list

>> So I suppose the OCaml grammar is not yet registered when type-conv
>> tries to remove the rule. Oh dear... Any thoughts on this one?
> 
> Ah yes, camlp4 modules initialization may be delayed, try to link
> this code after camlp4 modules and before type-conv ones:
> 
>  Camlp4.Register.iter_and_take_callbacks
>    (fun (name, callback)-> callback ())

Awesome, this is now working correctly!  Many thanks Jérémie!

Cheers,
Thomas

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2012-03-01 22:44 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-01 19:58 [Caml-list] compiling static preprocessors Thomas Gazagnaire
2012-03-01 20:14 ` Wojciech Meyer
2012-03-01 21:52 ` Jérémie Dimino
2012-03-01 22:25   ` Thomas Gazagnaire
2012-03-01 22:32     ` Jérémie Dimino
2012-03-01 22:43       ` Thomas Gazagnaire

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).