KIT | KIT-Bibliothek | Impressum | Datenschutz

Modular Specification and Dynamic Enforcement of Syntactic Language Constraints

Erdweg, Sebastian ORCID iD icon 1; Vergu, Vlad; Mezini, Mira; Visser, Eelco
1 Institut für Programmstrukturen und Datenorganisation (IPD), Karlsruher Institut für Technologie (KIT)

Abstract (englisch):

A key problem in metaprogramming and specifically in generative programming is to guarantee that generated code is well-formed with respect to the context-free and context-sensitive constraints of the target language. We propose typesmart constructors as a dynamic approach to enforcing the well-formedness of generated code. A typesmart constructor is a function that is used in place of a regular constructor to create values, but it may reject the creation of values if the given data violates some language-specific constraint. While typesmart constructors can be implemented individually, we demonstrate how to derive them automatically from a grammar, so that the grammar remains the sole specification of a language's syntax and is not duplicated. We have integrated support for typesmart constructors into the run-time system of Stratego to enforce usage of typesmart constructors implicitly whenever a regular constructor is called. We evaluate the applicability, performance, and usefulness of typesmart constructors for syntactic constraints in a compiler for MiniJava developed with Spoofax and in various language extensions of Java and Haskell implemented with SugarJ and SugarHaskell.


Download
Originalveröffentlichung
DOI: 10.1145/2577080.2577089
Zugehörige Institution(en) am KIT Institut für Programmstrukturen und Datenorganisation (IPD)
Publikationstyp Proceedingsbeitrag
Publikationsjahr 2014
Sprache Englisch
Identifikator KITopen-ID: 1000188549
Erschienen in MODULARITY 2014 - Proceedings of the 13th International Conference on Modularity (Formerly AOSD); Lugano, Schweiz, 22.-25.04.2014
Veranstaltung 13th International Conference on Modularity (2014), Lugano, Schweiz, 22.04.2014 – 25.04.2014
Verlag Association for Computing Machinery (ACM)
Seiten 241–252
Schlagwörter Abstract syntax tree; Dynamic analysis; Generative programming; Program transformation; Spoofax; SugarJ; Typesmart constructors; Well-formedness checks
Nachgewiesen in Scopus
KIT – Die Universität in der Helmholtz-Gemeinschaft
KITopen Landing Page