Rapid and robust compiler construction using template-based metacompilation

  • Authors:
  • C. van Reeuwijk

  • Affiliations:
  • Delft University of Technology, Delft, The Netherlands

  • Venue:
  • CC'03 Proceedings of the 12th international conference on Compiler construction
  • Year:
  • 2003

Quantified Score

Hi-index 0.00

Visualization

Abstract

We have developed Tm, a template-based metacompiler. Given a set of data-structure definitions and a template, Tm generates files that instantiate the template for the given data structures. With this process, Tm is able to generate program code to manipulate these data structures. Since it uses templates, the generated code is not restricted to a specific programming language: any sufficiently powerful programming language can be targeted. Tm has been used for a wide variety of tasks and languages. However, it was designed to support compiler construction, and most applications have been in that area. In this paper we outline Tm, and describe our experiences with using it to construct a static compiler for Java. As we will show, it has significantly accelerated implementation of the compiler. Almost 75% of its source code is generated by Tm, allowing us to rapidly implement a much more robust and sophisticated compiler than would have been possible otherwise.