Skip to content

Latest commit

 

History

8 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Crafting Interpreters

Working through Crafting Interpreters by Robert Nystrom.

The book builds two complete interpreters for Lox, a small dynamically-typed scripting language:

Part Interpreter Language Approach
I jlox Java Tree-walk interpreter
II clox C Bytecode VM (coming later)

A Python translation of jlox (lox-python/) is maintained alongside the Java source, chapter by chapter.


Repository Layout

crafting-interpreters/
├── src/com/craftinginterpreters/
│   ├── lox/          ← jlox source (Java)
│   └── tool/         ← code-generation utilities
├── lox-python/       ← Python translation of jlox
│   └── tests/        ← pytest test suite
├── hello.lox         ← sample Lox script
├── Makefile          ← build / run targets
└── CLAUDE.md         ← project notes & conventions

jlox (Java)

Requirements: JDK 17+

# Compile
make compile

# Interactive REPL
make run

# Run a script
make run-file FILE=hello.lox

# Regenerate Expr.java from the grammar definition
make generate

lox-python (Python)

Requirements: Python 3.11+

cd lox-python

# Interactive REPL
python lox.py

# Run a script
python lox.py ../hello.lox

# Run tests
python -m pytest tests/ -v

Progress

Chapter Topic Java Python
4 Scanning ✅ ✅
5 Representing Code (AST) ✅ ✅
6 Parsing Expressions ✅ ✅
7 Evaluating Expressions ✅ ✅
8 Statements and State ✅ ✅
9 Control Flow
10 Functions
11 Resolving and Binding
12 Classes
13 Inheritance

The Lox Language

Lox is a small, dynamically-typed language with:

  • Arithmetic, comparison, and logical operators
  • Variables (var), control flow (if, while, for)
  • Functions (fun) and closures
  • Classes and inheritance
var x = 1 + 2.5;
print x;

About

Working through Crafting Interpreters by Robert Nystrom - building jlox (Java) and a Python translation, chapter by chapter.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages