caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Ocaml 3.01 and camlp4 syntax?
@ 2008-11-12 23:22 Erik de Castro Lopo
  2008-11-13  1:28 ` [Caml-list] " Martin Jambon
  0 siblings, 1 reply; 3+ messages in thread
From: Erik de Castro Lopo @ 2008-11-12 23:22 UTC (permalink / raw)
  To: caml-list

Hi all,

Mostly out of curiosity, I'm having a look at the efuns Emacs
clone written in Ocaml:

    http://pauillac.inria.fr/cdrom/prog/unix/efuns/eng.htm

and trying to compile it with a recent Ocaml compiler like 3.10.2.

>From the files, it seems that the last version of Ocaml this code
compiled with was 3.01 (around the year 2000?). I've managed to find
fixes for a bunch of problems.

One of those problems was that one of the files (common/options.ml)
had code like this:

    open Genlex
  
    let lexer = make_lexer [ "=" ; "{" ; "}"; "["; "]"; ";" ; "("; ")"; ","; "."]
  
    let rec parse_gwmlrc = parser
        [< id = parse_id; 'Kwd "="; v = parse_option ; 
          eof = parse_gwmlrc >] -> (id, v) :: eof
    | [< >] -> []

which the current compiler complained about "[<". A bit of googling
suggested that this was in fact camlp4 source code. Sure enough,
renaming that file to pa_options.ml and running it throught camlp4
resulted in a file that the standard compiler digested quite happily.

I've now come to another file gwml/afterstep.mll that seems to be
ocamllex source code but again has these camlp4 like extensions.
Unfortunately camlp4 doesn't like this file, probably because it
has ocamllex syntax instead of ocaml syntax.

So, I have two questions :

 1) Did early versions of ocaml (say up to and including 3.01) handle
    constructs like those above that were later removed and and added
    to camlp4 instead?

 2) Any suggestions on how to handle the camlp4 syntax stuff in an
    ocamllex source file? Obviously, this code could be extracted
    and placed in its own file but I'm open to other suggestions.

Cheers,
Erik
-- 
-----------------------------------------------------------------
Erik de Castro Lopo
-----------------------------------------------------------------
Seen on comp.lang.python:
Q : If someone has the code in python for a buffer overflow,
    please post it.
A : Python does not support buffer overflows, sorry.


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

* Re: [Caml-list] Ocaml 3.01 and camlp4 syntax?
  2008-11-12 23:22 Ocaml 3.01 and camlp4 syntax? Erik de Castro Lopo
@ 2008-11-13  1:28 ` Martin Jambon
  2008-11-13  4:47   ` Erik de Castro Lopo
  0 siblings, 1 reply; 3+ messages in thread
From: Martin Jambon @ 2008-11-13  1:28 UTC (permalink / raw)
  To: caml-list

Erik de Castro Lopo wrote:
> Hi all,
> 
> Mostly out of curiosity, I'm having a look at the efuns Emacs
> clone written in Ocaml:
> 
>     http://pauillac.inria.fr/cdrom/prog/unix/efuns/eng.htm
> 
> and trying to compile it with a recent Ocaml compiler like 3.10.2.
> 
>>From the files, it seems that the last version of Ocaml this code
> compiled with was 3.01 (around the year 2000?). I've managed to find
> fixes for a bunch of problems.
> 
> One of those problems was that one of the files (common/options.ml)
> had code like this:
> 
>     open Genlex
>   
>     let lexer = make_lexer [ "=" ; "{" ; "}"; "["; "]"; ";" ; "("; ")"; ","; "."]
>   
>     let rec parse_gwmlrc = parser
>         [< id = parse_id; 'Kwd "="; v = parse_option ; 
>           eof = parse_gwmlrc >] -> (id, v) :: eof
>     | [< >] -> []
> 
> which the current compiler complained about "[<". A bit of googling
> suggested that this was in fact camlp4 source code. Sure enough,
> renaming that file to pa_options.ml and running it throught camlp4
> resulted in a file that the standard compiler digested quite happily.
> 
> I've now come to another file gwml/afterstep.mll that seems to be
> ocamllex source code but again has these camlp4 like extensions.
> Unfortunately camlp4 doesn't like this file, probably because it
> has ocamllex syntax instead of ocaml syntax.
> 
> So, I have two questions :
> 
>  1) Did early versions of ocaml (say up to and including 3.01) handle
>     constructs like those above that were later removed and and added
>     to camlp4 instead?

Exactly.

The 3.10 manual says:


7.2  Streams and stream parsers

The syntax for streams and stream parsers is no longer part of the
Objective Caml language, but available through a Camlp4 syntax
extension. See the Camlp4 reference manual for more information. Support
for basic operations on streams is still available through the
Stream[Stream] module of the standard library. Objective Caml programs
that use the stream parser syntax should be compiled with the -pp
camlp4o option to ocamlc and ocamlopt. For interactive use, run ocaml
and issue the #load "camlp4o.cma";; command.



>  2) Any suggestions on how to handle the camlp4 syntax stuff in an
>     ocamllex source file? Obviously, this code could be extracted
>     and placed in its own file but I'm open to other suggestions.

I don't know. Have you tried ocamllex followed by camlp4?


Martin
-- 
http://mjambon.com/


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

* Re: [Caml-list] Ocaml 3.01 and camlp4 syntax?
  2008-11-13  1:28 ` [Caml-list] " Martin Jambon
@ 2008-11-13  4:47   ` Erik de Castro Lopo
  0 siblings, 0 replies; 3+ messages in thread
From: Erik de Castro Lopo @ 2008-11-13  4:47 UTC (permalink / raw)
  To: caml-list

Martin Jambon wrote:

> Exactly.
> 
> The 3.10 manual says:
> 
> 7.2  Streams and stream parsers
> 
> The syntax for streams and stream parsers is no longer part of the
> Objective Caml language, but available through a Camlp4 syntax
> extension.

Ah, thank you. I wasn't expecting that in the current manual,
only in the first one or two manual versions after the change.

> >  2) Any suggestions on how to handle the camlp4 syntax stuff in an
> >     ocamllex source file? Obviously, this code could be extracted
> >     and placed in its own file but I'm open to other suggestions.
> 
> I don't know. Have you tried ocamllex followed by camlp4?

I tried it, but ocamllex errored out on the camlp4 code and
if I do camlp4 first, it errors out on the ocamllex code.

Cheers,
Erik
-- 
-----------------------------------------------------------------
Erik de Castro Lopo
-----------------------------------------------------------------
"Perl as a language has less a design than a thousand special
features flying in close formation."
-- From the c2 wiki


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

end of thread, other threads:[~2008-11-13  4:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-11-12 23:22 Ocaml 3.01 and camlp4 syntax? Erik de Castro Lopo
2008-11-13  1:28 ` [Caml-list] " Martin Jambon
2008-11-13  4:47   ` Erik de Castro Lopo

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