caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] [camlp4] compiling against Pcaml module
@ 2002-10-17 16:08 Stefano Zacchiroli
  2002-10-17 16:21 ` Daniel de Rauglaudre
  2002-10-17 16:22 ` Samuel Lacas
  0 siblings, 2 replies; 8+ messages in thread
From: Stefano Zacchiroli @ 2002-10-17 16:08 UTC (permalink / raw)
  To: Inria Ocaml Mailing List

I'm trying to play with ocaml sources abstract syntax tree, but I'm
unable to compile against Pcaml module.

As camlp4 reference manual report at the beginning of chapter 8:

  When linking an application using this library modules, you have to
  add the file gramlib.cma in the command line. For example, with the
  line:
          ocamlc -I +camlp4 gramlib.cma <the_files> 

This seems to work with modules from camlp4 library modules other that
Pcaml (try for example with Fstream or Stdpp).

As an example I've tried to build the following source file:

   (* bar.ml *)
   let ast =
     !Pcaml.parse_interf (Stream.of_channel (open_in "foo.mli"))
   in
     print_endline "foo"

with the following command:

  ocamlc -o bar -I +camlp4 gramlib.cma bar.ml

and I get:

  Error while linking ast_prova.cmo: Reference to undefined global `Pcaml'

I've also digged into <stdlib>/camlp4/gramlib.a with 'nm' and indeed I
found no symbols starting with "Pcaml" string.
Unfortunately the stdlib directory contains also no pcaml.cmo object ..

What I've to link additionally to gramlib.cma in order to use "Pcaml"
module?

BTW, is probably better also to correct the camlp4 manual with the
appropriate compile line, if I haven't missed something though.

TIA,
Cheers.

-- 
Stefano Zacchiroli - undergraduate student of CS @ Univ. Bologna, Italy
zack@cs.unibo.it | ICQ# 33538863 | http://www.cs.unibo.it/~zacchiro
"I know you believe you understood what you think I said, but I am not
sure you realize that what you heard is not what I meant!" -- G.Romney
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


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

* Re: [Caml-list] [camlp4] compiling against Pcaml module
  2002-10-17 16:08 [Caml-list] [camlp4] compiling against Pcaml module Stefano Zacchiroli
@ 2002-10-17 16:21 ` Daniel de Rauglaudre
  2002-10-17 16:23   ` Daniel de Rauglaudre
  2002-10-17 16:22 ` Samuel Lacas
  1 sibling, 1 reply; 8+ messages in thread
From: Daniel de Rauglaudre @ 2002-10-17 16:21 UTC (permalink / raw)
  To: caml-list

Hi,

On Thu, Oct 17, 2002 at 06:08:37PM +0200, Stefano Zacchiroli wrote:

>   ocamlc -o bar -I +camlp4 gramlib.cma bar.ml
> and I get:
>   Error while linking ast_prova.cmo: Reference to undefined global `Pcaml'

The gramlib.cma of Camlp4 is just if you use Camlp4 to make grammars
of your language, i.e. an alternative to ocamlyacc.

If you write a program using the module Pcaml, i.e. if it is about the
specific grammar of OCaml, you need to use the library camlp4.cma. But!
You need also to specify which syntax you want. For the normal syntax,
add "pa_o.cmo", for the revised syntax "pa_r.cmo", and for the Scheme
syntax "pa_scheme.cmo".

If your file "foo.mli" of your example is written in normal syntax,
just compile your bar.ml like this:

   ocamlc -o bar -I +camlp4 camlp4.cma pa_r.cmo bar.ml

-- 
Daniel de RAUGLAUDRE
daniel.de_rauglaudre@inria.fr
http://cristal.inria.fr/~ddr/
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


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

* Re: [Caml-list] [camlp4] compiling against Pcaml module
  2002-10-17 16:08 [Caml-list] [camlp4] compiling against Pcaml module Stefano Zacchiroli
  2002-10-17 16:21 ` Daniel de Rauglaudre
@ 2002-10-17 16:22 ` Samuel Lacas
  2002-10-17 16:26   ` Daniel de Rauglaudre
  1 sibling, 1 reply; 8+ messages in thread
From: Samuel Lacas @ 2002-10-17 16:22 UTC (permalink / raw)
  To: Inria Ocaml Mailing List

Stefano Zacchiroli a écrit 1.7K le Thu, Oct 17, 2002 at 06:08:37PM +0200:
# I'm trying to play with ocaml sources abstract syntax tree, but I'm
# unable to compile against Pcaml module.
[snip] 
# What I've to link additionally to gramlib.cma in order to use "Pcaml"
# module?

As far as I can tell, "Pcaml" is defined (at least) in camlp4o.cma
(under the camlp4 architecture).

Hope this helps,

sL
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


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

* Re: [Caml-list] [camlp4] compiling against Pcaml module
  2002-10-17 16:21 ` Daniel de Rauglaudre
@ 2002-10-17 16:23   ` Daniel de Rauglaudre
  0 siblings, 0 replies; 8+ messages in thread
From: Daniel de Rauglaudre @ 2002-10-17 16:23 UTC (permalink / raw)
  To: caml-list

>    ocamlc -o bar -I +camlp4 camlp4.cma pa_r.cmo bar.ml

Oops. I meant pa_o.cmo. Sorry.

-- 
Daniel de RAUGLAUDRE
daniel.de_rauglaudre@inria.fr
http://cristal.inria.fr/~ddr/
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


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

* Re: [Caml-list] [camlp4] compiling against Pcaml module
  2002-10-17 16:22 ` Samuel Lacas
@ 2002-10-17 16:26   ` Daniel de Rauglaudre
  2002-10-17 16:28     ` [Caml-list] a quick question on camlp4 Alexander V.Voinov
  0 siblings, 1 reply; 8+ messages in thread
From: Daniel de Rauglaudre @ 2002-10-17 16:26 UTC (permalink / raw)
  To: caml-list

Hi,

On Thu, Oct 17, 2002 at 06:22:42PM +0200, Samuel Lacas wrote:

> As far as I can tell, "Pcaml" is defined (at least) in camlp4o.cma
> (under the camlp4 architecture).

Yes, but it is just for the toplevel: if you link with it, you get an
error since it needs the module Toploop. For a standalone application,
link with "camlp4.cma pa_o.cmo" as I say in my previous message.

-- 
Daniel de RAUGLAUDRE
daniel.de_rauglaudre@inria.fr
http://cristal.inria.fr/~ddr/
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


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

* [Caml-list] a quick question on camlp4
  2002-10-17 16:26   ` Daniel de Rauglaudre
@ 2002-10-17 16:28     ` Alexander V.Voinov
  2002-10-17 16:55       ` Daniel de Rauglaudre
  0 siblings, 1 reply; 8+ messages in thread
From: Alexander V.Voinov @ 2002-10-17 16:28 UTC (permalink / raw)
  To: daniel.de_rauglaudre; +Cc: caml-list

Hi,

For a presentation which I'm about to make, I created a 
simple (normal) syntax extension to imitate Python loop
over a sequnce:

iterate <list> with <fun> which maps to List.iter <fun> <list>.

This results in examples like:

iterate [1; 2; 3; 4] with function
  | 2 -> printf "two\n"
  | n -> printf "%d\n"

Is it possible to eliminate the keyword 'function' from this,
that is to implement an extension like:

iterate <list> with <pat1> -> <expr1> | <pat2> -> <expr2> ...

mapping to

List.iter (function <pat1> -> <expr1> | <pat2> -> <expr2> ...) <list>.

I'm asking this just because I don't have time now to investigate
this by my own :-).

Also, I was thinking about extensions like

let sum = 
   fold [10; 20; 30; 40] from 0.0 with
     | val, sum -> val + sum

mapping to fold_left/fold_right.

Thank you in advance

Alexander
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


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

* Re: [Caml-list] a quick question on camlp4
  2002-10-17 16:28     ` [Caml-list] a quick question on camlp4 Alexander V.Voinov
@ 2002-10-17 16:55       ` Daniel de Rauglaudre
  2002-10-17 17:07         ` Alexander V.Voinov
  0 siblings, 1 reply; 8+ messages in thread
From: Daniel de Rauglaudre @ 2002-10-17 16:55 UTC (permalink / raw)
  To: caml-list

Hi,

On Thu, Oct 17, 2002 at 09:28:31AM -0700, Alexander V.Voinov wrote:

> Is it possible to eliminate the keyword 'function' from this,
> that is to implement an extension like:
> 
> iterate <list> with <pat1> -> <expr1> | <pat2> -> <expr2> ...

Not a problem to keep 'function' since it is already a keyword in
OCaml (normal syntax).

> I'm asking this just because I don't have time now to investigate
> this by my own :-).

What do you ask, exactly? Since you implemented your "iterate"
extension, I suppose that you know how to use Camlp4. What is the
difficulty to implement your "fold"?

-- 
Daniel de RAUGLAUDRE
daniel.de_rauglaudre@inria.fr
http://cristal.inria.fr/~ddr/
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


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

* Re: [Caml-list] a quick question on camlp4
  2002-10-17 16:55       ` Daniel de Rauglaudre
@ 2002-10-17 17:07         ` Alexander V.Voinov
  0 siblings, 0 replies; 8+ messages in thread
From: Alexander V.Voinov @ 2002-10-17 17:07 UTC (permalink / raw)
  To: daniel.de_rauglaudre; +Cc: caml-list

From: Daniel de Rauglaudre <daniel.de_rauglaudre@inria.fr>
Subject: Re: [Caml-list] a quick question on camlp4
Date: Thu, 17 Oct 2002 18:55:17 +0200

> Hi,
> 
> On Thu, Oct 17, 2002 at 09:28:31AM -0700, Alexander V.Voinov wrote:
> 
> > Is it possible to eliminate the keyword 'function' from this,
> > that is to implement an extension like:
> > 
> > iterate <list> with <pat1> -> <expr1> | <pat2> -> <expr2> ...
> 
> Not a problem to keep 'function' since it is already a keyword in
> OCaml (normal syntax).
> 
> > I'm asking this just because I don't have time now to investigate
> > this by my own :-).
> 
> What do you ask, exactly? 

I was wondering if it was really possible to go deeper into the syntax tree
and recreate the function body out of the <pat> -> <expr> pieces.

Since you implemented your "iterate"
> extension, I suppose that you know how to use Camlp4. 

It was a direct analog of the Pascal 'repeat' example. :-) I didn't go
any further that time.

> What is the
> difficulty to implement your "fold"?

Better knowledge of camlp4 :-). From your remark I understand that it's
possible. Thank you!

Alexander
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


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

end of thread, other threads:[~2002-10-17 17:18 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-10-17 16:08 [Caml-list] [camlp4] compiling against Pcaml module Stefano Zacchiroli
2002-10-17 16:21 ` Daniel de Rauglaudre
2002-10-17 16:23   ` Daniel de Rauglaudre
2002-10-17 16:22 ` Samuel Lacas
2002-10-17 16:26   ` Daniel de Rauglaudre
2002-10-17 16:28     ` [Caml-list] a quick question on camlp4 Alexander V.Voinov
2002-10-17 16:55       ` Daniel de Rauglaudre
2002-10-17 17:07         ` Alexander V.Voinov

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