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 LAA07791; Fri, 5 Sep 2003 11:18:19 +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 LAA01572 for ; Fri, 5 Sep 2003 11:18:18 +0200 (MET DST) Received: from intmail.imperium.ph ([202.175.240.154]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id h859IFT21553 for ; Fri, 5 Sep 2003 11:18:16 +0200 (MET DST) Received: from morgoth.imperium.ph (unknown [192.168.1.35]) by intmail.imperium.ph (Postfix) with SMTP id B583E46A1B for ; Fri, 5 Sep 2003 17:18:13 +0800 (PHT) Received: by morgoth.imperium.ph (sSMTP sendmail emulation); Fri, 5 Sep 2003 17:20:23 +0800 Date: Wed, 3 Sep 2003 13:31:14 +0800 From: "Rafael 'Dido' Sevilla" To: ocaml_beginners@yahoogroups.com Subject: [Caml-list] parsing forward references in ocamlyacc and other ocamlyacc questions Message-ID: <20030903053114.GA2490@imperium.ph> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.4i X-Loop: caml-list@inria.fr X-Spam: no; 0.00; rafael:01 'dido':01 dido:01 hash:01 bison:01 hashtbl:01 symtable:01 hashtbl:01 symtable:01 compiler:01 semantics:01 ocaml:01 inclusion:03 identifier:03 identifier:03 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk 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.: adt_declaration: IDENTIFIER COLON ADT OBRACE adt_member_list CBRACE SEMI where the rules under the adt_member_list nonterminal have access to the identifier name given in the ADT declaration. For the original Yacc or Bison, it can be done with an intermediate semantic action like: adt_declaration: IDENTIFIER COLON ADT { Hashtbl.add symtable $1 ... } OBRACE ... Something like (which is how you would do it without the use of intermediate actions): adt_name: IDENTIFIER COLON ADT { Hashtbl.add symtable $1 adt_skel; $1 } ; adt_declaration: adt_name OBRACE adt_member_list CBRACE SEMI { ... } ; doesn't seem to work. The symbol table addition still doesn't occur 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). I'll also ask how I would go about processing file inclusion in ocamlyacc using ocamllex... ------------------- 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