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 mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by yquem.inria.fr (Postfix) with ESMTP id 4585ABC37 for ; Wed, 1 Jul 2009 00:06:16 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AsoBAK8oSkqLEwExe2dsb2JhbACZAwEBFiQFp0SQFQWEDw X-IronPort-AV: E=Sophos;i="4.42,319,1243807200"; d="scan'208";a="30457386" Received: from infao0809.mpi-sb.mpg.de (HELO hera.mpi-sb.mpg.de) ([139.19.1.49]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/AES256-SHA; 01 Jul 2009 00:06:15 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mpi-sb.mpg.de; s=mail200803; h=From:To:In-Reply-To:Subject: References:Message-Id:Content-Type:Content-Transfer-Encoding: Mime-Version:Date:Cc; bh=AjXFoLMQtGbxWew6cP8tLB3E55ieyenGWHZv+ek VhYc=; b=lGLOawjTuLDeed4QI9g3TriuxUT41hy3TUyghi49VcX7291MVDeHA9b Nj6jBux+VysqDAGzPe618fQAf9HuoWaBKmrM2JJpN8iscRPO1ZDQAuC2ec6ARv8r kuDtDSWKNj1h34r+GFk/wNobRQS8OBefDzdl/Qrm/iYb2uFKceSM= Received: from infao0525.mpi-sb.mpg.de ([139.19.1.26]:48529 helo=newmaniac.mpi-sb.mpg.de) by hera.mpi-sb.mpg.de (envelope-from ) with esmtp (Exim 4.69) id 1MLlSr-0000BR-42; Wed, 01 Jul 2009 00:06:11 +0200 Received: from srbk-4db7ffcb.pool.einsundeins.de ([77.183.255.203]:55658 helo=[192.168.178.20]) by newmaniac.mpi-sb.mpg.de with esmtpsa (TLS-1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.63) (envelope-from ) id 1MLlSq-0005Aa-Ak; Wed, 01 Jul 2009 00:06:08 +0200 From: Andreas Rossberg To: Yitzhak Mandelbaum , Mike Lin In-Reply-To: Subject: Re: [Caml-list] ocamllex and python-style indentation References: <7d8707de0906110557n6a1511a2k9f4f00827f954cb6@mail.gmail.com> <4A310A5B.9010404@ens-lyon.org> <7d8707de0906120120x10cc8fe0p54adbd189003f3da@mail.gmail.com> Message-Id: <1750DDE9-4FC6-4657-9687-58240F520A70@mpi-sws.org> Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Apple Message framework v935.3) Date: Wed, 1 Jul 2009 00:06:09 +0200 Cc: Andrej Bauer , caml-list@inria.fr X-Mailer: Apple Mail (2.935.3) X-Spam: no; 0.00; rossberg:01 rossberg:01 ocamllex:01 yitzhak:01 mandelbaum:01 parens:01 tokens:01 haskell:01 literals:01 literals:01 tokens:01 surrounded:98 wrote:01 wrote:01 andreas:01 On Jun 30, 2009, at 20.58 h, Yitzhak Mandelbaum wrote: > To restart this thread, do your solutions handle the following > (legal) variation of the original example? > > if True: > x = 3+4 > y = (2 + > 4 + 5) > z = 5 > else: > x = 5 > if False: > x = 8 > z = 2 > > Notice that the assignment of y wraps onto the next line at an > *earlier* column. This is legal b/c it is surrounded by parens. > However, it seems that the preprocessing approaches will fail for > this example. Do you have a workaround? Handling that wouldn't be hard with the approach I described. You only need to have parentheses start a dummy block at column 0, so that no tokens will be inserted inside it . However, I don't think it is actually a good idea to allow this. (And I don't think Haskell does, but I may misremember.) On Jun 30, 2009, at 22.19 h, Mike Lin wrote: > More generally, you've got parentheses, comments, and string literals, > and you need to know to ignore whitespace within any of those -- and > to ignore e.g. an open parenthesis that occurs within a comment, or a > close comment that occurs within a string literal. So inevitably > you've got to lex and parse at some level to make this work for a > practical language. Comments and string literals are no problem, since the lex wrapper will never see anything inside them as separate tokens anyway. - Andreas