From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id E300EBC6B for ; Wed, 27 Jun 2007 21:56:49 +0200 (CEST) Received: from ipmail03.adl2.internode.on.net (ipmail03.adl2.internode.on.net [203.16.214.135]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id l5RJulPm002414 for ; Wed, 27 Jun 2007 21:56:49 +0200 X-IronPort-AV: E=Sophos;i="4.16,467,1175437800"; d="scan'208";a="108539581" Received: from ppp59-167-2-129.lns1.syd7.internode.on.net (HELO [192.168.1.201]) ([59.167.2.129]) by ipmail03.adl2.internode.on.net with ESMTP; 28 Jun 2007 05:26:45 +0930 Subject: Re: [Caml-list] The Implicit Accumulator: a design pattern using optional arguments From: skaller To: Brian Hurt Cc: Jon Harrop , caml-list@yquem.inria.fr In-Reply-To: <4682AD06.9080008@janestcapital.com> References: <200706271314.35134.jon@ffconsultancy.com> <46828488.3000006@SmokejumperIT.com> <200706271548.l5RFmiS04436@virtutech.se> <200706271906.07626.jon@ffconsultancy.com> <4682AD06.9080008@janestcapital.com> Content-Type: text/plain Date: Thu, 28 Jun 2007 05:56:39 +1000 Message-Id: <1182974200.11088.1.camel@rosella.wigram> Mime-Version: 1.0 X-Mailer: Evolution 2.10.1 Content-Transfer-Encoding: 7bit X-Miltered: at concorde with ID 4682C0FF.001 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; foo:01 baz:01 foo:01 baz:01 ocamllex:01 sourceforge:01 wrote:01 compile:01 matched:01 matched:01 caml-list:01 expression:02 expression:02 match:02 match:02 On Wed, 2007-06-27 at 14:31 -0400, Brian Hurt wrote: > Actually, what I'd like is a more powerful regular expression engine- > one where I can give multiple different patterns with constant values, > and create a single regular expression that if the first pattern is > matched, the first constant value is matched, etc. Something with a > signature like: > let re = compile [ ("foo", 1); ("bar", 2); ("baz", 3) ] > ~default:(-1);; > > let f str = > match re_match re str with > | 1 -> (* it's a foo *) > | 2 -> (* it's a bar *) > | 3 -> (* it's a baz *) > | -1 -> (* it didn't match *) > ;; > > In other words, something like ocamllex, except dynamic. I think you can do this now? it's just messy: use "(foo)|(bar)|(baz)" and check which group 1, 2 or 3 matches. -- John Skaller Felix, successor to C++: http://felix.sf.net