Version française
Home     About     Download     Resources     Contact us    
Browse thread
Re: [Caml-list] Camlp4 "vs" JSE
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Krishnaswami, Neel <neelk@c...>
Subject: Re: [Caml-list] Camlp4 "vs" JSE
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