Browse thread
[Caml-list] Documenting CamlP4 syntax extensions
-
Mitya Lomov
-
Daniel de Rauglaudre
-
Mitya Lomov
- Daniel de Rauglaudre
-
Mitya Lomov
-
Daniel de Rauglaudre
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ 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 |
Hi,
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:
Grammar.iter_entry
Grammar.fold_entry
which iterate an entry and transitively all the entries it calls.
This is committed in the current CVS version of Camlp4.
For example:
$ cat foo.ml
Grammar.iter_entry
(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 foo.ml
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/grammar.ml 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.
--
Daniel de RAUGLAUDRE
daniel.de_rauglaudre@inria.fr
http://cristal.inria.fr/~ddr/
-------------------
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