How to Build a Compiler
summary
A working Lisp → JavaScript compiler gets built end to end: a tokenizer, recursive parser, AST traverser using a visitor, a transformer that maps into a Babel AST (with a parent context hack and top‑level calls wrapped as ExpressionStatements), and a code generator that prints identifiers numbers and semicolons. The implementation is compact at ~250 lines, translates S‑expressions to JS call expressions and commas, and is demoed live producing correct output, proving the pipeline actually works.
AI-written summary · about
chapters (16)
- 0:00Introduction
- 1:17Why Compilers
- 2:07The Basics
- 4:26What is a Compiler
- 7:10Transformation
- 8:25Traversal
- 8:55Visiting
- 9:29Code Generation
- 10:20Compilers
- 11:50Lisp
- 13:15Tokenizer
- 16:45Parser
- 20:32Traverser
- 22:18Transformer
- 24:43Code Generator
- 25:47Pipeline
related talks
13mBrewing JavaScript: Compile your own domain-specific language to JavaScript
26mMake Your Own Programming Language!
22mHow Linters, Compilers & Other Cool Things Work
31mJavaScript Compilers For Fun and Profit
27mParsing, Compiling, and Static Metaprogramming
20mJavaScript Transformation
32mBuilding a High Performance JavaScript Compiler
44mJavaScript AST programming: Introduction and beyond
