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 HAA09810; Tue, 5 Oct 2004 07:38:51 +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 HAA15458 for ; Tue, 5 Oct 2004 07:38:50 +0200 (MET DST) Received: from is.intellij.net (mail.intellij.net [213.182.181.98]) by nez-perce.inria.fr (8.13.0/8.13.0) with SMTP id i955cnva001289 for ; Tue, 5 Oct 2004 07:38:49 +0200 Received: (qmail 22569 invoked by uid 89); 5 Oct 2004 05:38:48 -0000 Received: from unknown (HELO ?192.168.1.43?) (dsl@intellij.net@192.168.1.43) by mail.intellij.net with SMTP; 5 Oct 2004 05:38:48 -0000 Message-ID: <41623367.9060504@jetbrains.com> Date: Tue, 05 Oct 2004 09:38:47 +0400 From: Dmitry Lomov Organization: JetBrains Inc. User-Agent: Mozilla Thunderbird 0.7.2 (Windows/20040707) X-Accept-Language: en-us, en MIME-Version: 1.0 To: ocaml ml CC: Pietro Abate Subject: Re: [Caml-list] camlp4 question... References: <20041005034509.GA12748@pulp.anu.edu.au> In-Reply-To: <20041005034509.GA12748@pulp.anu.edu.au> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Miltered: at nez-perce with ID 41623369.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; lomov:01 lomov:01 jetbrains:01 caml-list:01 camlp:01 pietro:01 abate:01 failwith:01 expr:01 lident:01 expr:01 failwith:01 ffff:99 lident:01 jetbrains:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Pietro Abate wrote: > Hi all, > > I'd like to write a small extension to transform > > let f = ... > > in > > let f new_id = > match new_id with > |[a;b;c] -> ... > |_ -> failwith "wrong arguments" > > I've tried with something like: > expr: LEVEL "simple" > [[ > "let"; OPT "rec"; "<"; l = LIST1 LIDENT; ">"; $list:pel$ "in" e = expr -> > <:expr< let .... = function [] -> failwith "ffff" | $list:l$ -> $e$ >> > ]]; > > but I'm stuck... In particular, how can I parse $list:pel$ ? > pel = LIST patt ? Do check your syntax once again. $list:pel$ is an antiquotation, and not a parsing rule. As such, it cannot appear to the left of '->'. The LHS should look about like that: expr: LEVEL "let" (* sic! *) [[ "let"; OPT "rec"; LIDENT; "<"; LIST patt; ">";"="; expr;"in" expr -> .... ]] RHS should be quite straightforward (you should bind subparsing results, of course) HTH, Friendly, Dmitry -- Dmitry Lomov JetBrains Inc. http://www.jetbrains.com "Develop With Pleasure!" ------------------- 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