Nanopass Attribute Grammars

Nathan Ringo, Lucas Kramer, Eric Van Wyk

Research output: Chapter in Book/Report/Conference proceedingConference contribution

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 languageEnglish (US)
Title of host publicationSLE 2023 - Proceedings of the 16th ACM SIGPLAN International Conference on Software Language Engineering, Co-located with
Subtitle of host publicationSPLASH 2023
EditorsJoao Saraiva, Thomas Degueule, Elizabeth Scott
PublisherAssociation for Computing Machinery, Inc
Pages70-83
Number of pages14
ISBN (Electronic)9798400703966
DOIs
StatePublished - Oct 23 2023
Event16th ACM SIGPLAN International Conference on Software Language Engineering, SLE 2023 - Cascais, Portugal
Duration: Oct 23 2023Oct 24 2023

Publication series

NameSLE 2023 - Proceedings of the 16th ACM SIGPLAN International Conference on Software Language Engineering, Co-located with: SPLASH 2023

Conference

Conference16th ACM SIGPLAN International Conference on Software Language Engineering, SLE 2023
Country/TerritoryPortugal
CityCascais
Period10/23/2310/24/23

Bibliographical note

Publisher Copyright:
© 2023 ACM.

Keywords

  • attribute grammars
  • compilers
  • nanopass compilers
  • software engineering

Fingerprint

Dive into the research topics of 'Nanopass Attribute Grammars'. Together they form a unique fingerprint.

Cite this