Implementing an embedded compiler using program transformation rules

Domain‐specific languages (DSLs) are well‐recognized to ease programming and improve robustness for a specific domain, by providing high‐level domain‐specific notations and checks of domain‐specific properties. The compiler of a DSL, however, is often difficult to develop and maintain, because of the need to define a specific treatment for a large and potentially increasing number of language constructs. To address this issue, we propose an approach for specifying a DSL compiler using control‐flow sensitive concrete‐syntax based matching rules. These rules either collect information about the source code to carry out checks or perform transformations to carry out compilation. Because rules only mention the relevant constructs, using their concrete syntax, and hide the complexity of control‐flow graph traversal, it is easy to understand the purpose of each rule. Furthermore, new compilation steps can be added using only a small number of lines of code. We explore this approach in the context of the z2z DSL for network gateway development and show that it is beneficial to implement the core of its compiler in this manner.Copyright © 2013 John Wiley & Sons, Ltd.

[1]  S. Doaitse Swierstra,et al.  Typed Transformations of Typed Grammars: The Left Corner Transform , 2010, Electron. Notes Theor. Comput. Sci..

[2]  Curt Hibbs,et al.  Ruby on Rails: Up and Running , 2006 .

[3]  L Peyton JonesSimon,et al.  A transformation-based optimiser for Haskell , 1998 .

[4]  Yérom-David Bromberg,et al.  Bridging the Gap between Legacy Services and Web Services , 2010, Middleware.

[5]  Sasikanth Avancha,et al.  Security for Sensor Networks , 2004 .

[6]  S. Doaitse Swierstra,et al.  Parsing permutation phrases , 2004, J. Funct. Program..

[7]  Eelco Visser,et al.  WebDSL: a domain-specific language for dynamic web applications , 2008, OOPSLA Companion.

[8]  Laurence Tratt,et al.  Domain specific language implementation via compile-time meta-programming , 2008, TOPL.

[9]  Walter F. Stenning,et al.  AN EMPIRICAL STUDY , 2003 .

[10]  Christian Hofer,et al.  Polymorphic embedding of dsls , 2008, GPCE '08.

[11]  Eelco Visser,et al.  Code Generation by Model Transformation , 2008, ICMT@TOOLS.

[12]  Nuno Oliveira,et al.  Comparing general-purpose and domain-specific languages: An empirical study , 2010, Comput. Sci. Inf. Syst..

[13]  Viljem Zumer,et al.  Incremental programming language development , 2005, Comput. Lang. Syst. Struct..

[14]  Eric Van Wyk,et al.  Proving correctness of compiler optimizations by temporal logic , 2002, POPL '02.

[15]  Christopher W. Pidgeon,et al.  DMS®: Program Transformations for Practical Scalable Software Evolution , 2002, IWPSE '02.

[16]  Jeffrey C. Carver,et al.  Program comprehension of domain-specific and general-purpose languages: comparison using a family of experiments , 2011, Empirical Software Engineering.

[17]  Oscar Nierstrasz,et al.  Embedding Languages without Breaking Tools , 2010, ECOOP.

[18]  Tim Sheard,et al.  A software engineering experiment in software component generation , 1996, Proceedings of IEEE 18th International Conference on Software Engineering.

[19]  Gilles Dubochet On Embedding Domain-specific Languages with User-friendly Syntax , 2006 .

[20]  S. Doaitse Swierstra,et al.  Type-safe, self inspecting code , 2004, Haskell '04.

[21]  Alfred V. Aho,et al.  Compilers: Principles, Techniques, and Tools , 1986, Addison-Wesley series in computer science / World student series edition.

[22]  Thu D. Nguyen,et al.  Implementing Network Protocols at User Level , 1993, SIGCOMM.

[23]  Diomidis Spinellis,et al.  Notable design patterns for domain-specific languages , 2001, J. Syst. Softw..

[24]  Paul Hudak,et al.  Modular domain specific languages and tools , 1998, Proceedings. Fifth International Conference on Software Reuse (Cat. No.98TB100203).

[25]  Calvin Lin,et al.  Broadway: A Compiler for Exploiting the Domain-Specific Semantics of Software Libraries , 2005, Proceedings of the IEEE.

[26]  R. Kent Dybvig,et al.  A nanopass infrastructure for compiler education , 2004, ICFP '04.

[27]  Calton Pu,et al.  Spidle: A DSL Approach to Specifying Streaming Applications , 2003, GPCE.

[28]  David E. Culler,et al.  SPINS: security protocols for sensor networks , 2001, MobiCom '01.

[29]  Laurent Réveillère,et al.  Devil: an IDL for hardware programming , 2000, OSDI.

[30]  Martin Odersky,et al.  Programming in Scala: A Comprehensive Step-by-Step Guide, 2nd Edition , 2010 .

[31]  Eelco Visser,et al.  Stratego: A Language for Program Transformation Based on Rewriting Strategies , 2001, RTA.

[32]  Marjan Mernik,et al.  A preliminary study on various implementation approaches of domain-specific language , 2008, Inf. Softw. Technol..

[33]  Peng Ning,et al.  2008 International Conference on Information Processing in Sensor Networks TinyECC: A Configurable Library for Elliptic Curve Cryptography in Wireless Sensor Networks ∗ , 2022 .

[34]  S. Doaitse Swierstra,et al.  Typing dynamic typing , 2002, ICFP '02.

[35]  J. Lawall,et al.  A framework for simplifying the development of kernel schedulers: design and performance evaluation , 2005, Ninth IEEE International Symposium on High-Assurance Systems Engineering (HASE'05).

[36]  S. Doaitse Swierstra,et al.  Typed transformations of typed abstract syntax , 2009, TLDI '09.

[37]  Yérom-David Bromberg,et al.  Automatic Generation of Network Protocol Gateways , 2009, Middleware.

[38]  Matthias Felleisen,et al.  Implementation and use of the PLT scheme Web server , 2007, High. Order Symb. Comput..

[39]  Morten Rhiger,et al.  A foundation for embedded languages , 2002, TOPL.

[40]  David Rowe,et al.  Up and Running , 1993 .

[41]  Julia L. Lawall,et al.  Documenting and automating collateral evolutions in linux device drivers , 2008, Eurosys '08.

[42]  Daniele Antonio Di Pietro,et al.  Expression templates implementation of continuous and discontinuous Galerkin methods , 2009 .

[43]  I.D. Baxter,et al.  DMS/spl reg/: program transformations for practical scalable software evolution , 2004, Proceedings. 26th International Conference on Software Engineering.

[44]  Julia L. Lawall,et al.  A Language-Based Approach for Improving the Robustness of Network Application Protocol Implementations , 2007, 2007 26th IEEE International Symposium on Reliable Distributed Systems (SRDS 2007).

[45]  S. Jones,et al.  A Transformation-Based Optimiser for Haskell , 1998, Sci. Comput. Program..

[46]  H. Conrad Cunningham,et al.  A little language for surveys: constructing an internal DSL in Ruby , 2008, ACM-SE 46.

[47]  Arie van Deursen,et al.  The Asf+Sdf Meta-Environment: a Component-Based Language Development Environment , 2001, LDTA@ETAPS.

[48]  Aruna Raja,et al.  Domain Specific Languages , 2010 .

[49]  Laurent Réveillère,et al.  A generative programming approach to developing DSL compilers , 2005, GPCE'05.

[50]  Mitchell Wand,et al.  Continuation-Based Multiprocessing , 1980, High. Order Symb. Comput..

[51]  R. de Tornyay Up and running. , 1983, The Journal of nursing education.

[52]  Daan Leijen,et al.  Domain specific embedded compilers , 1999, DSL '99.

[53]  Yannis Smaragdakis,et al.  JTS: tools for implementing domain-specific languages , 1998, Proceedings. Fifth International Conference on Software Reuse (Cat. No.98TB100203).

[54]  M Mernik,et al.  When and how to develop domain-specific languages , 2005, CSUR.

[55]  Christophe Prud'homme,et al.  A domain specific embedded language in C++ for automatic differentiation, projection, integration and variational formulations , 2006, Sci. Program..

[56]  Laurent Réveillère,et al.  Building Efficient Distributed Systems: A Domain-Specific Language Based Approach. (Développement de systèmes distribués efficaces: une approche fondée sur les langages métiers) , 2011 .