caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Michal Moskal <malekith@pld-linux.org>
To: "Rafael 'Dido' Sevilla" <dido@imperium.ph>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] parsing forward references in ocamlyacc and other ocamlyacc questions
Date: Fri, 5 Sep 2003 22:56:34 +0200	[thread overview]
Message-ID: <20030905205634.GA16638@roke.freak> (raw)
In-Reply-To: <20030903053114.GA2490@imperium.ph>

On Wed, Sep 03, 2003 at 01:31:14PM +0800, 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.:
> 
> 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).

Are you *sure*? From what I know about yacc parser, this action *had* to
be taken before adt_member_list was parsed.

-- 
: Michal Moskal :: http://www.kernel.pl/~malekith : GCS {C,UL}++++$ a? !tv
: When in doubt, use brute force. -- Ken Thompson : {E-,w}-- {b++,e}>+++ h

-------------------
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


      parent reply	other threads:[~2003-09-05 20:57 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-09-03  5:31 Rafael 'Dido' Sevilla
2003-09-05 12:07 ` Eckart Goehler
2003-09-05 20:56 ` Michal Moskal [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20030905205634.GA16638@roke.freak \
    --to=malekith@pld-linux.org \
    --cc=caml-list@inria.fr \
    --cc=dido@imperium.ph \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).