How to write a programming language
summary
A tiny interpreter called Cell (github.com/andybalaam/cell) is implemented in Python and deliberately short to show core ideas. The lexer tokenizes input, the parser builds nested AST tuples, and the evaluator reduces trees to values with lexical scope and closures; error messages are minimal but it runs. The code sizes are explicit: lexer 40 lines, parser 81 lines, evaluator 92 lines, and the implementation demonstrates function calls, definitions, assignment, and a small standard library.
AI-written summary · about
chapters (28)
- 0:00Introduction to Cell
- 2:02Cell language demonstration
- 4:46Core language concepts
- 7:28Lexical scoping and closures
- 8:46The lexer explained
- 10:37Lexer implementation details
- 12:37Lexing strings and numbers
- 17:03Scanning string literals
- 19:38Scanning numbers and symbols
- 22:18Lexer testing and conclusion
- 25:33Introduction to parsing
- 28:06Parser data structures
- 30:01The parsing function
- 33:31Building expression trees
- 37:15Handling operator precedence
- 39:23Parsing function calls
- 43:25Parsing function definitions
- 45:24Parsing assignment statements
- 48:27Overview of evaluation
- 50:41The environment class
- 52:21Environment implementation
- 54:21Evaluating basic types
- 57:05Evaluating operations
- 59:16Error handling and evaluation
- 1:01:41Evaluating assignments
- 1:04:28Evaluating function calls
- 1:07:41Executing native functions
- 1:10:31Evaluating function definitions
related talks
46mInventing a language (placeholder title)
45mHow to Make a Programming Language
31mBuilding a Programming Language in Swift
27mPython: From Source to Execution
44mBuilding Languages Using Kotlin
18mHow to Build an Interpreter in 25 Minutes or Less
19mTales of C, the 6502 and the BBC (with added python)
22mDecoding: programming beyond text files
