Abstract
Compilers for feature-rich languages are complex; they perform many analyses and optimizations, and often lower complex language constructs into simpler ones. The nanopass compiler architecture manages this complexity by specifying the compiler as a sequence of many small transformations, over slightly different, but clearly defined, versions of the language that each perform a single straightforward action. This avoids errors that arise from attempting to solve multiple problems at once and allows for testing at each step. Attribute grammars are ill-suited for this architecture, primarily because they cannot identify the many versions of the language in a non-repetitive and type-safe way. We present a formulation of attribute grammars that addresses these concerns, called nanopass attribute grammars, that (i) identifies a collection of all language constructs and analyses (attributes), (ii) concisely constructs specific (sub) languages from this set and transformations between them, and (iii) specifies compositions of transformations to form nanopass compilers. The collection of all features can be statically typed and individual languages can be checked for well-definedness and circularity. We evaluate the approach by implementing a significant subset of the Go programming language in a prototype nanopass attribute grammar system.
Original language | English (US) |
---|---|
Title of host publication | SLE 2023 - Proceedings of the 16th ACM SIGPLAN International Conference on Software Language Engineering, Co-located with |
Subtitle of host publication | SPLASH 2023 |
Editors | Joao Saraiva, Thomas Degueule, Elizabeth Scott |
Publisher | Association for Computing Machinery, Inc |
Pages | 70-83 |
Number of pages | 14 |
ISBN (Electronic) | 9798400703966 |
DOIs | |
State | Published - Oct 23 2023 |
Event | 16th ACM SIGPLAN International Conference on Software Language Engineering, SLE 2023 - Cascais, Portugal Duration: Oct 23 2023 → Oct 24 2023 |
Publication series
Name | SLE 2023 - Proceedings of the 16th ACM SIGPLAN International Conference on Software Language Engineering, Co-located with: SPLASH 2023 |
---|
Conference
Conference | 16th ACM SIGPLAN International Conference on Software Language Engineering, SLE 2023 |
---|---|
Country/Territory | Portugal |
City | Cascais |
Period | 10/23/23 → 10/24/23 |
Bibliographical note
Publisher Copyright:© 2023 ACM.
Keywords
- attribute grammars
- compilers
- nanopass compilers
- software engineering