caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* quasiquoting: 3 parsers for camlp4 vs 1 for haskell?
@ 2009-04-17 18:24 Joel Reymont
  2009-04-17 20:06 ` [Caml-list] " Jake Donham
  2009-04-22 23:19 ` Jon Harrop
  0 siblings, 2 replies; 5+ messages in thread
From: Joel Reymont @ 2009-04-17 18:24 UTC (permalink / raw)
  To: O'Caml Mailing List

 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, in camlp4 this would require
three separate parsers, each generating different
representations of the same concrete syntax."

Can someone shed light on how, where and why three different
parsers are required for camlp4? Is this still the case with 3.11?

	Thanks, Joel

[1] http://www.eecs.harvard.edu/~mainland/ghc-quasiquoting/

---
Mac hacker with a performance bent
http://linkedin.com/in/joelreymont




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

* Re: [Caml-list] quasiquoting: 3 parsers for camlp4 vs 1 for haskell?
  2009-04-17 18:24 quasiquoting: 3 parsers for camlp4 vs 1 for haskell? Joel Reymont
@ 2009-04-17 20:06 ` Jake Donham
  2009-04-22 23:19 ` Jon Harrop
  1 sibling, 0 replies; 5+ messages in thread
From: Jake Donham @ 2009-04-17 20:06 UTC (permalink / raw)
  To: Joel Reymont; +Cc: O'Caml Mailing List

On Fri, Apr 17, 2009 at 11:24 AM, Joel Reymont <joelr1@gmail.com> wrote:
> Can someone shed light on how, where and why three different
> parsers are required for camlp4? Is this still the case with 3.11?

I haven't read the Mainland paper so I don't know exactly what he's
talking about, but with the MetaGenerator module in Camlp4 you can use
one parser for all three tasks.

Antiquotations can be used in pattern matching (you can see this all
over the Camlp4 source for the OCaml AST). Don't be misled by my
jsgen.ml; it's just not finished.

Jake


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

* Re: [Caml-list] quasiquoting: 3 parsers for camlp4 vs 1 for haskell?
  2009-04-17 18:24 quasiquoting: 3 parsers for camlp4 vs 1 for haskell? Joel Reymont
  2009-04-17 20:06 ` [Caml-list] " Jake Donham
@ 2009-04-22 23:19 ` Jon Harrop
  2009-04-23  2:17   ` Geoffrey Mainland
  2009-04-23 14:53   ` Nicolas Pouillard
  1 sibling, 2 replies; 5+ messages in thread
From: Jon Harrop @ 2009-04-22 23:19 UTC (permalink / raw)
  To: caml-list, mainland

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.

> each generating different representations of the same concrete syntax."

That has never been true.

> Can someone shed light on how, where and why three different
> parsers are required for camlp4?

I've CC'd the author. Perhaps he can shed some light on this.

-- 
Dr Jon Harrop, Flying Frog Consultancy Ltd.
http://www.ffconsultancy.com/?e


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

* Re: [Caml-list] quasiquoting: 3 parsers for camlp4 vs 1 for haskell?
  2009-04-22 23:19 ` Jon Harrop
@ 2009-04-23  2:17   ` Geoffrey Mainland
  2009-04-23 14:53   ` Nicolas Pouillard
  1 sibling, 0 replies; 5+ messages in thread
From: Geoffrey Mainland @ 2009-04-23  2:17 UTC (permalink / raw)
  To: Jon Harrop; +Cc: caml-list

On Thu, Apr 23, 2009 at 12:19:09AM +0100, Jon Harrop wrote:
> 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.
> 
> > each generating different representations of the same concrete syntax."
> 
> That has never been true.
> 
> > Can someone shed light on how, where and why three different
> > parsers are required for camlp4?
> 
> I've CC'd the author. Perhaps he can shed some light on this.

I actually spoke with Nicolas Pouillard about this at the workshop, and
he informed me that his rewrite of camlp4 for the 3.10 release included
a facility for translating a value into an OCaml AST representing that
value, so yes, that statement is now incorrect. I think Jake Donham's
reply to Joel's message of 4/15 made this clear and even helpfully
pointed to some code.

As for my work, I hope that anyone reading the paper will find the
technique I used to provide this functionality in the Haskell
implementation of quasiquotation both elegant and easy to understand.

Geoff


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

* Re: [Caml-list] quasiquoting: 3 parsers for camlp4 vs 1 for haskell?
  2009-04-22 23:19 ` Jon Harrop
  2009-04-23  2:17   ` Geoffrey Mainland
@ 2009-04-23 14:53   ` Nicolas Pouillard
  1 sibling, 0 replies; 5+ messages in thread
From: Nicolas Pouillard @ 2009-04-23 14:53 UTC (permalink / raw)
  To: Jon Harrop; +Cc: caml-list, mainland

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


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

end of thread, other threads:[~2009-04-23 14:54 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-04-17 18:24 quasiquoting: 3 parsers for camlp4 vs 1 for haskell? Joel Reymont
2009-04-17 20:06 ` [Caml-list] " Jake Donham
2009-04-22 23:19 ` Jon Harrop
2009-04-23  2:17   ` Geoffrey Mainland
2009-04-23 14:53   ` Nicolas Pouillard

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