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=none autolearn=disabled version=3.1.3 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 98084BC37 for ; Fri, 12 Jun 2009 15:40:11 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AsgBAAf4MUpCbwQak2dsb2JhbACYQQEBAQEJCQoJEgS4O4QLBQ X-IronPort-AV: E=Sophos;i="4.42,209,1243807200"; d="scan'208";a="31111638" Received: from out2.smtp.messagingengine.com ([66.111.4.26]) by mail1-smtp-roc.national.inria.fr with ESMTP; 12 Jun 2009 15:40:11 +0200 Received: from compute1.internal (compute1.internal [10.202.2.41]) by out1.messagingengine.com (Postfix) with ESMTP id AB30A3602DB; Fri, 12 Jun 2009 09:40:10 -0400 (EDT) Received: from heartbeat1.messagingengine.com ([10.202.2.160]) by compute1.internal (MEProxy); Fri, 12 Jun 2009 09:40:10 -0400 X-Sasl-enc: 6gPo0rUYDWGB7a9gj364yUTa/jtBMpA/7H5hwW6RwCwN 1244814010 Received: from [192.168.1.10] (ALyon-157-1-70-183.w81-251.abo.wanadoo.fr [81.251.157.183]) by mail.messagingengine.com (Postfix) with ESMTPSA id E535E18735; Fri, 12 Jun 2009 09:40:09 -0400 (EDT) Message-ID: <4A325980.2000204@ens-lyon.org> Date: Fri, 12 Jun 2009 15:34:56 +0200 From: Martin Jambon User-Agent: Thunderbird 2.0.0.17 (X11/20081008) MIME-Version: 1.0 To: Andrej Bauer Cc: caml-list@inria.fr Subject: Re: [Caml-list] ocamllex and python-style indentation References: <7d8707de0906110557n6a1511a2k9f4f00827f954cb6@mail.gmail.com> <4A310A5B.9010404@ens-lyon.org> <7d8707de0906120120x10cc8fe0p54adbd189003f3da@mail.gmail.com> In-Reply-To: <7d8707de0906120120x10cc8fe0p54adbd189003f3da@mail.gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam: no; 0.00; ens-lyon:01 ocamllex:01 andrej:01 inserting:01 tokens:01 wrote:01 andreas:01 caml-list:01 jambon:01 jambon:01 indentation:04 nested:04 successive:04 generally:04 depends:04 Andrej Bauer wrote: > Thanks to Andreas, I'll have a look at the "old" code. > > I think I understand the general idea of inserting "virtual" tokens, > but the details confuse me still. So starting with > >> if True: >> x = 3 >> y = (2 + >> 4 + 5) >> else: >> x = 5 >> if False: >> x = 8 >> z = 2 > > Martin suggests the following: > >> { >> if True: >> ; >> { >> x = 3 >> ; >> y = (2 + >> ; >> { >> 4 + 5) >> } >> } >> ; >> else: >> ; >> { >> x = 5 >> ; >> if False: >> ; >> { >> x = 8 >> ; >> z = 2 >> } >> } >> } > > I have two questions. Notice that the { ... } and ( ... ) need not be > correctly nested (in the top half), so how are we going to deal with > this? It depends on the characteristics of your language. It is generally easier to use several successive passes rather than trying to do everything in one pass. Martin -- http://mjambon.com/