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 LAA27763; Thu, 3 Apr 2003 11:26:04 +0200 (MET DST) 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 LAA24274 for ; Thu, 3 Apr 2003 11:26:03 +0200 (MET DST) Received: from ebene.inrialpes.fr (ebene.inrialpes.fr [194.199.18.70]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id h339Q2920971 for ; Thu, 3 Apr 2003 11:26:02 +0200 (MET DST) Received: from imap-serv.inrialpes.fr (imap-serv.inrialpes.fr [194.199.18.72]) by ebene.inrialpes.fr (8.11.6/8.11.6) with ESMTP id h339Q1Y12362 for ; Thu, 3 Apr 2003 11:26:01 +0200 (MEST) Received: from inrialpes.fr (adret.inrialpes.fr [194.199.23.65]) by imap-serv.inrialpes.fr (8.11.6/8.11.3/ImagV2) with ESMTP id h339Q1F04496 for ; Thu, 3 Apr 2003 11:26:01 +0200 (MEST) Message-ID: <3E8BFE27.9040602@inrialpes.fr> Date: Thu, 03 Apr 2003 11:25:59 +0200 From: Frederic Tronel Organization: INRIA Rhone-Alpes User-Agent: Mozilla/5.0 (X11; U; SunOS sun4u; en-US; rv:1.1) Gecko/20030204 X-Accept-Language: en-us, en MIME-Version: 1.0 To: caml-list@inria.fr Subject: [Caml-list] A question about Camlp4 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Spam: no; 0.00; tronel:01 inrialpes:01 camlp:01 lotos:01 expr:01 optionnal:01 compiler:01 caml:01 ast:02 match:02 unbound:02 canonical:03 readability:03 subset:03 trick:03 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Hi list, I'm using camlp4 in order to embed a scripting language within my caml programs. I've already done this one year ago for a subset of Lotos verification language, and I'm extending this work. I'm facing a difficulty. Here is a canonical example of the problem: EXTEND: rule1: ..... -> <:expr< >> (* A rule that generate a ML AST *) rule2: OPT a = rule1 ..... -> let b = match a with None -> <:expr> Some x -> <:expr> in <:expr< ATypeConstructor $b$>> ... END I have to do this small trick for each optionnal symbol in each rule, (this is also true for list meta symbols introduced by LIST0, LIST1 ...). It would greatly improve readability of my program, if I could define a small function outside from the grammar extension which would do: optionToAst o = match o with None -> <:expr> Some x -> <:expr> However if I do this the compiler complains about unbound value "loc". Thanks for your help. Best regards, Frederic Tronel. ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners