Code Generation with Templates

Templates are used to generate all kinds of text, including computer code. The last decade, the use of templates gained a lot of popularity due to the increase of dynamic web applications. Templates are a tool for programmers, and implementations of template engines are most times based on practical experience rather than based on a theoretical background. This book reveals the mathematical background of templates and shows interesting findings for improving the practical use of templates. First, a framework to determine the necessary computational power for the template metalanguage is presented. The template metalanguage does not need to be Turing-complete to be useful. A non-Turing-complete metalanguage enforces separation of concerns between the view and model. Second, syntactical correctness of all languages of the templates and generated code is ensured. This includes the syntactical correctness of the template metalanguage and the output language. Third, case studies show that the achieved goals are applicable in practice. It is even shown that syntactical correctness helps to prevent cross-site scripting attacks in web applications. The target audience of this book is twofold. The first group exists of researcher interested in the mathematical background of templates. The second group exists of users of templates. This includes designers of template engines on one side and programmers and web designers using templates on the other side

[1]  Thorsten Sturm,et al.  Generating Code from UML with Velocity Templates , 2002, UML.

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

[3]  Ghica van Emde Boas Template Programming for Model-Driven Code Generation , 2004 .

[4]  Eelco Visser,et al.  Meta-programming with Concrete Object Syntax , 2002, GPCE.

[5]  Jurgen J. Vinju,et al.  Type-Driven Automatic Quotation of Concrete Object Code in Meta Programs , 2005, RISE.

[6]  Michael D. Ernst,et al.  An Empirical Analysis of C Preprocessor Use , 2002, IEEE Trans. Software Eng..

[7]  J. Virágh Deterministic ascending tree automata II , 1983, Acta Cybern..

[8]  Arie van Deursen,et al.  The ASF+SDF Meta-environment: A Component-Based Language Development Environment , 2001 .

[9]  Shan Shan Huang,et al.  Statically safe program generation with safegen , 2005, GPCE'05.

[10]  Ralph Johnson,et al.  design patterns elements of reusable object oriented software , 2019 .

[11]  Hélène Kirchner,et al.  ELAN: A logical framework based on computational systems , 1996, WRLA.

[12]  Guido Wachsmuth A Formal Way from Text to Code Templates , 2009, FASE.

[13]  Leon Moonen,et al.  Generating robust parsers using island grammars , 2001, Proceedings Eighth Working Conference on Reverse Engineering.

[14]  Murray Hill,et al.  Yacc: Yet Another Compiler-Compiler , 1978 .

[15]  Jim Conallen,et al.  Modeling Web application architectures with UML , 1999, CACM.

[16]  Günter Hotz,et al.  Normal-form transformations of context-free grammars , 1978, Acta Cybern..

[17]  Paul Klint,et al.  The syntax definition formalism SDF—reference manual— , 1989, SIGP.

[18]  Aske Simon Christensen,et al.  Precise Analysis of String Expressions , 2003, SAS.

[19]  Terence John Parr,et al.  Enforcing strict model-view separation in template engines , 2004, WWW '04.

[20]  Ralf Lämmel,et al.  Towards an engineering discipline for GRAMMARWARE Draft as of August 17 , 2003 , 2003 .

[21]  Douglas C. Schmidt,et al.  Guest Editor's Introduction: Model-Driven Engineering , 2006, Computer.

[22]  Alfred V. Aho,et al.  Code Generation for Expressions with Common Subexpressions , 1977, J. ACM.

[23]  Tim Sheard,et al.  Accomplishments and Research Challenges in Meta-programming , 2001, SAIG.

[24]  Jurgen Vinju,et al.  Analysis and transformation of source code by parsing and rewriting , 2005 .

[25]  Eelco Visser,et al.  Preventing injection attacks with syntax embeddings , 2007, GPCE '07.

[26]  Stephen Travis Pope,et al.  A Description of the Model-View-Controller User Interface Paradigm in the Smalltalk-80 System , 1998 .

[27]  Tobias Nipkow,et al.  Term rewriting and all that , 1998 .

[28]  Bernard Lang,et al.  Document structure and modularity in mentor , 1984 .

[29]  Frank Neven,et al.  DTDs versus XML schema: a practical study , 2004, WebDB '04.

[30]  Hayco de Jong,et al.  Generation of abstract programming interfaces from syntax definitions , 2004, J. Log. Algebraic Methods Program..

[31]  Andrew S. Tanenbaum,et al.  Is your cat infected with a computer virus? , 2006, Fourth Annual IEEE International Conference on Pervasive Computing and Communications (PERCOM'06).

[32]  Eelco Visser,et al.  Generation of formatters for context-free languages , 1996, TSEM.

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

[34]  Christophe Ringeissen,et al.  A Pattern Matching Compiler for Multiple Target Languages , 2003, CC.

[35]  María Alpuente,et al.  A compositional semantics for conditional term rewriting systems , 1994, Proceedings of 1994 IEEE International Conference on Computer Languages (ICCL'94).

[36]  Eelco Visser,et al.  Scannerless Generalized-LR Parsing , 1997 .

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

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

[39]  J.W.C. Koorn,et al.  Generating Uniform User-Interfaces for Interactive Programming Environments , 1994 .

[40]  Walid Taha,et al.  MetaML and multi-stage programming with explicit annotations , 2000, Theor. Comput. Sci..

[41]  Matthias Felleisen,et al.  Hygienic macro expansion , 1986, LFP '86.

[42]  Adrian Johnstone,et al.  GLL Parsing , 2010, LDTA.

[43]  Paul Klint,et al.  Term rewriting with traversal functions , 2003, TSEM.

[44]  David A. Watt,et al.  Programming language design concepts , 2004 .

[45]  Todd L. Veldhuizen C++ Templates as Partial Evaluation , 1999, PEPM.

[46]  Alfred V. Aho,et al.  Code generation using tree matching and dynamic programming , 1989, ACM Trans. Program. Lang. Syst..

[47]  Murali Mani,et al.  Taxonomy of XML schema languages using formal language theory , 2005, TOIT.

[48]  Jan A. Bergstra,et al.  Algebraic specification , 1989 .

[49]  Mark van den Brand,et al.  Repleo: a syntax-safe template engine , 2007, GPCE '07.

[50]  Joost Engelfriet,et al.  Tree transducers, L systems and two-way machines (Extended Abstract) , 1978, J. Comput. Syst. Sci..

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

[52]  Maurice H. Halstead,et al.  Elements of software science (Operating and programming systems series) , 1977 .

[53]  Jeffrey D. Ullman,et al.  Introduction to Automata Theory, Languages and Computation , 1979 .

[54]  David S. Wile,et al.  Abstract Syntax from Concrete Syntax , 1997, Proceedings of the (19th) International Conference on Software Engineering.

[55]  Jean-Marie Favre,et al.  Towards a Basic Theory to Model Model Driven Engineering , 2004 .

[56]  Donald E. Knuth,et al.  On the Translation of Languages from Left to Right , 1965, Inf. Control..