|attribute grammars rosing@peakNOSPAMfive.com (MattR) (2003-10-31)|
|Re: attribute grammars derkgwen@HotPOP.com (Derk Gwen) (2003-11-01)|
|Attribute grammars compilers@ima.UUCP (1986-01-13)|
|attribute grammars firstname.lastname@example.org (1989-11-08)|
|Date:||31 Oct 2003 23:09:02 -0500|
|Posted-Date:||31 Oct 2003 23:09:02 EST|
Hi, I'm looking at easier ways to write attribute grammars for a
preprocessor I have. Speed is not as important as being able to just
quickly write the grammar (this is for a preprocessor and changing
attribution is common). Currently I just manually walk over the ast
and, while flexible, it's confusing. A few years back I used ELI that,
for all I can tell, is a common way to deal with attribute
grammars. ELI contains an attribute grammar language where each
attribute can only be assigned once and is a function of attributes
within the same node or nodes directly below. (There are also ways to
do standard traversals over the tree but this doesn't add as much as I
want.) Once this is written another compiler does all sorts of
analysis and optimization.
I like the idea of single assignment, writing sets of functions, and
having something else compile it into something that traverses the
tree. But I'd like to make a small change in the rest of this. Rather
than limit a function to the attributes in the current node or the
children of that node, I'd like to be able to specify any node, or
sets of nodes below or above the current node. So, at the top of a
fortran loop nest one could say something along the lines of: find all
of the array expressions below this node, and for each, evaluate such
and such an attribute and combine it into a list that is stored in an
attribute on this node of the tree. Another function could than look
at all of the elements of the list for whatever might be interesting.
The important thing is that nothing needs to be specified at the array
expression. There's some language that specifies interesting sets of
nodes relative to the current one and some traversal is generated to
go to those nodes, evaluate the interesting nodes if they're not
already evaluated, and return the result
This type of thing wouldn't be so great for doing things like name
analysis and it wouldn't be an improvement for type analysis, but for
the kinds of things I do it would be really useful.
If something like this exists I'd like to know about it. Also, would
it be reasonable to do this attribution dynamically (as opposed to
having a compiler work on the grammar and generate optimal code)?
Again, our experience has been that speed isn't much of an issue with
the types of attributution we do so if this runs 10x slower than what
a nice compiled grammar can generate it won't bother us.
Return to the
Search the comp.compilers archives again.