lol.c

An interpreter for the LOLCODE esoteric programming language, implementing lexing, parsing, and evaluation from scratch in Python.

Python

The Problem

As a compilers course project, I needed to build an interpreter from scratch — lexer, parser, and evaluator — to understand how programming languages work under the hood. LOLCODE was chosen for its entertaining syntax while still requiring full language implementation.

The Solution

I built a complete LOLCODE interpreter in Python with three phases.

  • Lexer — Tokenizes LOLCODE source into a stream of typed tokens (keywords, identifiers, literals, operators).
  • Parser — Builds an abstract syntax tree (AST) from the token stream, handling LOLCODE's unique syntax (HAI/KTHXBYE blocks, VISIBLE for print, GIMMEH for input).
  • Evaluator — Tree-walks the AST to execute the program, managing a symbol table for variables, type coercion rules, and control flow (IF/ELSE, loops).

What Went Wrong

LOLCODE's type coercion rules are unusual — comparing a string "17" to an integer 17 should succeed, but my initial evaluator treated all type mismatches as errors.

The fix: I implemented LOLCODE's implicit casting rules as a coercion table, automatically converting between NUMBR (int), NUMBAR (float), YARN (string), and TROOF (boolean) based on the operation context.

Results

  • Complete interpreter with lexer, parser, and evaluator
  • Handles LOLCODE's unique type coercion rules
  • Deepened understanding of language implementation fundamentals

Interested in working together?

Let's Talk