Skip to main content
Character frontCharacter back
Programming Languages · Research · 2022 – 2023

Lambda Lang: an interpreter for a small language, built in Racket with EOPL and SLLGEN

→ CONTEXT: Final project for Fundamentals of Programming Languages (FLP), Universidad del Valle, 2022–2023

ROLE: Interpreter Developer · Team of 4
TIMELINE: 2022 – 2023
STATUS: Archived
FOR: Universidad del Valle · Fundamentals of Programming Languages (FLP)
STACK:
language
  • Racket
  • #lang eopl
  • Scheme
toolkit
  • sllgen scanner & parser
  • define-datatype AST
concepts
  • Environments
  • Closures
  • Objects & methods
  • REPL
TEAM: 4 people · with Valentina Cobo (Co-author), Paola Andrea Domínguez (Co-author), Juan Felipe Jaramillo (Co-author)

BLOCK // PROBLEM

Reading about how programming languages work is abstract. The course asked us to build one: a language with its own grammar, an interpreter that executes it, and a REPL to try it live.

BLOCK // SOLUTION

A language and interpreter written in Racket with the EOPL toolkit (#lang eopl). sllgen generates the scanner and parser from the grammar; the evaluator walks the AST with environments that support variables, let and letrec, assignment, procedures, methods and objects with send, update and clone. A REPL evaluates each expression live, and the AST of any program can be inspected to see how it was understood.

BLOCK // CONSTRAINTS

  • A one-semester course project for a team of four
  • The whole interpreter lives in a single Racket file, so it had to stay readable
  • The grammar had to cover assignment, procedures and objects, not just expressions

ENGINEERING IMPACT REPORT

A from-scratch language and interpreter that turned parsing, environments and evaluation into working code, with a REPL to run every expression live.

ENGINEERING DECISIONS

DECISION_01

#lang eopl with sllgen instead of a hand-written parser

sllgen generates the scanner and parser from the grammar specification, so the effort went into semantics: environments, evaluation rules and objects.

Instead of: A recursive-descent parser written by hand

DECISION_02

Environments with references to support assignment

set needs mutable bindings. Storing values in vectors behind the environment keeps let, letrec and set consistent with each other.

Instead of: Immutable environments with no assignment

DECISION_03

Objects as first-class values with send, update and clone

It let us explore object semantics (state, dispatch, cloning) on top of the functional core without building a class system.

Instead of: Procedures and records only

FIELD NOTES & DEVELOPMENT HIGHLIGHTS

NOTE_01

Grammar to interpreter in one pipeline: sllgen scanner and parser, AST datatypes and an environment-based evaluator

NOTE_02

Objects, methods and clone semantics on top of a functional core with let, letrec, procedures and apply

NOTE_03

A REPL to run programs live, with the AST available for inspection: parsing and evaluation made visible instead of theoretical

LESSONS LEARNED

  • Writing the evaluator makes scope rules concrete: every closure bug turns out to be an environment bug.
  • Inspecting the AST is the fastest debugging tool a language project can have.