Writing a Compiler in Node.js using Streams
summary
Claim: a usable toy compiler is practical to build in Node.js by wiring lexer, parser and codegen as transform streams that pass JS objects in objectMode. Implementation tokenizes with a small preprocessor and a second token stage, parses with a top‑down parser that emits a Babel AST, then generates JavaScript. Tests include fizzbuzz (works) and fibonacci (iteration runs but missed the zero). Local Node diagnostics reveal buffering and backpressure behavior.
AI-written summary · about
chapters (13)
- 0:00Start
- 1:34Why write a compiler
- 2:23What are compilers
- 3:31Compiler Layers
- 6:50Node.js Core Streams
- 10:53Compiler Parts
- 11:35Grammar
- 12:22Lexer
- 13:42Parser
- 15:44Code Generation
- 16:57FizzBuzz
- 17:24Fibonacci
- 18:02Streams!
related talks
44mJavaScript AST programming: Introduction and beyond
45mHow to Make a Programming Language
50mSyntaxation
52mA bird's eye view of a compiler
25mA JavaScript Parody: A Fun Journey through Hot Topics of Node.js and JS
44mRethinking compilers with live coding
29mJavaScript in JavaScript: Inception
29mThe ClojureScript Compiler - A Look Behind the Curtains
