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 条
  • [41] Programming with C plus plus concepts
    Jaervi, Jaakko
    Marcus, Mat
    Smith, Jacob N.
    SCIENCE OF COMPUTER PROGRAMMING, 2010, 75 (07) : 596 - 614
  • [42] C plus plus string performance
    Kochubeevsky, L
    DR DOBBS JOURNAL, 2003, 28 (10): : 28 - +
  • [43] Mathematizing C plus plus Concurrency
    Batty, Mark
    Owens, Scott
    Sarkar, Susmit
    Sewell, Peter
    Weber, Tjark
    POPL 11: PROCEEDINGS OF THE 38TH ANNUAL ACM SIGPLAN-SIGACT SYMPOSIUM ON PRINCIPLES OF PROGRAMMING LANGUAGES, 2011, : 55 - 66
  • [44] C plus plus standards - Response
    Stevens, A
    DR DOBBS JOURNAL, 1997, 22 (11): : 12 - 12
  • [45] A C plus plus integrator class
    Conway, DJ
    DR DOBBS JOURNAL, 1995, 20 (12): : 52 - +
  • [46] Optimizations in C plus plus Compilers
    Godbolt, Matt
    COMMUNICATIONS OF THE ACM, 2020, 63 (02) : 41 - 49
  • [47] Nitpicking C plus plus Concurrency
    Blanchette, Jasmin Christian
    Weber, Tjark
    Batty, Mark
    Owens, Scott
    Sarkar, Susmit
    PPDP 11 - PROCEEDINGS OF THE 2011 SYMPOSIUM ON PRINCIPLES AND PRACTICES OF DECLARATIVE PROGRAMMING, 2011, : 113 - 123
  • [49] C/C plus plus Thread Safety Analysis
    Hutchins, DeLesley
    Ballman, Aaron
    Sutherland, Dean
    2014 14TH IEEE INTERNATIONAL WORKING CONFERENCE ON SOURCE CODE ANALYSIS AND MANIPULATION (SCAM 2014), 2014, : 41 - 46
  • [50] Bridging Excel and C/C plus plus Code
    Punuru, Janardhana R.
    Knopf, F. Carl
    COMPUTER APPLICATIONS IN ENGINEERING EDUCATION, 2008, 16 (04) : 289 - 304