caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* ocaml parser
@ 2008-07-01 16:34 Christophe Raffalli
  2008-07-02  4:48 ` [Caml-list] " Michel Mauny
  0 siblings, 1 reply; 4+ messages in thread
From: Christophe Raffalli @ 2008-07-01 16:34 UTC (permalink / raw)
  To: Caml Mailing List; +Cc: Emmanuel Onzon


[-- Attachment #1.1: Type: text/plain, Size: 1375 bytes --]


Dear list members and ocaml developper,

Is it a bug to have any difference between both ocaml parser (with "-pp 
camlp4o" or without) ?

I expected that everything that compiles with ocamlc should compile with 
ocamlc -pp camlp4o
(the opposite is not true and does not need to be true) which is not the 
case.

And a secondary question : why to have two parsers (except maybe for 
bootstraping) ?

Here is an example:

-------- test.ml ------
let parser = 0
-------- en test.ml --

Tocksi:pml christopheraffalli$ ocamlc -c test.ml
Tocksi:pml christopheraffalli$ ocamlc -c -pp camlp4o test.ml
File "test.ml", line 1, characters 0-3:
Parse error: [binding] expected after [opt_rec] (in [str_item])
Preprocessor error

(remark: this is the error message from ocaml 3.10, the error from 3.09 
was clearer).

Cheers,
Christophe

-- 
Christophe Raffalli
Universite de Savoie
Batiment Le Chablais, bureau 21
73376 Le Bourget-du-Lac Cedex

tel: (33) 4 79 75 81 03
fax: (33) 4 79 75 87 42
mail: Christophe.Raffalli@univ-savoie.fr
www: http://www.lama.univ-savoie.fr/~RAFFALLI
---------------------------------------------
IMPORTANT: this mail is signed using PGP/MIME
At least Enigmail/Mozilla, mutt or evolution 
can check this signature. The public key is
stored on www.keyserver.net
---------------------------------------------


[-- Attachment #1.2: Christophe_Raffalli.vcf --]
[-- Type: text/x-vcard, Size: 310 bytes --]

begin:vcard
fn:Christophe Raffalli
n:Raffalli;Christophe
org:LAMA (UMR 5127)
email;internet:christophe.raffalli@univ-savoie.fr
title;quoted-printable:Ma=C3=AEtre de conf=C3=A9rences
tel;work:+33 4 79 75 81 03
note:http://www.lama.univ-savoie.fr/~raffalli
x-mozilla-html:TRUE
version:2.1
end:vcard


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 249 bytes --]

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

* Re: [Caml-list] ocaml parser
  2008-07-01 16:34 ocaml parser Christophe Raffalli
@ 2008-07-02  4:48 ` Michel Mauny
  2008-07-02  7:44   ` Christophe Raffalli
  0 siblings, 1 reply; 4+ messages in thread
From: Michel Mauny @ 2008-07-02  4:48 UTC (permalink / raw)
  To: Christophe Raffalli; +Cc: Caml Mailing List

Christophe Raffalli écrit/writes [07/01/2008 06:34 PM] :

> Is it a bug to have any difference between both ocaml parser (with "-pp 
> camlp4o" or without) ?

In some situations yes, in others no.

> I expected that everything that compiles with ocamlc should compile with 
> ocamlc -pp camlp4o
> (the opposite is not true and does not need to be true) which is not the 
> case.

Camlp4o is supposed to parse all OCaml plus things such as stream
parsers.  Since adding keywords ("parser", for instance) may break
legal OCaml programs, Camlp4o is supposed to parse OCaml programs that
don't conflict with such extensions.  Camlp4o cannot therefore parse
_all_ OCaml programs.

> And a secondary question : why to have two parsers (except maybe for 
> bootstraping) ?

I'm not sure I understand your question, but the OCaml and Camlp4o
parsers use a different technology. The latter is extensible while the
former is not.

-- Michel


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

* Re: [Caml-list] ocaml parser
  2008-07-02  4:48 ` [Caml-list] " Michel Mauny
@ 2008-07-02  7:44   ` Christophe Raffalli
  2008-07-02 15:34     ` blue storm
  0 siblings, 1 reply; 4+ messages in thread
From: Christophe Raffalli @ 2008-07-02  7:44 UTC (permalink / raw)
  To: Michel Mauny; +Cc: Caml Mailing List


[-- Attachment #1.1: Type: text/plain, Size: 1046 bytes --]


>
>
>> And a secondary question : why to have two parsers (except maybe for 
>> bootstraping) ?
>
> I'm not sure I understand your question, but the OCaml and Camlp4o
> parsers use a different technology. The latter is extensible while the
> former is not.

I just think one parser technology (-pp camlp4o by default) sounds 
better to me !
This is a problem when you generate ocaml code that you must make sure 
to be compatible
with as many as possible OCaml parsers ...

Christophe
>
> -- Michel
>
>


-- 
Christophe Raffalli
Universite de Savoie
Batiment Le Chablais, bureau 21
73376 Le Bourget-du-Lac Cedex

tel: (33) 4 79 75 81 03
fax: (33) 4 79 75 87 42
mail: Christophe.Raffalli@univ-savoie.fr
www: http://www.lama.univ-savoie.fr/~RAFFALLI
---------------------------------------------
IMPORTANT: this mail is signed using PGP/MIME
At least Enigmail/Mozilla, mutt or evolution 
can check this signature. The public key is
stored on www.keyserver.net
---------------------------------------------


[-- Attachment #1.2: Christophe_Raffalli.vcf --]
[-- Type: text/x-vcard, Size: 310 bytes --]

begin:vcard
fn:Christophe Raffalli
n:Raffalli;Christophe
org:LAMA (UMR 5127)
email;internet:christophe.raffalli@univ-savoie.fr
title;quoted-printable:Ma=C3=AEtre de conf=C3=A9rences
tel;work:+33 4 79 75 81 03
note:http://www.lama.univ-savoie.fr/~raffalli
x-mozilla-html:TRUE
version:2.1
end:vcard


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 249 bytes --]

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

* Re: [Caml-list] ocaml parser
  2008-07-02  7:44   ` Christophe Raffalli
@ 2008-07-02 15:34     ` blue storm
  0 siblings, 0 replies; 4+ messages in thread
From: blue storm @ 2008-07-02 15:34 UTC (permalink / raw)
  To: Christophe Raffalli; +Cc: Michel Mauny, Caml Mailing List

> Is it a bug to have any difference between both ocaml parser (with "-pp camlp4o" or without) ?
camlp4o add some extensions to the ocaml syntax (streams and parser,
thus your conflict). But you can use a bare "camlp4" preprocessor,
adding it only the ocaml parser, and you wouldn't get those
incompatibilities :
  $ ocamlc -pp 'camlp4 pa_o.cmo pr_dump.cmo' test.ml

As explained in the man page :
       The command camlp4o is a shortcut for:
           camlp4 pa_o.cmo pa_op.cmo pr_dump.cmo
(pa_op.cmo providing streams and parser syntax)

> This is a problem when you generate ocaml code that
> you must make sure to be compatible
> with as many as possible OCaml parsers ...

An other solution would be to use the camlp4 libraries to output a
piece of OCaml AST directly, wich you can then read and interpret
directly and without ambiguities, without going through an additional
parsing stage. The pr_dump.cmo printer achieve this, although i'm not
exactly sure how you should proceed from an independent generator :
  $ cat test.ml
    print_endline "Hello World"
  $ camlp4 pa_o.cmo pr_dump.cmo test.ml > test.out
  $ ocamlc -o test -impl test.out
  $ ./test
    Hello World


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

end of thread, other threads:[~2008-07-02 15:34 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-07-01 16:34 ocaml parser Christophe Raffalli
2008-07-02  4:48 ` [Caml-list] " Michel Mauny
2008-07-02  7:44   ` Christophe Raffalli
2008-07-02 15:34     ` blue storm

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