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 OAA06306; Fri, 5 Sep 2003 14:07:54 +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 OAA02192 for ; Fri, 5 Sep 2003 14:07:53 +0200 (MET DST) Received: from aitp01.ait.physik.uni-tuebingen.de (aitp01.ait.physik.uni-tuebingen.de [134.2.76.79]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id h85C7qf27849 for ; Fri, 5 Sep 2003 14:07:52 +0200 (MET DST) Received: from aitp01.ait.physik.uni-tuebingen.de (localhost [127.0.0.1]) by aitp01.ait.physik.uni-tuebingen.de (8.12.9/8.12.9) with ESMTP id h85C7mAd027421; Fri, 5 Sep 2003 14:07:48 +0200 Received: from localhost (goehler@localhost) by aitp01.ait.physik.uni-tuebingen.de (8.12.9/8.12.9/Submit) with ESMTP id h85C7mrb027418; Fri, 5 Sep 2003 14:07:48 +0200 X-Authentication-Warning: aitp01.ait.physik.uni-tuebingen.de: goehler owned process doing -bs Date: Fri, 5 Sep 2003 14:07:48 +0200 (CEST) From: Eckart Goehler X-X-Sender: goehler@aitp01.ait.physik.uni-tuebingen.de To: caml-list@inria.fr, "Rafael 'Dido' Sevilla" Subject: Re: [Caml-list] parsing forward references in ocamlyacc and other ocamlyacc questions In-Reply-To: <20030903053114.GA2490@imperium.ph> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 rafael:01 'dido':01 hash:01 bison:01 patching:01 recursively:01 foo:01 mli:01 implemented:01 compiler:01 semantics:01 ocaml:01 token:01 token:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Hi, On Wed, 3 Sep 2003, Rafael 'Dido' Sevilla wrote: > I'm just wondering how you can guarantee that certain imperative effects > occur, like adding a name into a symbol table hash. I'm writing a > compiler whose semantics allow some limited forward references, e.g.: ... > until after the entire adt_declaration has been parsed. The > documentation for ocamlyacc has very little to say about it (unless > there's more documentation in other places besides the ocaml manual). As far as I understand ocamlyacc behaves as the original yacc (but not bison). > I'll also ask how I would go about processing file inclusion in > ocamlyacc using ocamllex... Tricky. Calling the parser function "main" from within the parser does not work currently with ocamlyacc. I tried this myself and ended in patching ocamlyacc: - the main function generated by ocamlyacc has to be recursive (let rec main = ...). - the parser table written out has to be defined before the main function. - because ocamllex needs the token information but must be defined *before* the parser (otherwise you can't recursively call ocamllex) the token have to be written into a different file (for foo.mly I choosed the output file name to be footoken.ml/footoken.mli). But file inclusion is a bit difficult because you can't always be shure that the processing order is kept (mentioned by the main problem you have: imperative features while parsing. Maybe the patch should be implemented in ocamlyacc eckart ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners