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 WAA30150; Sun, 23 Sep 2001 22:09:17 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id WAA30145 for ; Sun, 23 Sep 2001 22:09:16 +0200 (MET DST) Received: from lakeland.eecs.harvard.edu (lakeland.eecs.harvard.edu [140.247.62.173]) by nez-perce.inria.fr (8.11.1/8.10.0) with ESMTP id f8NK9FD05349 for ; Sun, 23 Sep 2001 22:09:16 +0200 (MET DST) Received: by lakeland.eecs.harvard.edu (Postfix, from userid 32148) id 8A4F618D47; Sun, 23 Sep 2001 16:09:15 -0400 (EDT) Date: Sun, 23 Sep 2001 16:09:15 -0400 From: Christian Lindig To: Vesa Karvonen Cc: Caml Mailing List Subject: Re: [Caml-list] On ocamlyacc and ocamllex Message-ID: <20010923160915.B28129@lakeland.eecs.harvard.edu> Mail-Followup-To: Christian Lindig , Vesa Karvonen , Caml Mailing List References: <000b01c143aa$d5218690$422aa8c0@housemarque.fi> <20010922211013.A580@eecs.harvard.edu> <001501c1444c$a7b0a720$422aa8c0@housemarque.fi> <20010923134425.A28129@lakeland.eecs.harvard.edu> <000901c14466$7848e280$422aa8c0@housemarque.fi> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <000901c14466$7848e280$422aa8c0@housemarque.fi>; from vesa.karvonen@housemarque.fi on Sun, Sep 23, 2001 at 10:32:23PM +0300 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Sun, Sep 23, 2001 at 10:32:23PM +0300, Vesa Karvonen wrote: > From: "Christian Lindig" > I'd prefer that the lexer generator would be extended so that additional > arguments could be added in a manner similar to this: > > rule token map = parse > eof { P.EOF } > | ws+ { token map lexbuf } > | tab { tab map lexbuf; token map lexbuf } > | nl { nl map lexbuf ; token map lexbuf } > | nl '#' { line map lexbuf 0; token map lexbuf } > ... I lobbied for this three years ago and had a patch for ocamllex: http://www.eecs.harvard.edu/~lindig/software/lex-patch.html > Can this technique be used for adding context to parsers generated > using ocamlyacc, too? I'm not sure what you mean here. A Yacc parser works bottom up - do you want to inject "context" into the tokens that are received from the lexer? > I agree that it may be somewhat easier for the parser generator, but I > find that separating the token type definition from the grammar > definition can be justified using quantitative technical arguments. I agree that this alternative avoids the dependency of the type definition on the grammar. But I am not sure that manually keeping the type definition and the %token declarations in the parser in sync is better than automatic recompiles or a little Make hack. -- Christian -- Christian Lindig Harvard University - DEAS lindig@eecs.harvard.edu 33 Oxford St, MD 242, Cambridge MA 02138 phone: +1 (617) 496-7157 http://www.eecs.harvard.edu/~lindig/ ------------------- 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