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] Documenting CamlP4 syntax extensions
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Daniel de Rauglaudre <daniel.de_rauglaudre@i...>
Subject: Re: [Caml-list] Documenting CamlP4 syntax extensions

On Fri, Sep 13, 2002 at 10:15:45PM +0400, Mitya Lomov wrote:
> Daniel de Rauglaudre wrote:
> > The function Grammar.Entry.print prints the rules of a grammar
> > entry. For example, the code:
> >     Grammar.Entry.print Pcaml.expr
> > prints the rules for expressions.
> This function is great for development purposes.
> But for documenting syntax extensions its output is not 
> quite acceptable, and coverting its output to more readable
> form essentialy involves parsing camlp4 grammar definitions
> (a la pa_extend.cmo). 
> Moreover, one have to build a transitive closure of all grammar
> entries referenced from an entry to get a complete doc...

Ok. For the "transitive closure" point, I added two functions:
which iterate an entry and transitively all the entries it calls.

This is committed in the current CVS version of Camlp4.

For example:
   $ cat
     (fun e ->
        Format.printf "@[<v 2>%s:@ %a@]@." e.Gramext.ename
          Grammar.print_entry e)
     (Grammar.Entry.obj Pcaml.expr)

This prints all entries of the OCaml grammar (normal syntax) starting
with "expr":
   $ ocaml -I +camlp4 camlp4o.cma

This example uses "Grammar.print_entry" (equivalent to Grammar.Entry.print
for entries "obj"). If that display does not fit you, you can take its code
in camlp4/lib/ and change it so that it is printed in LateX,
HTML, XML or any output format you want.

I can help, if needed, or I can do it if you or somebody tells me
how you want it to be displayed.

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