Re: synthized attributes in eli

"Tony Sloane" <asloane@ics.mq.edu.au>
1 Dec 2002 22:41:53 -0500

          From comp.compilers

Related articles
synthized attributes in eli oguzakyuz@softhome.net (Oguz Akyuz) (2002-11-26)
Re: synthized attributes in eli asloane@ics.mq.edu.au (Tony Sloane) (2002-12-01)
| List of all articles for this month |
From: "Tony Sloane" <asloane@ics.mq.edu.au>
Newsgroups: comp.compilers
Date: 1 Dec 2002 22:41:53 -0500
Organization: Dept of Computing, Macquarie University
References: 02-11-171
Keywords: attribute, tools
Posted-Date: 01 Dec 2002 22:41:53 EST

On Wed, 2002-11-27 at 14:14, Oguz Akyuz wrote:
> assume I have a small grammar like:
> A: B / C .
>
> When I try:
> RULE: A ::= B COMPUTE
> A.Type = B.Type;
> END;
>
> (Assume that both A and B have Type attributes and B.Type is something
> defined)
>
> I get an error like "miscomputation of A.Type" from eli system.
>
> Why does eli demand me to also add the rule(since adding this solves
> the problem):
>
> RULE: A ::= C COMPUTE
> A.Type = C.Type;
> END;
>
> I couldn't understand the point. I would be pleased if someone explains.
> Thanks


The reason Eli (actually LIGA, the attribute grammar tool used in Eli)
complains is because for an attribute grammar to be well-defined you
need to specify how to compute the attributes for all possible ASTs that
conform to the underlying context-free grammar.


In your case you have two grammar rules that define A. If you specify
that A has a synthesized Type attribute then you must say how to compute
it in both rules that define A (because either of these might be used in
a tree). Hence Eli insists that you add some computation for A.Type in
the A : C rule.


Feel free to contact me off the compilers list if you want more
explanation.


Cheers,
Tony
--
Tony Sloane <asloane@ics.mq.edu.au>
Dept of Computing, Macquarie University


Post a followup to this message

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