In this book we will create a programming language together. We'll start with 0 lines of code and end up with a fully working interpreter for the Monkey* programming language.
Step by step. From tokens to output. All code shown and included. Fully tested.
Buy this book to learn:
How to build an interpreter for a C-like programming language from scratch
What a lexer, a parser and an Abstract Syntax Tree (AST) are and how to build your own
What closures are and how and why they work
What the Pratt parsing technique and a recursive descent parser is
What others talk about when they talk about built-in data structures
What REPL stands for and how to build one
Why this book?
This is the book I wanted to have a year ago. This is the book I couldn't find. I wrote this book for you and me. So why should you buy it? What's different about it, compared to other interpreter or compiler literature?
Working code is the focus. Code is not just found in the appendix. Code is the main focus of this book.
It's small! It has around 200 pages of which a great deal are readable, syntax-highlighted, working code.
The code presented in the book is easy to understand, easy to extend, easy to maintain.
No 3rd party libraries! You're not left wondering: "But how does tool X do that?" We won't use a tool X. We only use the Go standard library and write everything ourselves.
Tests! The interpreter we build in the book is fully tested! Sometimes in TDD style, sometimes with the tests written after. You can easily run the tests to experiment with the interpreter and make changes.
Why this book?
This book is for you if you...
learn by building, love to look under the hood
love programming and to program for the sake of learning and joy!
are interested in how your favorite, interpreted programming language works
never took a compiler course in college
want to get started with interpreters or compilers…
... but don't want to work through a theory-heavy, 800 pages, 4 pounds compiler book as a beginner
kept screaming "show me the code!" when reading about interpreters and compilers
always wanted to say: "Holy shit, I built a programming language!"
0 有用 λ 2020-10-10 00:11:42
很适合迅速打通编译器的整体流程,一个礼拜就能看完,入门之后就可以看编译原理和形式语言自动机相关的书了。看完此书再看理论的好处是,不容易被各种细节带偏。
0 有用 poringking 2021-05-14 03:28:17
用c++写了一个,所有type都是value semantics,没有pointer乱飞。参考Sean Parent的cppcon talk: Better Code: Runtime Polymorphism https://github.com/versatran01/monkey-lang
0 有用 Fu 2020-01-15 18:02:25
很适合入门
2 有用 weakish 2018-02-18 15:56:23
Demonstrates how to write an interpreter for a self-invented dynamic typing language (Monkey) in Go 1.7. The path is easy to follow but Monkey could have been simpler.
4 有用 xiaohanyu 2020-12-26 15:46:19
市面上最好的教你如何写解释器的书,相较于本科课程侧重于 parser,以及各种编译原理侧重于自动机及文法理论,此书采用 go 语言及 TDD 的方式来从头构建一个解释器,对新手来说相当友好,非常容易上手。