Skip to main content

Part of the book series: Lecture Notes in Computer Science ((LNCS,volume 15219))

Included in the following conference series:

  • 164 Accesses

Abstract

We present Code-centric Code Generation (CCG), an approach designed to ease the development and evolution of template-based code generators. The key idea is to generate the required templates from appropriately annotated runnable prototypes written in the target language. In essence, this turns template definition into a two-step process: 1. writing a prototype (base configuration) in the target language, and 2. annotating the prototype’s AST with parameterized operations that, given the required parameters, allow one to transform this base configuration into the intended target code. The advantage of this approach is that prototypes, in contrast to templates, can be conveniently developed and evolved with the full tool support of common software development. We illustrate the ease of CCG-based code generator development by first specifying and then evolving the required templates in order to overcome a detected security vulnerability. A proof-of-concept implementation is publicly available for reproducibility.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Subscribe and save

Springer+ Basic
$34.99 /Month
  • Get 10 units per month
  • Download Article/Chapter or eBook
  • 1 Unit = 1 Article or 1 Chapter
  • Cancel anytime
Subscribe now

Buy Now

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Similar content being viewed by others

Notes

  1. 1.

    https://github.com/CCG-Paper/CCG-VS-Code-Extension.

  2. 2.

    https://github.com/CCG-Paper/CCG-Example.

  3. 3.

    https://github.com/CCG-Paper?tab=repositories.

  4. 4.

    https://handlebarsjs.com.

References

  1. Abd Alrahman, Y., De Nicola, R., Loreti, M.: A calculus for collective-adaptive systems and its behavioural theory. Inf. Comput. 268, 104457 (2019)

    Article  MathSciNet  Google Scholar 

  2. Arnoldus, J., Bijpost, J., van den Brand, M.: Repleo: a syntax-safe template engine. In: Proceedings of the 6th International Conference on Generative Programming and Component Engineering, pp. 25–32 (2007)

    Google Scholar 

  3. Busch, D.: Towards code-centric code generators. Electronic Communication of the European Association of Software Science and Technology (2023)

    Google Scholar 

  4. De Nicola, R., Ferrari, G., Loreti, M., Pugliese, R.: A language-based approach to autonomic computing. In: Beckert, B., Damiani, F., de Boer, F.S., Bonsangue, M.M. (eds.) FMCO 2011. LNCS, vol. 7542, pp. 25–48. Springer, Heidelberg (2013). https://doi.org/10.1007/978-3-642-35887-6_2

    Chapter  Google Scholar 

  5. De Nicola, R., Hennessy, M.C.: Testing equivalences for processes. Theoret. Comput. Sci. 34(1–2), 83–133 (1984)

    Article  MathSciNet  Google Scholar 

  6. Jörges, S.: Construction and Evolution of Code Generators: A Model-Driven and Service-Oriented Approach. LNCS, vol. 7747. Springer, Heidelberg (2013). https://doi.org/10.1007/978-3-642-36127-2

    Book  Google Scholar 

  7. Nicola, R.D., Loreti, M., Pugliese, R., Tiezzi, F.: A formal approach to autonomic systems programming: the SCEL language. ACM Trans. Auton. Adap. Syst. (TAAS) 9(2), 1–29 (2014)

    Article  Google Scholar 

  8. Parr, T.J., Quong, R.W.: ANTLR: a predicated-LL (k) parser generator. Softw. Pract. Exp. 25(7), 789–810 (1995)

    Google Scholar 

  9. Pech, V., Shatalin, A., Voelter, M.: JetBrains MPS as a tool for extending Java. In: Proceedings of the 2013 International Conference on Principles and Practices of Programming on the Java Platform: Virtual Machines, Languages, and Tools, PPPJ 2013, pp. 165–168. Association for Computing Machinery, New York (2013). https://doi.org/10.1145/2500828.2500846

  10. Smyth, S.: Interactive Model-Based Compilation — A Modeller-Driven Development Approach. No. 2021/1 in Kiel Computer Science Series, Department of Computer Science, CAU Kiel (2021). https://doi.org/10.21941/kcss/2021/10, dissertation, Faculty of Engineering, Kiel University

  11. Syriani, E., Luhunu, L., Sahraoui, H.: Systematic mapping study of template-based code generation. Comput. Lang. Syst. Struct. 52, 43–62 (2018)

    Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Daniel Busch .

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2025 The Author(s), under exclusive license to Springer Nature Switzerland AG

About this paper

Check for updates. Verify currency and authenticity via CrossMark

Cite this paper

Busch, D., Smyth, S., Tegeler, T., Steffen, B. (2025). Code-Centric Code Generation. In: Margaria, T., Steffen, B. (eds) Leveraging Applications of Formal Methods, Verification and Validation. REoCAS Colloquium in Honor of Rocco De Nicola. ISoLA 2024. Lecture Notes in Computer Science, vol 15219. Springer, Cham. https://doi.org/10.1007/978-3-031-73709-1_21

Download citation

  • DOI: https://doi.org/10.1007/978-3-031-73709-1_21

  • Published:

  • Publisher Name: Springer, Cham

  • Print ISBN: 978-3-031-73708-4

  • Online ISBN: 978-3-031-73709-1

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics