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 条
  • [1] DSL in C plus plus Template Metaprogram
    Porkolab, Zoltan
    Sinkovics, Abel
    Siroki, Istvan
    CENTRAL EUROPEAN FUNCTIONAL PROGRAMMING SCHOOL, CEFP 2013, 2015, 8606 : 76 - 114
  • [2] Max/Plus Tree Automata for Termination of Term Rewriting
    Koprowski, Adam
    Waldmann, Johannes
    ACTA CYBERNETICA, 2009, 19 (02): : 357 - 392
  • [3] DSL plus ISP = CLEC
    Llana, A
    COMMUNICATIONS NEWS, 1998, 35 (11): : 14 - +
  • [4] Zipr plus plus : Exceptional Binary Rewriting
    Hiser, Jason
    Anh Nguyen-Tuong
    Hawkins, William
    McGill, Matthew
    Co, Michele
    Davidson, Jack
    FEAST'17: PROCEEDINGS OF THE 2017 WORKSHOP ON FORMING AN ECOSYSTEM AROUND SOFTWARE TRANSFORMATION, 2017, : 9 - 15
  • [5] Science plus fiction in Trieste
    Savio, S
    CINEFORUM, 2005, 45 (02): : 75 - 76
  • [6] FLEXIBLE SYMBOL TABLE STRUCTURES FOR COMPILING C plus plus .
    Dewhurst, Stephen C.
    Software - Practice and Experience, 1987, 17 (08) : 503 - 5
  • [7] Expressing and Applying C plus plus Code Transformations for the HDF5 API Through a DSL
    Golasowski, Martin
    Bispo, Joao
    Martinovic, Jan
    Slaninova, Katerina
    Cardoso, Joao M. P.
    COMPUTER INFORMATION SYSTEMS AND INDUSTRIAL MANAGEMENT (CISIM 2017), 2017, 10244 : 303 - 314
  • [8] StochHMM: a flexible hidden Markov model tool and C plus plus library
    Lott, Paul C.
    Korf, Ian
    BIOINFORMATICS, 2014, 30 (11) : 1625 - 1626
  • [9] Tree plus plus : Truncated Tree Based Graph Kernels
    Ye, Wei
    Wang, Zhen
    Redberg, Rachel
    Singh, Ambuj
    IEEE TRANSACTIONS ON KNOWLEDGE AND DATA ENGINEERING, 2021, 33 (04) : 1778 - 1789
  • [10] PyGB: GraphBLAS DSL in Python']Python with Dynamic Compilation into Efficient C plus
    Chamberlin, Jesse
    Zalewski, Marcin
    McMillan, Scott
    Lumsdaine, Andrew
    2018 IEEE INTERNATIONAL PARALLEL AND DISTRIBUTED PROCESSING SYMPOSIUM WORKSHOPS (IPDPSW 2018), 2018, : 310 - 319