caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Camlp4 "vs" JSE
@ 2002-02-06 13:37 Dave Berry
  2002-02-06 14:59 ` Daniel de Rauglaudre
  0 siblings, 1 reply; 5+ messages in thread
From: Dave Berry @ 2002-02-06 13:37 UTC (permalink / raw)
  To: caml-list

Two ex-colleagues of mine published a paper in last year's OOPSLA about
a macro system for Java.  In their paper they briefly mention Camlp4 in
the "related work" section.  They say that because Camlp4 is
grammar-based, it can't guarantee parseability.  Is this true, or did
they not understand Camlp4 properly?

Does anyone here have any more to contribute comparing the two
approaches?

The authors in question are Jonathan Bachrach and Keith Playford, and
the title of their paper is something like "The Java Syntactic
Extender", OOPSLA 2001.

Dave.



-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr


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

* Re: [Caml-list] Camlp4 "vs" JSE
  2002-02-06 13:37 [Caml-list] Camlp4 "vs" JSE Dave Berry
@ 2002-02-06 14:59 ` Daniel de Rauglaudre
  2002-02-06 22:14   ` Chris Hecker
  0 siblings, 1 reply; 5+ messages in thread
From: Daniel de Rauglaudre @ 2002-02-06 14:59 UTC (permalink / raw)
  To: caml-list

Hi,

On Wed, Feb 06, 2002 at 01:37:00PM -0000, Dave Berry wrote:

> Two ex-colleagues of mine published a paper in last year's OOPSLA about
> a macro system for Java.  In their paper they briefly mention Camlp4 in
> the "related work" section.  They say that because Camlp4 is
> grammar-based, it can't guarantee parseability.  Is this true, or did
> they not understand Camlp4 properly?

Yes, Camlp4 works with syntax trees, not with text.

-- 
Daniel de RAUGLAUDRE
daniel.de_rauglaudre@inria.fr
http://cristal.inria.fr/~ddr/
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr


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

* Re: [Caml-list] Camlp4 "vs" JSE
  2002-02-06 14:59 ` Daniel de Rauglaudre
@ 2002-02-06 22:14   ` Chris Hecker
  2002-02-07  5:25     ` Daniel de Rauglaudre
  0 siblings, 1 reply; 5+ messages in thread
From: Chris Hecker @ 2002-02-06 22:14 UTC (permalink / raw)
  To: Daniel de Rauglaudre, caml-list


>> the "related work" section.  They say that because Camlp4 is
>> grammar-based, it can't guarantee parseability.  Is this true, or did
>> they not understand Camlp4 properly?
>Yes, Camlp4 works with syntax trees, not with text.

What does that mean, "can't guarantee parseability?"

Chris


-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr


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

* Re: [Caml-list] Camlp4 "vs" JSE
  2002-02-06 22:14   ` Chris Hecker
@ 2002-02-07  5:25     ` Daniel de Rauglaudre
  0 siblings, 0 replies; 5+ messages in thread
From: Daniel de Rauglaudre @ 2002-02-07  5:25 UTC (permalink / raw)
  To: caml-list

Hi,

On Wed, Feb 06, 2002 at 02:14:13PM -0800, Chris Hecker wrote:

> What does that mean, "can't guarantee parseability?"

I wondered that also but I think they meant that their preprocessor
can treat even non parsable input. For exemple, in C, if your input
is:
      /* main () { printf("hello, world"); }

It is not parsable since the comment does not end, but if your
preprocessor is:
      sed -e 's|/\*||'

Which removes the initial /*, the C compiler can parse.

Camlp4 is a preprocessor which parses, respecting a "grammar" (it's
why they say "grammar-based"), what sed or /lib/cpp don't really do:
they just look at what is interesting for them, even if the rest is
not correct C.

Well, it is the way I interpreted what they said.

-- 
Daniel de RAUGLAUDRE
daniel.de_rauglaudre@inria.fr
http://cristal.inria.fr/~ddr/
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr


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

* Re: [Caml-list] Camlp4 "vs" JSE
@ 2002-02-07 14:08 Krishnaswami, Neel
  0 siblings, 0 replies; 5+ messages in thread
From: Krishnaswami, Neel @ 2002-02-07 14:08 UTC (permalink / raw)
  To: caml-list

Daniel de Rauglaudre [mailto:daniel.de_rauglaudre@inria.fr] wrote:
> On Wed, Feb 06, 2002 at 02:14:13PM -0800, Chris Hecker wrote:
> 
> > What does that mean, "can't guarantee parseability?"
> 
> Camlp4 is a preprocessor which parses, respecting a "grammar" (it's
> why they say "grammar-based"), what sed or /lib/cpp don't really do:
> they just look at what is interesting for them, even if the rest is
> not correct C.
> 
> Well, it is the way I interpreted what they said.

I don't think this is it. The way I interpreted it is that Camlp4 works
basically by letting the user add productions to the grammar. However, 
it looks like you can make Camlp4 crash at runtime by adding insufficiently 
left-factored grammar rules, since it uses recursive descent parsing. 
(Can you make Camlp4 loop with left-recursive rules? I haven't used it 
very much, so I don't know.)

An example of a system that can "guarantee parseability" is the macro system
that Schwartzbach and Brabrand developed for the Bigwig project. Their
system
will detect and reject at compile time any macro definitions that would not
be parseable with their LL(1) parser. So the compiler guarantees
parseability
in the sense that you can't write a program that is generated by the grammar
but can't be parsed by the compiler. It's kind of like static typing for
macros.

JSE doesn't guarantee parseability, because it's a procedural macro system.
Since you can do arbitrary computations at compile time, obviously you can't
guarantee termination. 

--
Neel Krishnaswami
neelk@cswcasa.com
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr


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

end of thread, other threads:[~2002-02-07 14:03 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-02-06 13:37 [Caml-list] Camlp4 "vs" JSE Dave Berry
2002-02-06 14:59 ` Daniel de Rauglaudre
2002-02-06 22:14   ` Chris Hecker
2002-02-07  5:25     ` Daniel de Rauglaudre
2002-02-07 14:08 Krishnaswami, Neel

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