English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
[Camlp4] Beta-release
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2006-05-16 (20:16)
From: Aleksey Nogin <nogin@c...>
Subject: Re: [Caml-list] [Camlp4] Beta-release
I have a question/feature request.

For our camlp4 usage (in MetaPRL theorem prover - http://metaprl.org/ ), 
we need to:
- extend the OCaml grammar
- refer to a "state" when parsing the extensions.

Currently we have to put the state in a global ref (yuck!), which causes 
all kinds of difficulties.

Is this something that can be done better in your reimplementation? Can 
something like this be added to your reimplementation?

Basically, I would really like to see camlp4 help with the following:

1) Defining parsers that depend on a shared state that is passed around.

Currently one can either
a) use a global pointer ref, or
b) manually define the productions of "state -> ..." type and manually 
pass the state around.

(a) is obviously bad, but even (b) is not only a lot of extra typing, 
but also means that the execution of productions will be delayed until 
the whole thing is parsed, which would mean that when something goes 
wrong, you would often get a campl4 parsing error instead of a (usually 
more meaningful) error generated by the production code.

2) Allow passing shared state even for grammars that extend things like 
OCaml grammar.

3) (completely unrelated) I wish there was a way to tell camlp4 to 
detect and report conflicts!

P.S. The bulk of our camlp4 code is in 
(the shared state is hidden in a way here - the grammar is created in a 
functor where the input module provides functions like mk_opname; when 
the functor will be instantiated, the functions would be made dependent 
on a number of global refs) and in 
(here we actually extend the OCaml grammar, using some of the stuff from 
term_grammar.ml in that extension).

If you are interested in downloading MetaPRL sources to look at this 
stuff in more detail, please see the download instructions at 

Aleksey Nogin

Home Page: http://nogin.org/
E-Mail: nogin@cs.caltech.edu (office), aleksey@nogin.org (personal)
Office: Moore 04, tel: (626) 395-2200