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
There's an elephant in the room: Solution to sharing a symbol table
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2007-05-02 (05:58)
From: Joel Reymont <joelr1@g...>
Subject: Re: [Menhir-list] There's an elephant in the room: Solution to sharing a symbol table

On May 2, 2007, at 6:44 AM, Francois Pottier wrote:

> Functors can be applied at run-time (via "let module"), so a  
> functor parameter
> *can* provide a parser with runtime information. I would still  
> recommend the
> %parameter approach, since it is syntactically lighter and more  
> efficient (the
> semantic actions won't be delayed).

I have been butting my head against this for a few days now. Please,  
please provide an example!!! I'm not talking about a general example  
of a %parameter approach but an example of using that approach with a  

Consider this function that should parser a string and return an AST:

let parse str =
   let lexbuf = Lexing.from_string str in
   program (token tab) lexbuf

The token lexer above takes a tab argument before lexbuf but program  
always expects (Lexing.lexbuf -> token) so we give program the  
curried function.

How do you write parse above with the %parameter approach to ensure  
that parse ALWAYS uses a new symbol table that is shared between the  
lexer and the parser in this parsing run?

	Thanks, Joel