Building Interpreters with Rewriting Strategies

Eelco Dolstra, Eelco Visser. Building Interpreters with Rewriting Strategies. Electronic Notes in Theoretical Computer Science, 65(3):57-76, 2002. [doi]

Abstract

Programming language semantics based on pure rewrite rules suffers from the gap between the rewriting strategy implemented in rewriting engines and the intended evaluation strategy. This paper shows how programmable rewriting strategies can be used to implement interpreters for programming languages based on rewrite rules. The advantage of this approach is that reduction rules are first class entities that can be reused in different strategies, even in other kinds of program transfor- mations such as optimizers. The approach is illustrated with several interpreters for the lambda calculus based on implicit and explicit (parallel) substitution, different strategies including normalization, eager evaluation, lazy evaluation, and lazy eval- uation with updates. An extension with pattern matching and choice shows that such interpreters can easily be extended.