Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] RE: 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: Jeff Henrikson <jehenrik@y...>
Subject: [Caml-list] RE: camlp4: generating keyword on the fly
Aha.  Never mind.  I figured it out.  Use $keyword$ around it.  Sorry.


Jeff Henrikson

> -----Original Message-----
> From: Jeff Henrikson [mailto:jehenrik@yahoo.com]
> Sent: Saturday, January 12, 2002 8:29 PM
> To: caml-list@inria.fr
> Subject: camlp4: generating keyword on the fly
> 
> 
> 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.  But this is 
> as far as I get.  This function compiles:
> 
> 
> let make_one_item_entry entrysym (keyword : string) =
>   let tmp = (Grammar.Entry.create Pcaml.gram entrysym) in
>   EXTEND
>     tmp: [ [ "birthday" ] ]
>     ;
>   END;
>   tmp;;
> 
> Grammar.Entry.print (make_one_item_entry "happy" "birthday");;
> 
> # [ LEFTA
>   [ "birthday" ] ]
> - : unit = ()
> 
> 
> But this one does not:
> 
> 
> 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");;
> 
> 
> Note that this looks right but isn't:
> 
> 
> let make_one_item_entry entrysym (keyword : string) =
>   let tmp = (Grammar.Entry.create Pcaml.gram entrysym) in
>   let tmp2 = (Grammar.Entry.create Pcaml.gram keyword) in
>   EXTEND
>     tmp: [ [ tmp2 ] ]
>     ;
>   END;
>   tmp;;
> 
> Grammar.Entry.print (make_one_item_entry "happy" "birthday");;
> 
> # [ LEFTA
>   [ birthday ] ]
> - : unit = ()
> 
> 
> (The quotes are missing)  I'm new at camlp4, so I don't know if my jargon for explaining this is right, but: 
> 
> I can get an empty entry with Grammar.Entry.create, but the only way to extend it seems to be with EXTEND which so far 
> as I can see only takes string constants.  Does this make sense?
> 
> 
> Jeff Henrikson
> 
> 
-------------------
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