2026-07-08tbench harbor

Debugging a Tree-Walking Interpreter Against a Formal Language Spec

interpreterssoftware-engineeringdebugginglanguage-design

Task

Given a source-code implementation of a tree-walking interpreter for MiniLang — a small, dynamically-typed scripting language — and an immutable formal language specification, identify and fix every defect in the interpreter so it faithfully implements every rule in the spec.

The specification covered expression evaluation, operator precedence, type coercion, variable scoping, control flow, and runtime error semantics. All corrections targeted interpreter source files exclusively; the spec was read-only.

Approach

Cross-referenced interpreter behaviour against specification rules construct-by-construct. Executed test programs that exercised edge cases in each language feature, compared actual vs. specified output, then traced each divergence back to its source in the interpreter.

Key defect categories found:

  • Incorrect operator associativity and precedence handling in the AST evaluator
  • Type coercion rules not matching spec — especially in mixed-type arithmetic
  • Scoping bugs where variable lookup traversed the wrong environment chain
  • Control flow edge cases in loop and conditional evaluation

Key Techniques

Tree-walking interpreter internals, formal language specification analysis, spec-driven debugging, dynamic type system semantics, AST traversal logic

Environment

Self-contained Docker environment. Automated test suite validated interpreter output against specification-derived ground truth. Iterated until all checks passed.

GitHub
LinkedIn
Spotify
Netflix