Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] camlp4 vs. ocamllex/yacc?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2003-01-24 (15:23)
From: Jean-Christophe Filliatre <Jean-Christophe.Filliatre@l...>
Subject: Re: [Caml-list] camlp4 vs. ocamllex/yacc?

 > What are the advantages/disadvantages of using camlp4 vs. a combination of 
 > ocamllex and ocamlyacc?  

For  having  used both  of  them intensively,  I  see  (at least)  the
following advantages of camlp4:

 - it comes with a lexer, saving you the burden of writing one
   (this lexer conforms to ocaml lexical conventions; for prototype
   implementations, it is usually fine)

 - it offers high level grammar constructors such as LIST0, LIST1,
   OPT, ... It results in cleaner and more concise grammars.

Another advantage of camlp4, not of common use, is to propose an ocaml
datatype for grammars: thus grammars can be extended dynamically. This
is not possible with ocamlyacc grammars.

The (sole?)  advantage of  ocamlyacc is when  you already have  a YACC
grammar. Turning it into an ocamlyacc grammar is almost immediate.

 > Is there already a translator like this out there (to save me the effort)?  

There are probably many (Ocaml is, in particular, a good tool to write
compilers) but  this really  depends on your  input syntax  (there are
really *many* ways to write mathematics using ASCII :-).


To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: