Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] camlp4: generating keyword on the fly
[ 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] camlp4: generating keyword on the fly
Hi,

On Sat, Jan 12, 2002 at 08:28:49PM -0500, Jeff Henrikson wrote:

> I want to be able to cook up keywords on the fly using camlp4, and
> it seems like I should be able to do it.

I am not sure what "cook up" means in English, but if you want to give
a string variable as keyword, write it between dollars in the EXTEND
statement:

  let make_one_item_entry entrysym (keyword : string) =
    let tmp = (Grammar.Entry.create Pcaml.gram entrysym) in
    EXTEND
      tmp: [ [ $keyword$ ] ]
      ;
    END;
    tmp;;

  Grammar.Entry.print (make_one_item_entry "happy" "birthday");;

This is an undocumented feature.

-- 
Daniel de RAUGLAUDRE
daniel.de_rauglaudre@inria.fr
http://cristal.inria.fr/~ddr/
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr