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 IAA31899; Fri, 23 May 2003 08:31:47 +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 IAA31749 for ; Fri, 23 May 2003 08:31:46 +0200 (MET DST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id h4N6VeH21355; Fri, 23 May 2003 08:31:40 +0200 (MET DST) Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id IAA31844; Fri, 23 May 2003 08:31:39 +0200 (MET DST) From: Pierre Weis Message-Id: <200305230631.IAA31844@pauillac.inria.fr> Subject: Re: [Caml-list] ocamllex, regular expression syntax In-Reply-To: <20030522205632.GA2130@kunz.ratzer> from Stefan Heimann at "May 22, 103 10:56:33 pm" To: lists@stefanheimann.net (Stefan Heimann) Date: Fri, 23 May 2003 08:31:39 +0200 (MET DST) Cc: caml-list@inria.fr X-Mailer: ELM [version 2.4ME+ PL28 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam: no; 0.00; pierre:01 weis:01 caml-list:01 catch-all:01 cristal:01 caml:01 syntax:02 imply:02 constructs:02 match:02 harder:02 module:03 suppose:03 str:05 mean:05 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Hi, [...] > But the regular expression syntax in the Str module looks "normal" to > me. > > Regular expressions like this > > "[^"\\]*(\\.[^"\\]*)*" > > are not easy to read, I suppose you did not try this, since it is not a legal regular expression. I guess you mean "[^\\"\\]*(\\.[^\\"\\]*)*" (Hence, the ``normal looking'' of those reg-exps does not imply simple, clear, and natural syntax !) > but with the ocamllex syntax it is even more > difficult: > > '"'[^'"''\\']*('\\'_[^'"''\\']*)*'"' > > (and harder to write). It is not so clear to me: the ' conventions are exactly those of the language (hence there is no need to \\ the " symbols), the _ gets its "normal" meaning of ``whatever'' or ``catch all case'' pattern... > Is this just for historical reason or is there a practical reason for > this syntax? I'm just curious... It's just natural: you would start by giving syntax to match chars, hence you ``naturally'' write them inside quotes following the Caml convention. The rest of the regular expressions constructs, succession, alternative, repetitition, range and catch-all just follow almost automatically. Regards, Pierre Weis INRIA, Projet Cristal, Pierre.Weis@inria.fr, http://pauillac.inria.fr/~weis/ ------------------- 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