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 LAA23263; Tue, 26 Nov 2002 11:36:13 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id LAA22691 for caml-list@pauillac.inria.fr; Tue, 26 Nov 2002 11:36:13 +0100 (MET) Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id BAA10473 for ; Tue, 26 Nov 2002 01:07:36 +0100 (MET) Received: from axiom.anu.edu.au (axiom.anu.edu.au [150.203.127.200]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id gAQ07YX04417 for ; Tue, 26 Nov 2002 01:07:35 +0100 (MET) Received: from zed.cipputi.it (rsisedhcp-166.anu.edu.au [150.203.126.166]) by axiom.anu.edu.au (8.11.2/8.11.2/SuSE Linux 8.11.1-0.5) with ESMTP id gAQ07VC20934 (using TLSv1/SSLv3 with cipher EDH-RSA-DES-CBC3-SHA (168 bits) verified NO) for ; Tue, 26 Nov 2002 11:07:31 +1100 Received: from zed.cipputi.it (localhost [127.0.0.1]) by zed.cipputi.it (8.12.6/8.12.6/Debian-8) with ESMTP id gAQ07Jlg021925 for ; Tue, 26 Nov 2002 11:07:19 +1100 Received: (from abate@localhost) by zed.cipputi.it (8.12.6/8.12.6/Debian-8) id gAQ07Jtj021923 for caml-list@inria.fr; Tue, 26 Nov 2002 11:07:19 +1100 Date: Tue, 26 Nov 2002 11:07:19 +1100 From: Pietro Abate To: caml-list@inria.fr Subject: [Caml-list] camlp4 and let binding... Message-ID: <20021126000718.GA20511@zed> Mail-Followup-To: Pietro Abate , caml-list@inria.fr Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.4i X-Operating-System: GNU/Linux X-Organization: Research School of Information Science and Engineering (Austrialian National University) Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk hi all, I'm having few problems writing an camlp4 grammar for my project. I would like to rewrite something something like let rule_1 = x & y ; z => x + y ; z ;; in a piece of ocaml code like let rule_r = let pattern = let p1 = And(x,y) in let p2 = Star in (p1,p2) in let action s = match s with |And(x,y)::z -> Plus(x,y)::z |_ -> failwith ("error") in new rule(pattern,action) I wrote something that, of course, doesn't work. My major problems are about the inner let definitions. How can I chain all let defintions in the list ? EXTEND str_item: [[ "let"; r = LIDENT; "="; n = complexnum "=>"; d = complexnum -> let pref = "rule" ^ r in let definition = n @ (genaction n d) in (****) > ]];; complexnum: [[ n = LIST1 numerator SEP ';' -> (<:patt< "pattern" >>, n) ]]; numerator: [[ pel = LIST1 pattern SEP ';' -> pel >> ]]; pattern: [[ n = LIDENT -> (<:patt< $genid$>, ) (***) n1 = LIDENT; '&'; n2 = LIDENT -> (<:patt< $genid$>, ) n1 = LIDENT; '+'; n2 = LIDENT -> (<:patt< $genid$>, ) ]]; END (***) genid is a simple function that generates unique identifiers... (****) genaction should be a function that generates the action (but I still have no idea how to write it...) tnx for your help, p -- pgp key: 1024D/8A091922 2000-10-18 Pietro Abate Key fingerprint = 5111 D91B 5E0C 5CE6 FDA3 5EF4 6120 E18E 8A09 1922 public key avalaible via public key server at wwwkeys.eu.pgp.net "Who says that something cannot be done should not interrupt a man who is doing it." --- Old Chinese Proverb ------------------- 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