Constructing Customized Interpreters from Reusable Evaluators Using Game

  • Stijn Timbermont
  • Coen De Roover
  • Theo D’Hondt
Part of the Lecture Notes in Computer Science book series (LNCS, volume 7306)


Separation of concerns is difficult to achieve in the implementation of a programming language interpreter. We argue that evaluator concerns (i.e., those implementing the operational semantics of the language) are, in particular, difficult to separate from the runtime concerns (e.g., memory and stack management) that support them. This precludes the former from being reused and limits variability in the latter.

In this paper, we present the Game environment for composing customized interpreters from a reusable evaluator and different variants of its supporting runtime. To this end, Game offers a language for specifying the evaluator according to the generic programming methodology. Through a transformation into defunctionalized monadic style, the Game toolchain generates a generic abstract machine in which the sequencing of low-level interpretational steps is parameterized. Given a suitable instantiation of these parameters for a particular runtime, the toolchain is able to inject the runtime into the generic abstract machine such that a complete interpreter is generated.

To validate our approach, we port the prototypical Scheme evaluator to Game and compose the resulting generic abstract machine with several runtimes that vary in their automatic memory management as well as their stack discipline.


Operational Semantic Abstract Machine Require Dependency Root Pointer Supporting Runtime 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. 1.
    Abelson, H., Sussman, G.J., Sussman, J.: Structure and Interpretation of Computer Programs, 2nd edn. MIT Press/McGraw-Hill, Cambridge (1996)zbMATHGoogle Scholar
  2. 2.
    Ager, M.S., Biernacki, D., Danvy, O., Midtgaard, J.: A functional correspondence between evaluators and abstract machines. In: Proc. of the 5th ACM SIGPLAN Intl. Conf. on Principles and Practice of Declaritive Programming, PPDP 2003, pp. 8–19. ACM, New York (2003)Google Scholar
  3. 3.
    Clinger, W.D., Hartheimer, A.H., Ost, E.M.: Implementation strategies for first-class continuations. Higher Order Symbol. Comput. 12, 7–45 (1999)zbMATHCrossRefGoogle Scholar
  4. 4.
    Danvy, O.: Defunctionalized interpreters for programming languages. In: Proc. of the 13th ACM SIGPLAN Intl. Conf. on Functional Programming, ICFP 2008, pp. 131–142. ACM, New York (2008)CrossRefGoogle Scholar
  5. 5.
    Diehl, S., Sestoft, P.: Abstract machines for programming language implementation. Future Gener. Comput. Syst. 16, 739–751 (2000)CrossRefGoogle Scholar
  6. 6.
    Anton Ertl, M., Gregg, D.: The structure and performance of efficient interpreters. Journal of Instruction-Level Parallelism 5, 1–25 (2003)Google Scholar
  7. 7.
    Ganz, S.E., Friedman, D.P., Wand, M.: Trampolined style. In: Proc. of the Fourth ACM SIGPLAN Intl. Conf. on Functional Programming, ICFP 1999, pp. 18–27. ACM, New York (1999)CrossRefGoogle Scholar
  8. 8.
    Graunke, P., Findler, R.B., Krishnamurthi, S., Felleisen, M.: Automatically restructuring programs for the web. In: Proc. of the 16th IEEE Intl. Conf. on Automated Software Engineering, ASE 2001, p. 211. IEEE Computer Society, Washington, DC (2001)CrossRefGoogle Scholar
  9. 9.
    Hanson, C.: Efficient stack allocation for tail-recursive languages. In: Proc. of the 1990 ACM Conf. on LISP and Functional Programming, LFP 1990, pp. 106–118. ACM, New York (1990)CrossRefGoogle Scholar
  10. 10.
    Herzeel, C., Costanza, P.: Dynamic parallelization of recursive code: part 1: managing control flow interactions with the continuator. In: Proc. of the ACM Intl. Conf. on Object Oriented Programming Systems Languages and Applications, OOPSLA 2010, pp. 377–396. ACM, New York (2010)CrossRefGoogle Scholar
  11. 11.
    Liang, S., Hudak, P., Jones, M.: Monad transformers and modular interpreters. In: Proc. of the 22nd ACM SIGPLAN-SIGACT Symp. on Principles of Programming Languages, POPL 1995, pp. 333–343. ACM, New York (1995)CrossRefGoogle Scholar
  12. 12.
    Nielsen, L.R.: A selective cps transformation. Electr. Notes Theor. Comput. Sci. 45, 311–331 (2001)CrossRefGoogle Scholar
  13. 13.
    Reynolds, J.C.: Definitional interpreters for higher-order programming languages. In: Proc. of the ACM Annual Conf., ACM 1972, vol. 2, pp. 717–740. ACM, New York (1972)CrossRefGoogle Scholar
  14. 14.
    Rigo, A., Pedroni, S.: Pypy’s approach to virtual machine construction. In: Companion to the 21st ACM SIGPLAN Symp. on Object-Oriented Programming Systems, Languages, and Applications, OOPSLA 2006, pp. 944–953. ACM, New York (2006)CrossRefGoogle Scholar
  15. 15.
    Rompf, T., Maier, I., Odersky, M.: Implementing first-class polymorphic delimited continuations by a type-directed selective cps-transform. In: Proc. of the 14th ACM SIGPLAN Intl. Conf. on Functional Programming, ICFP 2009, pp. 317–328. ACM, New York (2009)CrossRefGoogle Scholar
  16. 16.
    Schrijvers, T., Peyton Jones, S., Chakravarty, M., Sulzmann, M.: Type checking with open type functions. In: Proc. of the 13th ACM SIGPLAN Intl. Conf. on Functional Programming, ICFP 2008, pp. 51–62. ACM, New York (2008)CrossRefGoogle Scholar
  17. 17.
    Snyder, M., Frisby, N., Kimmell, G., Alexander, P.: Writing Composable Software with InterpreterLib. In: Bergel, A., Fabry, J. (eds.) SC 2009. LNCS, vol. 5634, pp. 160–176. Springer, Heidelberg (2009)CrossRefGoogle Scholar
  18. 18.
    Talpin, J.-P., Jouvelot, P.: The type and effect discipline. Inf. Comput. 111, 245–296 (1994)MathSciNetzbMATHCrossRefGoogle Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2012

Authors and Affiliations

  • Stijn Timbermont
    • 1
  • Coen De Roover
    • 1
  • Theo D’Hondt
    • 1
  1. 1.Vrije Universiteit BrusselBelgium

Personalised recommendations