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 OctDisplayed time zone: Beirut change
14:00 - 15:30
|A Stage-Polymorphic IR for Compiling MATLAB-Style Dynamic Tensor Expressions|
|Reflection in Attribute Grammars|
Lucas Kramer University of Minnesota, Ted Kaminski University of Minnesota, Eric Van Wyk University of Minnesota, USADOI Pre-print
|Polymorphic Extractors for Semantic and Portable Pattern Matching (Short Paper)|
Amir Shaikhha University of Oxford