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 VAA09657; Fri, 4 Oct 2002 21:28:09 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f 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 VAA09515 for ; Fri, 4 Oct 2002 21:28:08 +0200 (MET DST) X-SPAM-Warning: Sending machine is listed in blackholes.five-ten-sg.com Received: from athlon.baretta.com (r-mi214-6a66.tin.it [62.211.4.66]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id g94JS7507418; Fri, 4 Oct 2002 21:28:07 +0200 (MET DST) Received: from baretta.com (localhost.localdomain [127.0.0.1]) by athlon.baretta.com (Postfix) with ESMTP id C01EA27246; Fri, 4 Oct 2002 21:38:09 +0200 (CEST) Message-ID: <3D9DEE21.7040604@baretta.com> Date: Fri, 04 Oct 2002 21:38:09 +0200 From: Alessandro Baretta Organization: Baretta srl -- www.baretta.com User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.1) Gecko/20020826 X-Accept-Language: it, en MIME-Version: 1.0 To: Luc Maranget , Ocaml Subject: Re: [Caml-list] Pattern matching and strings References: <200210041514.RAA0000017577@beaune.inria.fr> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Luc Maranget wrote: > I have thought about that a little. > > My first guess is that such matching should be distinct from > ordinary PM, mixing the two would be an implementor nightmare. > > My second guess is that what you want is regexp matching + a construct > for binding subparts of the matched string (maybe I am wrong here). > > Using ocamllex syntax for patterns (+ as) your exemple could be written > > regexpmatch s with > | "foo" (_* as x) -> foo x > | "bar" (_* as x) -> bar x > | _* -> raise Unrecognized This is basically what I was looking for. > This would be much nicer than using various regexp packages API, the > real add-on being the variables in place of \1, \2 etc. Precisely. > ... > > In fact such, an extension is probably feasible using camlp4 and this > would probably be the best solution, to avoid extra-complexity in the > compiler itself. I really must get around to learning Camlp4. Why did no one teach it to me when I was at the X? > In the end, do not hold your breath. I won't probably do that. > But it can be a interesting project for a compiler course... > > --Luc ;) Alex ------------------- 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