Reflection in Attribute Grammars
This paper presents a technique for realizing reflection in attribute grammars. It is implemented and evaluated in the Silver attribute grammar system in the form of a
reflect function mapping typed syntax trees and other values into a generic representation and a
reify function for the inverse mapping. This is especially useful in meta-programming systems in which syntax trees are properly typed, both in the meta-language of the system and in the implementation to which the meta-language is translated. This is the case in Silver, a strongly typed language that translates to Java.
We demonstrates its usefulness in several ways. The first is in an extension to Silver for writing language extensions for the AbleC extensible C specification. This allows language developers to specify complete C syntax trees using the concrete syntax of C, with typed holes, instead of writing abstract syntax trees, saving almost 18,000 lines of specifications. Secondly, a scrap-your-boilerplate style substitution mechanism is also described. The third use is in serialization and deserialization of the interface files Silver generates to support separate compilation; a custom interface language was replaced by a generic reflection-based implementation saving around 2,000 lines of specifications. Finally, an experimental implementation of staged interpreters for a small staged functional language is discussed.
Mon 21 Oct Times are displayed in time zone: Beirut change
|14:00 - 14:30|
|14:30 - 15:00|
Lucas KramerUniversity of Minnesota, Ted KaminskiUniversity of Minnesota, Eric Van WykUniversity of Minnesota, USADOI Pre-print
|15:00 - 15:20|
Amir ShaikhhaUniversity of Oxford