Trieste: A C plus plus DSL for Flexible Tree Rewriting

被引:0
|
作者
Clebsch, Sylvan [1 ]
Blomqvist, Matilda [2 ]
Castegren, Elias [2 ]
Johnson, Matthew A. [3 ]
Parkinson, Matthew J. [3 ]
机构
[1] Microsoft Azure Res, Austin, TX 78701 USA
[2] Uppsala Univ, Uppsala, Sweden
[3] Microsoft Azure Res, Cambridge, England
关键词
Rewriting; Compilers; Domain-Specific Languages;
D O I
10.1145/3687997.3695647
中图分类号
TP18 [人工智能理论];
学科分类号
081104 ; 0812 ; 0835 ; 1405 ;
摘要
Compilation is all about tree rewriting. In functional languages where all data is tree-shaped, tree rewriting is facilitated by pattern matching, but data immutability leads to copying for each update. In object-oriented languages like Java or C++, a standard approach is to use the visitor pattern, which increases modularization but also adds indirection and introduces boilerplate code. In this paper, we introduce Trieste - a novel tree-rewriting DSL, combining the power of C++ with the expressivity of pattern matching. In Trieste, sequences of rewrite passes can be used to read a file to produce an abstract syntax tree (AST), convert from one AST to another, or write an AST to disk. Each pass rewrites an AST in place using subtree pattern matching, where the result is dynamically checked for well-formedness. Checking the well-formedness of trees dynamically enables flexibly changing the tree structure without having to define new data types for each intermediate representation. The well-formedness specification can also be used for scoped name binding and generating random well-formed trees for fuzz testing in addition to checking the shape of trees. Trieste has been used to build fully compliant parsers for YAML and JSON, a transpiler from YAML to JSON, and a compiler and interpreter for the policy language Rego.
引用
收藏
页码:184 / 189
页数:6
相关论文
共 50 条
  • [11] A PBPO plus Graph Rewriting Tutorial
    Overbeek, Roy
    Endrullis, Jorg
    ELECTRONIC PROCEEDINGS IN THEORETICAL COMPUTER SCIENCE, 2022, (354): : 45 - 63
  • [12] PBPO plus Graph Rewriting in Context
    Endrullis, Jorg
    ELECTRONIC PROCEEDINGS IN THEORETICAL COMPUTER SCIENCE, 2023, (377):
  • [13] Flexible semi-automatic support for type migration of primitives for C/C plus plus programs
    Szalay, Richard
    Porkolab, Zoltan
    2022 IEEE INTERNATIONAL CONFERENCE ON SOFTWARE ANALYSIS, EVOLUTION AND REENGINEERING (SANER 2022), 2022, : 878 - 889
  • [14] Exudyn - a C plus plus -based Python']Python package for flexible multibody systems
    Gerstmayr, Johannes
    MULTIBODY SYSTEM DYNAMICS, 2024, 60 (04) : 533 - 561
  • [15] A flexible C plus plus framework for the partitioned solution of strongly coupled multifield problems
    Koenig, Marcel
    Radtke, Lars
    Duester, Alexander
    COMPUTERS & MATHEMATICS WITH APPLICATIONS, 2016, 72 (07) : 1764 - 1789
  • [16] VisualDSP plus plus makes for flexible programming
    Moretti, G
    EDN, 2001, 46 (02) : 26 - 26
  • [17] C for C plus plus programmers
    Stevens, A
    DR DOBBS JOURNAL, 1997, 22 (07): : 99 - 102
  • [18] Structured Synchronous Reactive Programming for Game Development Case Study: On Rewriting Pingus from C plus plus to CEU
    Sant'Anna, Francisco
    2018 17TH BRAZILIAN SYMPOSIUM ON COMPUTER GAMES AND DIGITAL ENTERTAINMENT (SBGAMES 2018), 2018, : 240 - 249
  • [19] C plus plus and Interoperability Between Libraries: The GraphBLAS C plus plus Specification
    Brock, Benjamin
    McMillan, Scott
    Buluc, Aydin
    Mattson, Timothy G.
    Moreira, Jose E.
    2023 IEEE INTERNATIONAL PARALLEL AND DISTRIBUTED PROCESSING SYMPOSIUM WORKSHOPS, IPDPSW, 2023, : 207 - 215
  • [20] CAPD::DynSys: a flexible C plus plus toolbox for rigorous numerical analysis of dynamical systems
    Kapela, Tomasz
    Mrozek, Marian
    Wilczak, Daniel
    Zgliczynski, Piotr
    COMMUNICATIONS IN NONLINEAR SCIENCE AND NUMERICAL SIMULATION, 2021, 101