Abstract
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 |
Pages | 48-60 |
Number of pages | 13 |
ISBN (Electronic) | 9781450369800 |
DOIs | |
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 |
Publication series
Name | GPCE 2019 - Proceedings of the 18th ACM SIGPLAN International Conference on Generative Programming: Concepts and Experiences, co-located with SPLASH 2019 |
---|
Conference
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 |
---|---|
Country/Territory | Greece |
City | Athens |
Period | 10/21/19 → 10/22/19 |
Bibliographical note
Publisher Copyright:Copyright © 2019 by the Association for Computing Machinery, Inc. (ACM).
Keywords
- Attribute grammars
- Meta-programming
- Reflection
Fingerprint
Dive into the research topics of 'Reflection in Attribute Grammars'. Together they form a unique fingerprint.Datasets
-
Silver-ableC: a Silver extension for writing ableC specifications
Van Wyk, E. & Kramer, L., Data Repository for the University of Minnesota, 2019
DOI: 10.13020/hbr0-9z50, http://hdl.handle.net/11299/206532
Dataset
-
A Silver implementation of a subset of MetaOCaml
Van Wyk, E. & Kramer, L., Data Repository for the University of Minnesota, 2019
DOI: 10.13020/z10a-7g60, http://hdl.handle.net/11299/206536
Dataset