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=AWL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id C0591BC37 for ; Wed, 1 Jul 2009 17:16:59 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AngBAFMaS0qLEwExkWdsb2JhbACZCAEBAQEJCwoHEwWlcpByBYQQ X-IronPort-AV: E=Sophos;i="4.42,324,1243807200"; d="scan'208";a="42761127" Received: from hera.mpi-sb.mpg.de ([139.19.1.49]) by mail4-smtp-sop.national.inria.fr with ESMTP/TLS/AES256-SHA; 01 Jul 2009 17:16:59 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mpi-sb.mpg.de; s=mail200803; h=Message-ID:Date:From: MIME-Version:To:CC:Subject:References:In-Reply-To:Content-Type: Content-Transfer-Encoding; bh=eldGs7NKO6AJq+H270OAXskUdEPiGbuxeb GWHhFdVuc=; b=AQT/hDcFd5GAvzwrqUFzCWnqF68mm13kFJs6HJT/futsmZ8LYx 9M99A4glYAs7a/D7srb8d+B/CYfICQ5pt3dRI/ggiUfOQmd5g0GAL/lt6XWo+7as 5jiogAhSC6DtLmsz/Qyh+9Ur6/vIHdsMbnZ+ngSwL84jwqcPjE/FRdUk4= Received: from newzak.mpi-sb.mpg.de ([139.19.1.28]:52075) by hera.mpi-sb.mpg.de (envelope-from ) with esmtp (Exim 4.69) id 1MM1YO-0003mN-0g; Wed, 01 Jul 2009 17:16:58 +0200 Received: from groove.ds.mpi-sws.mpg.de ([139.19.131.41]:40150) by newzak.mpi-sb.mpg.de with esmtpsa (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.63) (envelope-from ) id 1MM1YN-0008UB-I9; Wed, 01 Jul 2009 17:16:55 +0200 Message-ID: <4A4B7DE7.3080606@mpi-sws.org> Date: Wed, 01 Jul 2009 17:16:55 +0200 From: Andreas Rossberg User-Agent: Mozilla-Thunderbird 2.0.0.17 (X11/20081019) MIME-Version: 1.0 To: Sylvain Le Gall Cc: caml-list@inria.fr Subject: Re: [Caml-list] Re: ocamllex and python-style indentation References: <7d8707de0906110557n6a1511a2k9f4f00827f954cb6@mail.gmail.com> <4A310A5B.9010404@ens-lyon.org> <7d8707de0906120120x10cc8fe0p54adbd189003f3da@mail.gmail.com> <1750DDE9-4FC6-4657-9687-58240F520A70@mpi-sws.org> <2a1a1a0c0906301913t1dce3eebie91c7cc94f015481@mail.gmail.com> <2a1a1a0c0907010702u19ad7ba6kd831a71fa1b7f2a5@mail.gmail.com> <4A4B700D.3060701@mpi-sws.org> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Spam: no; 0.00; rossberg:01 rossberg:01 ocamllex:01 lexbuf:01 lexbuf:01 lexer:01 recursive:01 wrote:01 andreas:01 andreas:01 caml-list:01 lex:01 lex:01 arbitrary:02 parse:02 Sylvain Le Gall wrote: > May I recommend you to write this in a more simple way: > > ------------------------------------------------------------------------- > rule lex = > parse eof { () } > | "(*" { start := pos lexbuf; lexNestComment lexbuf; lex lexbuf } > > and lexNestComment = > parse eof { error (loc 2) "unterminated comment" } > | "(*" { lexNestComment lexbuf } > | "*)" { () } > | _ { lexNestComment lexbuf } > ------------------------------------------------------------------------- > Mh, I think in lexNestComment it should at least say | "(*" { lexNestComment lexbuf; lexNestComment lexbuf } That might work. I am not sure how well the various lexer generators handle arbitrary recursive invocations and reentrance, though. Have you tried it? If it works, yes, that's certainly a nicer version. - Andreas