Attribute Grammars used in compilers

7 Jan 86 16:22:00 GMT

          From comp.compilers

Related articles
Attribute Grammars used in compilers compilers@ima.UUCP (1986-01-07)
| List of all articles for this month |

Relay-Version: version B 2.10.2 9/12/84; site mit-hermes.ARPA
Posting-Version: Notesfiles $Revision: $; site ima.UUCP
From: compilers@ima.UUCP
Newsgroups: mod.compilers
Date: 7 Jan 86 16:22:00 GMT
Article-I.D.: ima.136300029
Posted: Tue Jan 7 11:22:00 1986
Date-Received: 9 Jan 86 13:03:41 GMT
Nf-ID: #N:ima:136300029:000:1493
Nf-From: ima!compilers Jan 7 11:22:00 1986

[from ]

My submition to mod.compilers had an error. I stated that node C
had three attribute, when in fact node C has one attribute. Below
is a copy of the fixed article.


[The submission already went out, because I didn't catch it either.
  Sorry, too. -John]
I'm interested in finding people that have used attribute grammars to
aid the development of a real live compiler. I am specifically interested
in finding out the pragmatics used in specifying the AG. What I mean by
pragmatics is "what was specified, from what kind of node, and to what kind
of node." Here is an example of what I mean:

The grammar is as follows

A ::= B C [ A.j := B.i * C.k; A.i := B.i; A.k := C.k;]
B ::= By [ B.i := B.i + 1;]
B ::= y [ B.i := 1;]
C ::= Bx [ C.k := B.i + 1;]

Node A has three attributes (A.i, A.j, A.k).
Node B has one attribute (B.i).
Node C has one attributes (C.k).

Since A is copying attributes i and k from a child and also calculating
attribute j from the same attributes, is it better to get the values (that
j is calculated) from the children nodes or to calcuate them from attributes
in the same node?

This type of example appears many times when specifying attributes. Other
pragmatic issues are "How far down the tree, or up the tree should you
calculate information?" and "What should be calculated with attributes and
What should be calculated by a backend?"

Please respond to mod.compilers, so we can get ideas flowing!

Post a followup to this message

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