← Back to Projects

Scheme Language Interpreter

2025

  • Built an interpreter for a subset of Scheme in Python, from parsing through evaluation.
  • Implemented core special forms, user-defined procedures, and lexical scoping.
  • Added tail-call optimization so deeply recursive programs run in constant space.

Collaborators

Links / info


Overview

This was the final project for CS 61A (Structure and Interpretation of Computer Programs). I wrote an interpreter for a subset of the Scheme programming language in Python. The interpreter runs a full read-eval-print loop: it reads Scheme source, parses it into expressions, evaluates those expressions against an environment, and prints the result.

What I built

I implemented the core special forms (define, lambda, if, cond, and, or, let, begin, and quotation), user-defined procedures with lexical scoping through environment frames, and a library of built-in procedures. The interpreter also performs tail-call optimization, so deeply recursive Scheme programs run in constant space instead of overflowing the stack. Building a language end to end was a hands-on look at how code is actually evaluated, from parsing through closures and environments.

↑ Back to top

© 2026 Lachlan Watts-Tobin