A Cheap Implementation of Resugaring in BIRDS Based on Bidirectional Transformation

Syntactic sugar refers to a certain syntactic structure added to the programming language. This syntactic structure has no effect on the function of the language, but is more convenient for programmers to use. Since syntactic sugar will be translated to the basic syntactic structure of the core language at the compilation stage, the relationship between the source program written with syntactic sugar and the execution of the core program is masked, and the compiled program is unfamiliar to programmers. It is not convenient for programmers to learn and debug source programs written with syntactic sugar. To solve that problem, this paper adopts the idea of resugaring for automatically transforming the evaluation sequence of the core language into the evaluation sequence of the surface language, and gives a cheap implementation using the existing bidirectional transformation tool BIRDS. The resugaring algorithms for both non-recursive and recursive desugaring transformations are implemented using Datalog, and the solutions to maintain two important properties of emulation and abstraction in the process of resugaring are studied.

[1]  Ralf Lämmel,et al.  Bidirectional Transformations: A Cross-Discipline Perspective , 2009, ICMT@TOOLS.

[2]  Guy Lapalme,et al.  Implementation of a “Lisp comprehension” macro , 1991, LIPO.

[3]  Andy Schürr,et al.  Specification of Graph Translators with Triple Graph Grammars , 1994, WG.

[4]  Zhenjiang Hu,et al.  BiGUL: a formally verified core language for putback-based bidirectional programming , 2016, PEPM.

[5]  Li Liu,et al.  Brul: A Putback-Based Bidirectional Transformation Library for Updatable Views , 2016, Bx@ETAPS.

[6]  Shriram Krishnamurthi,et al.  Resugaring: lifting evaluation sequences through syntactic sugar , 2014, PLDI.

[7]  Benjamin C. Pierce,et al.  Relational lenses: a language for updatable views , 2006, PODS '06.

[8]  Matthias Felleisen,et al.  Debugging hygienic macros , 2010, Sci. Comput. Program..

[9]  Matthias Felleisen,et al.  Expressing Structural Properties as Language Constructs , 1999, ESOP.

[10]  Michal Antkiewicz,et al.  Design Space of Heterogeneous Synchronization , 2007, GTTSE.

[11]  Nicolas Spyratos,et al.  Update semantics of relational views , 1981, TODS.

[12]  Zhenjiang Hu,et al.  Programmable view update strategies on relations , 2019, Proc. VLDB Endow..

[13]  Zhenjiang Hu,et al.  A Clear Picture of Lens Laws - Functional Pearl , 2015, MPC.

[14]  Francesco Ricci,et al.  Harmonise: A Solution for Data Interoperability , 2002, I3E.

[15]  John Clements,et al.  Portable and high-level access to the stack with Continuation Marks , 2006 .

[16]  Matthias Felleisen,et al.  Modeling an Algebraic Stepper , 2001, ESOP.

[17]  Nate Foster,et al.  Combinators for bi-directional tree transformations: a linguistic approach to the view update problem , 2005, POPL '05.

[18]  Zhenjiang Hu,et al.  An axiomatic basis for bidirectional programming , 2018, Proc. ACM Program. Lang..