YACC and inherited attributes

pkeddie@axion.bt.co.uk (Paul Keddie)
Wed, 11 Mar 1992 11:24:01 GMT

          From comp.compilers

Related articles
YACC and inherited attributes pkeddie@axion.bt.co.uk (1992-03-11)
Re: YACC and inherited attributes rockwell@socrates.umd.edu (Raul Deluth Miller-Rockwell) (1992-03-12)
Re: YACC and inherited attributes max@nic.gac.edu (Max Hailperin) (1992-03-12)
| List of all articles for this month |

Newsgroups: comp.compilers
From: pkeddie@axion.bt.co.uk (Paul Keddie)
Keywords: yacc, question, attribute
Organization: British Telecom Research Labs
Date: Wed, 11 Mar 1992 11:24:01 GMT

Dear All,


I am using YACC for the very first time and am wondering how inherited
attributes can be built up. I can see that synthesized attributes are easy,
but what about examples (in C) like: int x,y,z;


How do you pass down the information that x,y,z have type-specifier `int'?


I don't think you can do something like:


A : B C { $2 = function_of($1); } in YACC.


There must be standard ways of doing this. I don't want (or should need) to
construct a parser tree, instead just annotate the symbol table with info.
like the type of a variable.


Grateful for any help you can give, Cheers, Paul Keddie
Software Maintenance Group, Software Technology Division, BT
Research Labs, Martlesham Heath, Ipswich, IP5 7RE, UK
E-mail: pkeddie@axion.bt.co.uk
Phone: +44 473 649154
Fax: +44 473 643019
[You can use the $-1 hack to look at attributes in enclosing productions,
so long as you understand your contexts very well, but I am not aware of
any general solution that isn't really ugly. In this particular case, you
can build a data structure holding references to x, y, and z, then do
something to it when the enclosing int declaration is reduced. -John]
--


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.