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=2.8 required=5.0 tests=AWL,DNS_FROM_RFC_POST, SPF_NEUTRAL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by yquem.inria.fr (Postfix) with ESMTP id E3571BC37 for ; Wed, 1 Jul 2009 16:37:47 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgoCAOMRS0rRVdSumWdsb2JhbACYST8BAQEBAQgLCgcTpEOBGpBrAQMCBIQMBQ X-IronPort-AV: E=Sophos;i="4.42,324,1243807200"; d="scan'208";a="32305339" Received: from mail-vw0-f174.google.com ([209.85.212.174]) by mail1-smtp-roc.national.inria.fr with ESMTP; 01 Jul 2009 16:37:47 +0200 Received: by vwj4 with SMTP id 4so413232vwj.1 for ; Wed, 01 Jul 2009 07:37:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=77L8hKa/BpXQ/TY8ITtShZUwu8bZ/7Lp0dySWLx5qkM=; b=g/UUlikvk+2WKPv8il+Bi+lbI1fe6AP6IgxNKk9Rey7MdZvbPPUHkSwbXbfTEEOjbB 6fqYj42IOHLLeIYXOECFbHbqbpR7+ETveyPv90zJRoAEtFrit5m7aQcpA+aaMSpwHh4P QtdkvOVC3+TpDanilHknmgZqG1yu3I2XON5Jg= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=q4tjkPKhNrlYz2eHwU0di8C3TI143p4nzazZ33jyKIZz9aNdRUmDa22h6PzrOFvPaW kfaR/f4nW9UhDSOwBDVARd3R9wizCzsVdN0/7iYwgLrYwZJt7tx2gNrejCrIjA4/2l2R ltNjbJpb37yzKSKQBiAFz2MDe3jiRgLbIgXgM= MIME-Version: 1.0 Received: by 10.220.77.17 with SMTP id e17mr9121512vck.3.1246459064957; Wed, 01 Jul 2009 07:37:44 -0700 (PDT) In-Reply-To: <4A4B70F2.2030002@mpi-sws.org> References: <7d8707de0906110557n6a1511a2k9f4f00827f954cb6@mail.gmail.com> <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> <4A4B70F2.2030002@mpi-sws.org> Date: Wed, 1 Jul 2009 10:37:44 -0400 Message-ID: <2a1a1a0c0907010737v5760f7c1ud6020debbe60f906@mail.gmail.com> Subject: Re: [Caml-list] ocamllex and python-style indentation From: Mike Lin To: Andreas Rossberg Cc: caml-list@inria.fr Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Spam: no; 0.00; ocamllex:01 parser:01 rossberg:01 rossberg:01 lexbuf:01 lexbuf:01 tokens:01 lexer:01 2009:98 wrote:01 wrote:01 stack:01 andreas:01 andreas:01 caml-list:01 That's cheating!!!!!! It's clever :) But clearly, you have a little parser with a stack there. My original contribution to this thread was just that "you've got to lex and parse at some level" before doing the whitespace conversion. Not that you were claiming otherwise, but it seemed like others had alluded to simpler ways which would only work for toy languages. On Wed, Jul 1, 2009 at 10:21 AM, Andreas Rossberg wro= te: > I wrote: >> >> ------------------------------------------------ >> let error l s =3D (* ... *) >> let commentDepth =3D ref 0 >> let start =3D ref 0 >> let loc length =3D let pos =3D !start in (pos, pos+length) >> >> rule lex =3D >> =A0 parse eof =A0 =A0 =A0 =A0 =A0 =A0{ EOF } >> =A0 (* | ... *) >> =A0 | "{-" =A0 =A0 =A0 =A0 =A0 =A0{ start :=3D pos lexbuf; >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 lexNestComment lexbuf } > > Sorry, the "{-" should be "(*" for ML. And the (* | ... *) is supposed to > stand for all other tokens in your lexer. > > - Andreas > >