Path: utzoo!attcan!uunet!husc6!bloom-beacon!tut.cis.ohio-state.edu!mailrus!ames!nrl-cmf!cmcl2!brl-adm!adm!jbaker@ee.ucla.edu
From: jbaker@ee.ucla.edu (Joe Baker)
Newsgroups: comp.lang.c
Subject: yacc with multiple attributes
Message-ID: <16345@brl-adm.ARPA>
Date: 30 Jun 88 04:49:39 GMT
Sender: news@brl-adm.ARPA
Lines: 27

[ This isn't really a C question, but all the yacc users seem to be
here.  Sorry for the interruption from the C/FORTRAN debate. ]

I am working on an interpreter for a little language with C-like
syntax.  Since I have several data types, and will probably be adding 
type constructors at some point, I'd like to set up a fairly general 
type system.  Because of this, lots of the non-terminals will have
several attributes.  I can see a couple of possible approaches:

1) Build an explicit parse tree, use the yacc value stack to hold
the node pointers, and carry the type information in the nodes.

2) Use a struct on the value stack, and carry both value and type
information (i.e., copy the stuff in Aho, Sethi, and Ullman, chap. 6.)
I think this would work with various intermediate code representations,
but I'm leaning to an explicit parse tree to simplify error recovery.

3) ?

Any opinions or pointers to examples?

Thanks in advance.  Please send mail to me and I will summarize to the
net if there is any interest.

- Joe Baker, Dept. of Electrical Engineering
6731 Boelter Hall, UCLA, L.A., CA 90024 (213) 825-7079, 825-2327
ARPA: jbaker@ee.ucla.edu UUCP: {ihnp4|randvax|ucbvax}!ucla-cs!uclaee!jbaker