caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] a question about compilation ... [sexplib; gramlib]
@ 2013-09-19 11:36 Matej Kosik
  2013-09-19 12:17 ` Kakadu
  2013-09-19 15:16 ` Gerd Stolpmann
  0 siblings, 2 replies; 4+ messages in thread
From: Matej Kosik @ 2013-09-19 11:36 UTC (permalink / raw)
  To: caml-list

[-- Attachment #1: Type: text/plain, Size: 706 bytes --]

Hi,

If my program contains "__LOCATION__" macro, I can get it compiled with the following instructions:

	ocamlfind ocamlc -package camlp4.gramlib -pp camlp4of main.ml -o main.cmo -c
	ocamlfind ocamlc -package camlp4.gramlib -linkpkg main.cmo -o main

If my program contains "with sexp" macro, I can get it compiled with the following instructions:

	ocamlfind ocamlc -package sexplib,sexplib.syntax -syntax camlp4o main.ml -o main.cmo -c
	ocamlfind ocamlc -package sexplib,sexplib.syntax -linkpkg main.cmo -o main

Is it technically possible to to compile a program where I use both "__LOCATION__" as well as "with sexp" macros?
(like the attached sample)

Thank you very much, in advance, for the help.

[-- Attachment #2: sample.ml --]
[-- Type: text/plain, Size: 130 bytes --]

open Camlp4.PreCast

type foo = Bar | Baz
with sexp

let l = __LOCATION__ in

Printf.printf "file_name = %s\n" (Loc.file_name l);

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

* Re: [Caml-list] a question about compilation ... [sexplib; gramlib]
  2013-09-19 11:36 [Caml-list] a question about compilation ... [sexplib; gramlib] Matej Kosik
@ 2013-09-19 12:17 ` Kakadu
  2013-09-19 15:16 ` Gerd Stolpmann
  1 sibling, 0 replies; 4+ messages in thread
From: Kakadu @ 2013-09-19 12:17 UTC (permalink / raw)
  To: Matej Kosik; +Cc: Caml List

AFAIK these syntax extensions are composable.

For your sample code I can see preprocessed result after executing
camlp4of -I `ocamlfind query type_conv` -I `ocamlfind query sexplib`
pa_type_conv.cma pa_sexp_conv.cma sample.ml

I'm not sure how to built-in it into compilation. Maybe you need add
command above after -pp option.

Happy hacking,
Kakadu

On Thu, Sep 19, 2013 at 3:36 PM, Matej Kosik
<5764c029b688c1c0d24a2e97cd764f@gmail.com> wrote:
> Hi,
>
> If my program contains "__LOCATION__" macro, I can get it compiled with the following instructions:
>
>         ocamlfind ocamlc -package camlp4.gramlib -pp camlp4of main.ml -o main.cmo -c
>         ocamlfind ocamlc -package camlp4.gramlib -linkpkg main.cmo -o main
>
> If my program contains "with sexp" macro, I can get it compiled with the following instructions:
>
>         ocamlfind ocamlc -package sexplib,sexplib.syntax -syntax camlp4o main.ml -o main.cmo -c
>         ocamlfind ocamlc -package sexplib,sexplib.syntax -linkpkg main.cmo -o main
>
> Is it technically possible to to compile a program where I use both "__LOCATION__" as well as "with sexp" macros?
> (like the attached sample)
>
> Thank you very much, in advance, for the help.
>
> --
> Caml-list mailing list.  Subscription management and archives:
> https://sympa.inria.fr/sympa/arc/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] 4+ messages in thread

* Re: [Caml-list] a question about compilation ... [sexplib; gramlib]
  2013-09-19 11:36 [Caml-list] a question about compilation ... [sexplib; gramlib] Matej Kosik
  2013-09-19 12:17 ` Kakadu
@ 2013-09-19 15:16 ` Gerd Stolpmann
  2013-09-20  8:54   ` Matej Kosik
  1 sibling, 1 reply; 4+ messages in thread
From: Gerd Stolpmann @ 2013-09-19 15:16 UTC (permalink / raw)
  To: Matej Kosik; +Cc: caml-list

[-- Attachment #1: Type: text/plain, Size: 1448 bytes --]

Am Donnerstag, den 19.09.2013, 12:36 +0100 schrieb Matej Kosik:
> Hi,
> 
> If my program contains "__LOCATION__" macro, I can get it compiled with the following instructions:
> 
> 	ocamlfind ocamlc -package camlp4.gramlib -pp camlp4of main.ml -o main.cmo -c
> 	ocamlfind ocamlc -package camlp4.gramlib -linkpkg main.cmo -o main

I don't know where you have this from, but this is not the right way of
doing it. Better:

ocamlfind ocamlc -package camlp4.macro -syntax camlp4o main.ml -c

> 
> If my program contains "with sexp" macro, I can get it compiled with the following instructions:
> 
> 	ocamlfind ocamlc -package sexplib,sexplib.syntax -syntax camlp4o main.ml -o main.cmo -c
> 	ocamlfind ocamlc -package sexplib,sexplib.syntax -linkpkg main.cmo -o main
> 
> Is it technically possible to to compile a program where I use both "__LOCATION__" as well as "with sexp" macros?
> (like the attached sample)

Combined:

ocamlfind ocamlc -package camlp4.macro,sexplib,sexplib.syntax -syntax
camlp4o main.ml -c

Gerd

> 
> Thank you very much, in advance, for the help.
> 

-- 
------------------------------------------------------------
Gerd Stolpmann, Darmstadt, Germany    gerd@gerd-stolpmann.de
Creator of GODI and camlcity.org.
Contact details:        http://www.camlcity.org/contact.html
Company homepage:       http://www.gerd-stolpmann.de
------------------------------------------------------------

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 490 bytes --]

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

* Re: [Caml-list] a question about compilation ... [sexplib; gramlib]
  2013-09-19 15:16 ` Gerd Stolpmann
@ 2013-09-20  8:54   ` Matej Kosik
  0 siblings, 0 replies; 4+ messages in thread
From: Matej Kosik @ 2013-09-20  8:54 UTC (permalink / raw)
  To: Gerd Stolpmann; +Cc: OCaml

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

Thank you all,

On 19/09/13 16:16, Gerd Stolpmann wrote:
> Am Donnerstag, den 19.09.2013, 12:36 +0100 schrieb Matej Kosik:
> 
> Better:
> 
> ocamlfind ocamlc -package camlp4.macro -syntax camlp4o main.ml -c
> 
>> 
>> If my program contains "with sexp" macro, I can get it compiled with the following instructions:
>> 
>> ocamlfind ocamlc -package sexplib,sexplib.syntax -syntax camlp4o main.ml -o main.cmo -c ocamlfind ocamlc -package sexplib,sexplib.syntax -linkpkg main.cmo -o main
>> 
>> Is it technically possible to to compile a program where I use both "__LOCATION__" as well as "with sexp" macros? (like the attached sample)
> 
> Combined:
> 
> ocamlfind ocamlc -package camlp4.macro,sexplib,sexplib.syntax -syntax camlp4o main.ml -c

This works.

I have noticed an additional problem, though.
If I use the above command, then I noticed that adding "with sexp" after a type&exception definition is not an option, but an obligation.

The problem disappears if I reverse the library order:

ocamlfind ocamlc -package sexplib,sexplib.syntax,camlp4.macro -syntax camlp4o sample.ml -c
ocamlfind c -package sexplib,camlp4.gramlib -linkpkg sample.cmo -o sample
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.14 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQIcBAEBCgAGBQJSPA1BAAoJEMGSqCmYLk+ztwMQALrj6yvTATdE6UGLzfDDoDAn
KNWycblnjesEn9dfnihNgLuUNk/YmO/E7BdxLkWJ8798Qok4XaqZ02rqZ2Ctc1Aq
RhM2wweccVgzG0aDqMpDbSqOZqspNkmkDgMGkSVpWjkowx0kTMeP573AJ1l5F3np
czXYyEpSEKexeE2iLw6ucchIj5XVjYyHXn9EFyWckXKKfTScNqR7gubRNd45uv/E
MLxCGFCV8iXSyTo4f9xGTtbu35DHLEm1MKkw1SAs05H9JRVLHfpZqpCbQW1H2eSy
f6dD/tqvQ5gjv88q0pDhtft4vItnCpmRA3Z5b3k4rhgXKYZo1FYG5P3q9CRTw2cM
qax3zSnRu2tGsrpWluPg+LSnL5ol+pX9WqSf+9j/xvjZkX0ic0oKsW07Hce59Jsj
CqF8zUNRr/Y/lOkNG4T0R1Fg1YHSkImnLxWpt4oUB8fe3DNxXyFWSKx/sT2+vU+F
eilaqv99apCiXljY0LXWEkRXeUQaKdYX1AiPHhr5CkJFHutp4eDDKXRNEeZdQFRp
FVYFAepOvUotpBLms+ArauTMFNxFgC0lN+SgAmVDLGsXfDb3lT7v2SC97lqBceSU
5d+p2CmY07HG959IRvaE4Cr1GqW26lC8/rhdUVjE/4u1kRMZqhRjlw99+Tse3tZZ
M8YnspznLHksf6U2Ft5/
=AyT7
-----END PGP SIGNATURE-----

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

end of thread, other threads:[~2013-09-20  8:54 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-09-19 11:36 [Caml-list] a question about compilation ... [sexplib; gramlib] Matej Kosik
2013-09-19 12:17 ` Kakadu
2013-09-19 15:16 ` Gerd Stolpmann
2013-09-20  8:54   ` Matej Kosik

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).