From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id CAA20903; Sun, 13 Jan 2002 02:13:10 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id CAA20971 for ; Sun, 13 Jan 2002 02:13:09 +0100 (MET) Received: from c007.snv.cp.net (c007-h011.c007.snv.cp.net [209.228.33.217]) by nez-perce.inria.fr (8.11.1/8.11.1) with SMTP id g0D1D8T16386 for ; Sun, 13 Jan 2002 02:13:08 +0100 (MET) Received: (cpmta 9784 invoked from network); 12 Jan 2002 17:13:01 -0800 Received: from 65.187.194.217 (HELO vaiobambino) by smtp.directvinternet.com (209.228.33.217) with SMTP; 12 Jan 2002 17:13:01 -0800 X-Sent: 13 Jan 2002 01:13:01 GMT From: "Jeff Henrikson" To: Subject: [Caml-list] camlp4: generating keyword on the fly Date: Sat, 12 Jan 2002 20:28:49 -0500 Message-ID: <005201c19bd1$a72e8b00$0b01a8c0@mit.edu> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook 8.5, Build 4.71.2173.0 Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2615.200 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk 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