4 ms·
Check out "Writing An Interpreter In Go" https://interpreterbook.com/ https://interpreterbook.com/ It uses Golang to make an interpreter for a simple C-Style la
by citeguised 8y ago
Check out "Writing An Interpreter In Go" https://interpreterbook.com/ https://interpreterbook.com/
It uses Golang to make an interpreter for a simple C-Style language and it's "only" 200 pages long. I'm about a third in and my head is smoking.
- slackpad 8y agoThis is a great read! The code is very clean and easy to follow and the progression of ideas is well thought out. Even if you don't know Go you could learn that along the way without too much trouble. He also just released a companion volume writing a compiler for the Monkey as well.
- dvlsg 8y agoThat looks pretty awesome. Thanks for the suggestion. Looks like it gets to a good amount of functionality too, with first class functions and closures and the like.
- stevekemp 8y agoVery much so, and once you've completed the book there are a lot of extensions various people have made. For example here's a version with classes / OO-behaviour: https://github.com/haifenghuang/monkey https://github.com/haifenghuang/monkey Or here's my version which "just" adds some more standard-library facilities, allowing you to open/read/write files: https://github.com/skx/monkey https://github.com/skx/monkey I found the language fun to play with, and I used a virtually identical lexer and parser-idea in a recent project of my own - rather than "parsing" an input-file with regular-expressions, which is how I would have previously approached the implementation of simple DSLs. I guess that showed I'd learned something useful!
- loffa 8y agoThe jovial writing style makes the content easily consumable
- deleted 8y ago[deleted]