From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id F2943BB91 for ; Fri, 28 Jan 2005 02:14:44 +0100 (CET) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id j0S1EiVJ015707 for ; Fri, 28 Jan 2005 02:14:44 +0100 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 CAA14131 for ; Fri, 28 Jan 2005 02:14:44 +0100 (MET) Received: from smtp1.adl2.internode.on.net (smtp1.adl2.internode.on.net [203.16.214.181]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id j0S1Eg9D015694 for ; Fri, 28 Jan 2005 02:14:43 +0100 Received: from [192.168.1.200] (ppp205-248.lns1.syd3.internode.on.net [203.122.205.248]) by smtp1.adl2.internode.on.net (8.12.9/8.12.9) with ESMTP id j0S1EeTX091142; Fri, 28 Jan 2005 11:44:40 +1030 (CST) Subject: Re: [Caml-list] yacc style From: skaller Reply-To: skaller@users.sourceforge.net To: Erik de Castro Lopo Cc: caml-list In-Reply-To: <20050128083956.7dc72787.ocaml-erikd@mega-nerd.com> References: <875c7e0705012712177a9e852@mail.gmail.com> <20050128083956.7dc72787.ocaml-erikd@mega-nerd.com> Content-Type: text/plain Message-Id: <1106874879.12114.145.camel@pelican.wigram> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.2 (1.2.2-4) Date: 28 Jan 2005 12:14:39 +1100 Content-Transfer-Encoding: 7bit X-Miltered: at concorde with ID 41F99204.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at concorde with ID 41F99202.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 sourceforge:01 wrote:01 wrote:01 parser:01 parser:01 ocamlyacc:01 ocamllex:01 strangely:01 typedef:01 lexbuf:01 ocaml:01 lexer:01 glebe:01 061:98 X-Spam-Checker-Version: SpamAssassin 3.0.0 (2004-09-13) on yquem.inria.fr X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.0 X-Spam-Level: On Fri, 2005-01-28 at 08:39, Erik de Castro Lopo wrote: > On Thu, 27 Jan 2005 15:17:13 -0500 > Chris King wrote: > > > Is it considered better style to > > instead have the parser return a parse tree, and then use that to > > generate the imperative structure, > > Yes, normally the parser generates a parse tree which is then > passed to the semantic analyser for semantic checking. Unfortunately this is useless in the common case of needing to parse C. It would surely be nice to be able to pass an argument to ocamlyacc, as can now be done for ocamllex. Strangely in this case the ideal place to add on the typedef table would be the lexbuf, which *is* passed to the parser .. but the client can't get at it, and it isn't extensible. The reason this isn't done right seems to be that yacc/lex are used to bootstrap Ocaml and so fixing them would destablise the bootstrap. FYI: in Felix, the parser and lexer are built-in to the language, and lexical scoping is supported: whilst you cannot pass in an extra argument to the parser, you *can* write action code that depends on its environment, which need not be the top level. -- John Skaller, mailto:skaller@users.sf.net voice: 061-2-9660-0850, snail: PO BOX 401 Glebe NSW 2037 Australia Checkout the Felix programming language http://felix.sf.net