From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Delivered-To: caml-list@yquem.inria.fr Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id 51D70BB91 for ; Thu, 27 Jan 2005 18:20:09 +0100 (CET) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id j0RHK8XK030176 for ; Thu, 27 Jan 2005 18:20:08 +0100 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 SAA00742 for ; Thu, 27 Jan 2005 18:20:08 +0100 (MET) Received: from rproxy.gmail.com (rproxy.gmail.com [64.233.170.204]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id j0RHK7p4030172 for ; Thu, 27 Jan 2005 18:20:07 +0100 Received: by rproxy.gmail.com with SMTP id i8so286292rne for ; Thu, 27 Jan 2005 09:20:06 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:references; b=XmzB+a4kQh6+3KqWfrrhUExt/qVhZDCVVXCRl27kDj464yZZREmTHLN9X6v//i+m2hhVrlHWynbT6yqz1+Rpz1aJQRmsx5HjW51x8CVh4c1CIioIx4kMhEQ0/aYt0Eu7jfyXVgZ2FXSjR8Df6vfevT27GcnEncxlnM0w08nsQ4Y= Received: by 10.38.208.9 with SMTP id f9mr5337rng; Thu, 27 Jan 2005 09:20:06 -0800 (PST) Received: by 10.38.65.58 with HTTP; Thu, 27 Jan 2005 09:20:06 -0800 (PST) Message-ID: <7f8e92aa050127092017e7f423@mail.gmail.com> Date: Thu, 27 Jan 2005 19:20:06 +0200 From: Radu Grigore Reply-To: Radu Grigore To: skaller@users.sourceforge.net Subject: Re: [Caml-list] index of substring Cc: Jean-Christophe Filliatre , "yjc01@doc.ic.ac.uk" , caml-list In-Reply-To: <1106844935.12114.62.camel@pelican.wigram> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit References: <1106786478.41f838aecb7dd@www.doc.ic.ac.uk> <7f8e92aa05012622441fce509b@mail.gmail.com> <1106818582.6734.154.camel@pelican.wigram> <16888.49247.996632.225091@gargle.gargle.HOWL> <1106844935.12114.62.camel@pelican.wigram> X-Miltered: at nez-perce with ID 41F922C8.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at nez-perce with ID 41F922C7.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 sourceforge:01 wrote:01 integers:01 stack:01 filliatre:01 recursion:01 lexbuf:01 lexer:01 lexbuf:01 lexer:01 fallbacks:01 failwith:01 ocamllex:01 hair:98 X-Spam-Checker-Version: SpamAssassin 3.0.0 (2004-09-13) on yquem.inria.fr X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_BY_IP autolearn=disabled version=3.0.0 X-Spam-Level: On 28 Jan 2005 03:55:36 +1100, skaller wrote: > Well it doesn't handle (* or *) in strings .. Making things complicated just for fun isn't actually fun. The fact is that a finite automaton by itself cannot detect matching delimiters. Finite implies that the automaton can't count (at least countable sets) and matching requires counting. Sure, there are lots of nuances here: what does countable mean when you use 32b for integers,... but that's splitting the hair. The basic idea remains even after you look at these additional details. So if you want to detect matching delimiters you need a counter. You can either use an explicit one or use the stack as Jean-Christophe Filliatre did. > In particular the recursion only works 'by luck of > the implementation' that allows sharing of a lexbuf > between two lexer functions What do you mean "by luck"? The documentation clearly passes the lexbuf from one lexer to the other a few times. If the spec says it's possible then in what way is it "luck"? > -- who knows how > the lexer handles fallbacks? IMO adding a _ -> failwith "some error message" whenever the programmer fails to provide an explicit "else" branch is just fine. In fact I would prefer a "compile" error to be emitted by ocamllex (or at least a warning) when such a clause is missing from one lexer. -- regards, radu http://rgrig.idilis.ro/