ABSTRACT
Templates are a very common solution to generate code. They are used for different tasks like rendering webpages, creating Java Beans and so on. Most template systems have no notion of the object language and just generate text. The drawback of this approach is the possibility to generate syntactical incorrect code. This can lead to all kinds of annoying errors.
In this paper we present an approach for a syntax safe template engine. Syntax safety guarantees that the generated code can be correctly parsed. To ensure this we use the object language grammar to evaluate the template.
- M. G. J. van den Brand, H. A. de Jong, P. Klint, and P. A. Olivier. Efficient annotated terms. Softw. Pract. Exper., 30(3):259--291, 2000. Google ScholarDigital Library
- M. G. J. van den Brand and P. Klint. ASF+SDF Meta-Environment User Manual.Google Scholar
- M. Bravenboer, R. de Groot, and E. Visser. Metaborg in action: Examples of domain-specific language embedding and assimilation using stratego/xt. In GTTSE '05: Proceedings of the Summer School on Generative and Transformational Techniques in Software Engineering, 2005. Google ScholarDigital Library
- J. Clark, S. DeRose, et al. XML Path Language (XPath) Version 1.0. W3C Recommendation, 16:1999, 1999.Google Scholar
- Object Management Group. MOF model to text transformation language rfp. OMG Document ad/2004-04-07 (2004).Google Scholar
- Object Management Group. Unified modeling language: Super-structure-version 2.0-final adopted specification. 2005.Google Scholar
- J. Heering, P. R. H. Hendriks, P. Klint, and J. Rekers. The syntax definition formalism SDF - reference manual. SIGPLAN Notices, 24(11):43--75, 1989. Google ScholarDigital Library
- J. Herrington. Code Generation in Action. Manning Publications, 2003. Google ScholarDigital Library
- S. S. Huang, D. Zook, and Y. Smaragdakis. Statically safe program generation with SafeGen. In R. Glück and M. Lowry, editors, Generative Programming and Component Engineering (GPCE 2005), volume 3676 of Lecture Notes in Computer Science, pages 309--326. Springer-Verlag, 2005. Google ScholarDigital Library
- R. Johnson and J. Hoeller. Expert One-on-One J2EE Development without EJB. John Wiley & Sons, 2004. Google ScholarDigital Library
- H. A. de Jong and P. A. Olivier. Generation of abstract programming interfaces from syntax definitions. Journal of Logic and Algebraic Programming, 59(1-2):35--61, 2004.Google ScholarCross Ref
- P. Klint, R. Lämmel, and C. Verhoef. Toward an engineering discipline for grammarware. ACM Transactions on Software Engineering Methodology, 14(3):331--380, 2005. Google ScholarDigital Library
- E. Kohlbecker, D. P. Friedman, M. Felleisen, and B. Duba. Hygienic macro expansion. In LFP '86: Proceedings of the 1986 ACM conference on LISP and functional programming, pages 151--161, New York, NY, USA, 1986. ACM Press. Google ScholarDigital Library
- D. Leijen and E. Meijer. Domain specific embedded compilers. In PLAN '99: Proceedings of the 2nd conference on Domain-specific languages, pages 109--122, New York, NY, USA, 1999. ACM Press. Google ScholarDigital Library
- L. Moonen. Generating robust parsers using island grammars. In Proceedings of the 8th Working Conference on Reverse Engineering, pages 13--22. IEEE Computer Society Press, oct 2001. Google ScholarDigital Library
- T. J. Parr. Enforcing strict model-view separation in template engines. In WWW '04: Proceedings of the 13th international conference on World Wide Web, pages 224--233, New York, NY, USA, 2004. ACM Press. Google ScholarDigital Library
- T. Sheard. Accomplishments and research challenges in meta-programming. In SAIG 2001: Proceedings of the Second International Workshop on Semantics, Applications, and Implementation of Program Generation, pages 2--44, London, UK, 2001. Springer-Verlag. Google ScholarDigital Library
- R. Soley and the OMG Staff Strategy Group. Model-driven architecture. November 2000.Google Scholar
- W. Taha and T. Sheard. MetaML and multi-stage programming with explicit annotations. Technical report, 1999. Google ScholarDigital Library
- M. G. J. van den Brand, P. Klint, and J. J. Vinju. Term rewriting with traversal functions. ACM Trans. Softw. Eng. Methodol., 12(2):152--190, 2003. Google ScholarDigital Library
- J. J. Vinju. Analysis and Transformation of Source Code by Parsing and Rewriting. PhD thesis, University of Amsterdam, 2005.Google Scholar
- E. Visser. Scannerless generalized-LR parsing. Technical Report P9707, Programming Research Group, Universiteit van Amsterdam, juli 1997.Google Scholar
- E. Visser. Meta-programming with concrete object syntax. In GPCE '02: Proceedings of the 1st ACM SIGPLAN/SIGSOFT conference on Generative Programming and Component Engineering, pages 299--315, London, UK, 2002. Springer-Verlag. Google ScholarDigital Library
- E. Visser. Program transformation with Stratego/XT: Rules, strategies, tools, and systems in StrategoXT-0.9. In C. Lengauer et al., editors, Domain-Specific Program Generation, volume 3016 of Lecture Notes in Computer Science, pages 216--238. Spinger-Verlag, June 2004.Google Scholar
- M. Völter and A. Gartner. Jenerator - generative programming for java. OOPSLA, October 2001.Google Scholar
Index Terms
- Repleo: a syntax-safe template engine
Recommendations
Less is more: unparser-completeness of metalanguages for template engines
GCPE '11A code generator is a program translating an input model into code. In this paper we focus on template-based code generators in the context of the model view controller architecture (MVC).
The language in which the code generator is written is known as ...
Concrete syntax for objects: domain-specific language embedding and assimilation without restrictions
OOPSLA '04Application programmer's interfaces give access to domain knowledge encapsulated in class libraries without providing the appropriate notation for expressing domain composition. Since object-oriented languages are designed for extensibility and reuse, ...
Learning Translation Templates from Bilingual Translation Examples
A mechanism for learning lexical correspondences between two languages from sets of translated sentence pairs is presented. These lexical level correspondences are learned using analogical reasoning between two translation examples. Given two ...
Comments