Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] ocamllex/yacc and camlp4
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Pierre Weis <pierre.weis@i...>
Subject: Re: [Caml-list] ocamllex/yacc and camlp4
Hi,

> > Quick question: why are ocamllex and ocamlyacc not implemented with
> > camlp4?  They seem to be doing exactly what camlp4 is there for, and I
> > think would serve as great camlp4 examples (plus being able to extend
> > *their* syntax could be very powerful indeed.)
> > 
> > Thanks,
> > John
> 
> Hello,
> 
> First there is history, ocamllex and ocamlyacc predate camlp4, thus
> they were not written with camlp4 initially.
> 
> Second there is bootstrap. Since the lexer and parser of ocamlc itself
> are written with ocamllex/ocamlyacc, Making these tools to depend on
> camlp4 would include camlp4 in the bootstrap cycle of ocamlc.
> The resulting situation would complicate bootstraping ocamlc.
> 
> Of course there could be camlp4 versions of ocamllex/ocamlyacc in
> addition to ocamllex/ocamlyacc versions of ocamllex/ocamlyacc. Well,
> nobody ever thought about doing that, I guess.
> 
> -- Luc Maranget

I would add two points to Luc's answer:

 1) ocamllex and ocamlyacc implementation technologies are damned fast
and it is difficult to compete with them using streams.

 2) Semantics differences between Yacc and functionnal parsing are
large and complex, so that implementing the precise Yacc semantics
with its reduce/reduce and shift/reduce conflicts and the default
conflicts resolution that Yacc also implements could not be a trivial
task.

Last but not least, the actual ocamllex/ocamlyacc implementations work
pretty well, so that there is no clear necessity to rewrite them.

In conclusion: pure Camlp4 implementation of ocamllex/ocamlyacc is
still an interesting and challenging progamming task for the next few
years, if you (or someone else) had the will and time to provide two
``great camlp4 examples'' to the rest of us...

Happy hacking :)

Pierre Weis

INRIA, Projet Cristal, Pierre.Weis@inria.fr, http://pauillac.inria.fr/~weis/


-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners