Gradual Grammars: Syntax in Levels and Locales

T. Van Der Storm, F. Hermans

Research output: Chapter in Book / Report / Conference proceedingConference contributionAcademicpeer-review

Abstract

Programming language implementations are often one-size-fits-all. Irrespective of the ethnographic background or proficiency of their users, they offer a single, canonical syntax for all language users. Whereas professional software developers might be willing to learn a programming language all in one go, this might be a significant barrier for non-technical users, such as children who learn to program, or domain experts using domain-specific languages (DSLs). Parser tools, however, do not offer sufficient support for graduality or internationalization, leading (worst case) to maintaining multiple parsers, for each target class of users. In this paper we present Fabric, a grammar formalism that supports: 1) the gradual extension with (and deprecation of) syntactic constructs in consecutive levels ("vertical"), and, orthogonally, 2) the internationalization of syntax by translating keywords and shuffling sentence order ("horizontal"). This is done in such a way that downstream language processors (compilers, interpreters, type checkers etc.) are affected as little as possible. We discuss the design of Fabric and its implementation on top of the LARK parser generator, and how Fabric can be embedded in the Rascal language workbench. A case study on the gradual programming language Hedy shows that language levels can be represented and internationalized concisely, with hardly any duplication. We evaluate the Fabric embedding using the Rebel2 DSL, by translating it to Dutch, and "untranslating"its concrete syntax trees, to reuse its existing compiler. Fabric thus provides a principled approach to gradual syntax definition in levels and locales.
Original languageEnglish
Title of host publicationSLE 2022
Subtitle of host publicationProceedings of the 15th ACM SIGPLAN International Conference on Software Language Engineering
EditorsBernd Fischer, Lola Burgueno, Walter Cazzola
PublisherAssociation for Computing Machinery, Inc
Pages134-147
Number of pages14
ISBN (Electronic)9781450399197
DOIs
Publication statusPublished - Nov 2022
Event15th ACM SIGPLAN International Conference on Software Language Engineering, SLE 2022, co-located with the ACM SIGPLAN conference on Systems, Programming, Languages, and Applications. SPLASH 2022 - Auckland, New Zealand
Duration: 6 Dec 20227 Dec 2022

Conference

Conference15th ACM SIGPLAN International Conference on Software Language Engineering, SLE 2022, co-located with the ACM SIGPLAN conference on Systems, Programming, Languages, and Applications. SPLASH 2022
Country/TerritoryNew Zealand
CityAuckland
Period6/12/227/12/22

Fingerprint

Dive into the research topics of 'Gradual Grammars: Syntax in Levels and Locales'. Together they form a unique fingerprint.

Cite this