English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
quasiquoting: 3 parsers for camlp4 vs 1 for haskell?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2009-04-23 (14:54)
From: Nicolas Pouillard <nicolas.pouillard@g...>
Subject: Re: [Caml-list] quasiquoting: 3 parsers for camlp4 vs 1 for haskell?
Excerpts from Jon Harrop's message of Thu Apr 23 01:19:09 +0200 2009:
> On Friday 17 April 2009 19:24:31 Joel Reymont wrote:
> >  From the quasiquoting paper by Geoffrey Mainland [1], page 7:
> >
> > "The major advantage of our approach over that of camlp4
> > is that we demonstrate how to use generic programming
> > to reuse a single parser to parse quasiquoted patterns,
> > quasiquoted expressions and plain syntax that does not
> > include antiquotes. Because OCaml does not support generic
> > programming out of the box,
> I have no idea what he meant by this.
> > in camlp4 this would require three separate parsers,
> AFAICT, that was not true when he wrote it (Sept 2007) and is not true today.

There was indeed three different parsers for OCaml-like syntax in the old
camlp4. Actually there was one classical parser for the official/original
OCaml syntax but this one was not embeddable in quotations. There was also
two parsers for the revised syntax one being the classical one and the other
being for quotations.

> > each generating different representations of the same concrete syntax."
> That has never been true.

We are talking about quotations here, and I can confirm that the two parsers
for the revised syntax where generating to different representations of the
concrete syntax.

Example (simplified):
  f 42     => App (Var "f") (Int "42")
  <<f 42>> => App (App (Con "Var") (Str "f")) (App (Con "Int") (Str "42"))

The new version of camlp4 use only one grammar for the revised syntax (instead
of two) and a grammar extension for the official/original syntax.

Best regards,

Nicolas Pouillard