This paper shows how reflection on (undecorated) syntax trees used in attribute grammars can significantly reduce the amount of boiler-plate specifications that must be written. It is implemented in the Silver attribute grammar system in the form of a reflect function mapping syntax trees and other values into a generic representation and a reify function for the inverse mapping. We demonstrate its usefulness in several ways. The first is in an extension to Silver itself that simplifies writing language extensions for the ableC extensible C specification by allowing language engineers to specify C-language syntax trees using the concrete syntax of C (with typed holes) instead of writing abstract syntax trees. Secondly, a scrap-your-boilerplate style substitution mechanism is described. The third use is in serialization and de-serialization of the interface files Silver generates to support separate compilation; a custom interface language was replaced by a generic reflection-based implementation. Finally, an experimental implementation of staged interpreters for a small staged functional language is discussed.
|Original language||English (US)|
|Title of host publication||GPCE 2019 - Proceedings of the 18th ACM SIGPLAN International Conference on Generative Programming|
|Subtitle of host publication||Concepts and Experiences, co-located with SPLASH 2019|
|Editors||Ina Schaefer, Christoph Reichenbach, Tijs van der Storm|
|Publisher||Association for Computing Machinery, Inc|
|Number of pages||13|
|State||Published - Oct 21 2019|
|Event||18th ACM SIGPLAN International Conference on Generative Programming: Concepts and Experiences, GPCE 2019, co-located with ACM SIGPLAN Conference on Systems, Programming, Languages, and Applications: Software for Humanity, SPLASH 2019 - Athens, Greece|
Duration: Oct 21 2019 → Oct 22 2019
|Name||GPCE 2019 - Proceedings of the 18th ACM SIGPLAN International Conference on Generative Programming: Concepts and Experiences, co-located with SPLASH 2019|
|Conference||18th ACM SIGPLAN International Conference on Generative Programming: Concepts and Experiences, GPCE 2019, co-located with ACM SIGPLAN Conference on Systems, Programming, Languages, and Applications: Software for Humanity, SPLASH 2019|
|Period||10/21/19 → 10/22/19|
- Attribute grammars
FingerprintDive into the research topics of 'Reflection in Attribute Grammars'. Together they form a unique fingerprint.
Van Wyk, E. & Kramer, L., Data Repository for the University of Minnesota, 2019