Concrete Syntax Metapatterns

Conference Paper (2024)
Author(s)

L. Miljak (TU Delft - Programming Languages)

Casper Bach Poulsen (TU Delft - Programming Languages)

R. Corvino (TNO - Embedded Systems Innovation)

Research Group
Embedded Systems
DOI related publication
https://doi.org/10.1145/3687997.3695637
More Info
expand_more
Publication Year
2024
Language
English
Research Group
Embedded Systems
Pages (from-to)
43-55
ISBN (electronic)
9798400711800
Reuse Rights

Other than for strictly personal use, it is not permitted to download, forward or distribute the text or part of it, without the consent of the author(s) and/or copyright holder(s), unless the work is under an open content license such as Creative Commons.

Abstract

Software engineers should be able to apply massive code refactorings to maintain large legacy code bases. A key aspect of developing restructurings is matching and transforming code snippets using abstract syntax trees (ASTs). Matching on ASTs is typically done through AST patterns with holes. AST patterns can be extended to become metapatterns, which increase their expressivity. Metapattern examples include disjunctions, descendant patterns, and patches where we inline transformations into the pattern itself. Despite their expressivity, abstract syntax (meta)patterns can become verbose and require restructuring engineers to be intimately familiar with the data types that define the AST. A better approach is to use concrete syntax patterns, which allows us to denote our patterns in the syntax of the object language. Previous work has shown that we can use external black-box parsers of the object language to compile concrete syntax patterns for arbitrary languages. In this paper, we scale this compilation method to support concrete syntax metapatterns, which allows for a more declarative way of expressing restructurings. We evaluate this method through an implementation written in Kotlin.