Abstract
Many applications of model-based techniques ultimately require a model-to-text transformation to make practical use of the information encoded in meta-model instances. This step requires a code generator that has to be validated in order to ensure that the translation doesn’t alter the semantics of the model. Validation is often test-based, i.e. the code generator is executed on a wide range of inputs in order to verify the correctness of its output. Unfortunately, tests generally only prove the presence of errors, not their absence. This paper identifies the common core of string template implementations that are often used in the description of code generators, deriving a formal model that is suitable for mathematical reasoning. We provide a formal proof of the equivalence in expressiveness between string templates and context free grammars, thereby allowing the application of formal results from language theory. From there, we derive a scheme that would allow the verification of syntactical correctness for generated code before the translation of any model-instance is attempted, at the expense of freedom in the variability of the description.
This is a preview of subscription content, log in via an institution.
Buying options
Tax calculation will be finalised at checkout
Purchases are for personal use only
Learn about institutional subscriptionsReferences
Arnoldus, B.J.: An illumination of the template enigma: software code generation with templates. Ph.D. thesis, Technische Universiteit Eindhoven (2010)
Bettini, L.: Implementing Domain-Specific Languages with Xtext and Xtend. Packt Publishing, Birmingham (2013)
Hopcroft, J.E., Ullman, J.D.: Introduction to Automata Theory, Languages, and Computation, Chap. 8, p. 203. In: [5] (1979)
Hopcroft, J.E., Ullman, J.D.: Introduction to Automata Theory, Languages, and Computation, Chap. 8, pp. 185–192. In: [5] (1979)
Hopcroft, J.E., Ullman, J.D.: Introduction to Automata Theory, Languages, and Computation. Addison-Wesley (1979)
Parr, T.J.: Enforcing strict model-view separation in template engines. In: Proceedings of the 13th International Conference on World Wide Web, pp. 224–233. ACM (2004)
Parr, T.J.: A functional language for generating structured text (2006). http://www.cs.usfca.edu/~parrt/papers/ST.pdf
Rudd, T., Orr, M., Bicking, I., Esterbrook, C.: Cheetah: the python-powered template engine. In: 10th International Python Conference-2002 (2007)
Wachsmuth, G.: A formal way from text to code templates. In: Chechik, M., Wirsing, M. (eds.) FASE 2009. LNCS, vol. 5503, pp. 109–123. Springer, Heidelberg (2009). doi:10.1007/978-3-642-00593-0_8
Author information
Authors and Affiliations
Corresponding author
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2017 Springer International Publishing AG
About this paper
Cite this paper
Weber, D., Fischer, J. (2017). Static Syntax Validation for Code Generation with String Templates. In: Csöndes, T., Kovács, G., Réthy, G. (eds) SDL 2017: Model-Driven Engineering for Future Internet. SDL 2017. Lecture Notes in Computer Science(), vol 10567. Springer, Cham. https://doi.org/10.1007/978-3-319-68015-6_2
Download citation
DOI: https://doi.org/10.1007/978-3-319-68015-6_2
Published:
Publisher Name: Springer, Cham
Print ISBN: 978-3-319-68014-9
Online ISBN: 978-3-319-68015-6
eBook Packages: Computer ScienceComputer Science (R0)