[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Grammar inheritance, attributes and framework desing ideas [Was:Re: [wishlist] Attributes]



Hi Roger, Mariusz & all,

Roger Keays wrote:
How many people out there are interested in seeing support for attribute
grammars?
> ...
Etienne doesn't want to have attributes on the SableCC generated nodes
and suggests storing them in a hashtable. I think you can still do this
with an attributed grammar.
> ...
Here is an example snippet:
Attributes
name: String;
type: String;
size: Integer;
... The walker generated contains three hashtable (name, type, size) indexed
by SableCC nodes and provides getter methods. e.g.


if (attributes.getType(node).equals("char")) { /* do something */ }

Thoughts? Comments?

Since the recent thread discussing grammar inheritance, I have been thinking seriously about the subject, and my initial desing for them includes something that resembles what Roger is suggesting.

So, I see some extentions to SableCC that would satisfy my worries
about code maintenance and be in line with the needs for attributes
often voiced on this mailing-list.

So, these propositions should be added to the wish-list, as I will
need to devote more time thinking about many details, including
implementation related ones, and how it will all integrate within the
CST->AST extentions.

I saw a paper presentation about Polyglot at CC 2003 this last week,
and this work does contain interesting ideas.  Some of these ideas
could make a nice addition for SableCC, but they should first be
adapted as the constraints are different.  (See Patrick Lam's last
message for URLs).

I will discuss my ideas on this list once the CST->AST stuff will have
migrated to a stable version.

Have fun!

Etienne
--
Etienne M. Gagnon, Ph.D.             http://www.info.uqam.ca/~egagnon/
SableVM:                                       http://www.sablevm.org/
SableCC:                                       http://www.sablecc.org/