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 条
  • [21] C plus plus builder
    Brauer, R
    DR DOBBS JOURNAL, 1997, 22 (07): : 12 - 12
  • [22] C plus plus constructors
    Meyers, S
    DR DOBBS JOURNAL, 1997, 22 (05): : 10 - 10
  • [23] C plus plus standards
    Myers, N
    DR DOBBS JOURNAL, 1997, 22 (11): : 10 - +
  • [24] C plus plus evolves!
    Naumann, Axel
    20TH INTERNATIONAL CONFERENCE ON COMPUTING IN HIGH ENERGY AND NUCLEAR PHYSICS (CHEP2013), PARTS 1-6, 2014, 513
  • [25] C plus plus constructors
    Plochan, F
    DR DOBBS JOURNAL, 1997, 22 (08): : 10 - +
  • [26] Synchronising C/C plus plus and POWER
    Sarkar, Susmit
    Memarian, Kayvan
    Owens, Scott
    Batty, Mark
    Sewell, Peter
    Maranget, Luc
    Alglave, Jade
    Williams, Derek
    ACM SIGPLAN NOTICES, 2012, 47 (06) : 311 - 321
  • [27] UPC plus plus : A PGAS Extension for C plus
    Zheng, Yili
    Kamil, Amir
    Driscoll, Michael B.
    Shan, Hongzhang
    Yelick, Katherine
    2014 IEEE 28TH INTERNATIONAL PARALLEL AND DISTRIBUTED PROCESSING SYMPOSIUM, 2014,
  • [28] ROC plus plus : Robust Optimization in C plus
    Vayanos, Phebe
    Jin, Qing
    Elissaios, George
    INFORMS JOURNAL ON COMPUTING, 2022, 34 (06) : 2873 - 2888
  • [29] Speeding up C-tree plus database searches
    Mudd, J
    DR DOBBS JOURNAL, 1996, 21 (04): : 76 - &
  • [30] Performance Analysis of B plus -Tree and CSB plus -Tree in Main Memory Database
    Sun, Fengdong
    Wang, Lan
    2014 IEEE WORKSHOP ON ELECTRONICS, COMPUTER AND APPLICATIONS, 2014, : 265 - 268