Writing an Interpreter in GO - Day 1
/ 2 min read
읽게된 계기
항상 Compiler나 Interpreter가 작동하는 원리를 배우고는 싶었다.
몇년 전 코로나 자가격리때 파이썬으로 BASIC interpreter를 만든 기억은 나지만, 그저 튜토리얼을 따라 친 것이었기에, 이해가 부족했다.
중간에 드는 생각
(1%)
Especially with a C-like language and its curly braces and semicolons, where I didn’t even know how to start parsing them. The academic textbooks had the answers I was looking for, of course. But rather inaccessible to me, behind their lengthy, theoretical explanations and mathematical notation.
Semicolon 때문에 어떻게 parse 할 지 모르겠다고 했는데, 오히려 parsing이 쉬워진다고 생각했다.
라인과 관계 없이 ;
만 나오면 하나의 statement1로 처리하면 된다고 생각했다.
(2%)
Monkey also supports a special type of functions, called higher order functions. These are functions that take other functions as arguments. Here is an example:
Pseudo lambda calculus - LET’S GOOOOOO —
(3%)
The interpreter we’re going to build in this book will implement all these features. It will tokenize and parse Monkey source code in a REPL2, building up an internal representation of the code called abstract syntax tree and then evaluate this tree.
(3%)
But why the name? Why is it called “Monkey”? Well, because monkeys are magnificent, elegant, fascinating and funny creatures. Exactly like our interpreter.
My language name - Oomiz