From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id KAA10566; Fri, 12 Oct 2001 10:29:43 +0200 (MET DST) Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id KAA10544 for ; Fri, 12 Oct 2001 10:29:42 +0200 (MET DST) Received: from uni-sb.de (uni-sb.de [134.96.252.33]) by concorde.inria.fr (8.11.1/8.10.0) with ESMTP id f9C8Tfj12694 for ; Fri, 12 Oct 2001 10:29:41 +0200 (MET DST) Received: from cs.uni-sb.de (cs.uni-sb.de [134.96.252.31]) by uni-sb.de (8.11.6/2001082200) with ESMTP id f9C8TfP23145 for ; Fri, 12 Oct 2001 10:29:41 +0200 (CEST) Received: from mail.cs.uni-sb.de (IDENT:iqD5DKgnd62epKkqSkfuE4Bx0KgHWANh@mail.cs.uni-sb.de [134.96.254.200]) by cs.uni-sb.de (8.12.1/2001100800) with ESMTP id f9C8TeN17768 for ; Fri, 12 Oct 2001 10:29:40 +0200 (CEST) Received: from ps.uni-sb.de (grizzly.ps.uni-sb.de [134.96.186.68]) by mail.cs.uni-sb.de (8.12.1/2001100800) with ESMTP id f9C8Tc100079 for ; Fri, 12 Oct 2001 10:29:38 +0200 (CEST) X-Authentication-Warning: email: Host grizzly.ps.uni-sb.de [134.96.186.68] claimed to be ps.uni-sb.de Received: from ps.uni-sb.de (zoidberg.ps.uni-sb.de [134.96.186.121]) by ps.uni-sb.de (8.11.2/8.11.0) with ESMTP id f9C8Tb620850; Fri, 12 Oct 2001 10:29:37 +0200 Message-ID: <3BC6A9F1.8A790E42@ps.uni-sb.de> Date: Fri, 12 Oct 2001 10:29:37 +0200 From: Andreas Rossberg Organization: =?iso-8859-1?Q?Universit=E4t?= des Saarlandes X-Mailer: Mozilla 4.77 [en] (X11; U; Linux 2.4.3-12 i686) X-Accept-Language: de, en MIME-Version: 1.0 To: caml-list@inria.fr Subject: Re: [Caml-list] Re: [Caml-announce] OCamldoc References: <8E31D6933A2FE64F8AE3CC1381EEDCE7140166@NT.kal.com> <4066.1002712085@saul.cis.upenn.edu> <20011011213211.B1047@pauillac.inria.fr> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Xavier Leroy wrote: > > I've been > hacking Lex and Yacc for years, still I do not have the slightest idea > on how to take indentation into account in a Lex/Yacc parser... What you can do is, write a standard lexer and a (more or less, see below) standard parser. In addition, you write a lexer wrapper that does several things: - calculate line/column information from the absolute character position for every token (e.g. by incrementally co-traversing the input), - maintain a stack of current indentation levels, - insert some appropriate virtual tokens on line and indentation level changes. The grammar implemented by the parser contains occurences of these virtual tokens at the right places. In the approach taken by Haskell (don't know about Python) you do not even need to think about that, since you only insert standard tokens. And if you have a lexer that is able to calculate lines/columns by itself, everything becomes very easy. -- Andreas Rossberg, rossberg@ps.uni-sb.de "Computer games don't affect kids; I mean if Pac Man affected us as kids, we would all be running around in darkened rooms, munching magic pills, and listening to repetitive electronic music." - Kristian Wilson, Nintendo Inc. ------------------- Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr