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 MAA07571; Tue, 17 Jul 2001 12:36:58 +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 MAA07522 for ; Tue, 17 Jul 2001 12:36:57 +0200 (MET DST) Received: from fichte.ai.univie.ac.at (fichte.ai.univie.ac.at [131.130.174.156]) by concorde.inria.fr (8.11.1/8.10.0) with ESMTP id f6HAaub00416; Tue, 17 Jul 2001 12:36:56 +0200 (MET DST) Received: (from markus@localhost) by fichte.ai.univie.ac.at (8.9.3/8.9.3/Debian 8.9.3-21) id MAA12788; Tue, 17 Jul 2001 12:36:55 +0200 Date: Tue, 17 Jul 2001 12:36:55 +0200 From: Markus Mottl To: Francois Pottier Cc: caml-list@inria.fr Subject: Re: [Caml-list] Some sugar for regexp matching using camlp4 Message-ID: <20010717123655.B9902@fichte.ai.univie.ac.at> References: <20010716175406.A25317@pauillac.inria.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <20010716175406.A25317@pauillac.inria.fr>; from Francois.Pottier@inria.fr on Mon, Jul 16, 2001 at 17:54:06 +0200 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Mon, 16 Jul 2001, Francois Pottier wrote: > I have experimented a bit with custom syntax for regular expression > matching. My goal was to implement some high-level constructs on top > of a low-level regexp library such as PCRE. The result of my (modest) > experiment is attached. It is a camlp4 grammar extension, which allows > writing Nice! This example could surely be used to build a convenient special purpose language for text manipulation. > extract x, y, ... matching e against r in e' > > The semantics is as follows. The expression e is evaluated, yielding > a string which is matched against the regular expression r. r must be > either a constant string, or a compiled regular expression; if the > former, pre-compilation code is inserted transparently. Note that it should be possible to assert the required number of subgroups at compile-time if the user supplied a constant string: you'd only have to compile the pattern string to a regexp within the camlp4-rule and check things there. This would even allow you to catch illegal patterns: static typing for regular expression :-) Best regards, Markus Mottl -- Markus Mottl markus@oefai.at Austrian Research Institute for Artificial Intelligence http://www.oefai.at/~markus ------------------- Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr