We can learn how to make an interpreter in this book.
====> ☆☆☆ "Writing An Interpreter in Go" ☆☆☆
That interpreter is called Monkey in the book.
The Monkey is written in Go in the book.
But in this repository it is written in Dart.
- Lexer
- Parser
- Evaluator
- Compiler
- VM
- REPL
- Test case
- Evaluator and VM benchmarks
$ dart run
>> let a = 5
>> a + 10
15
>> let new_closure = fn(a) { fn() { a; }; };
>> let closure = new_closure(99);
>> closure();
99
let fibonacci = fn(x) {
if (x == 0) {
return 0;
} else {
if (x == 1) {
return 1;
} else {
fibonacci(x - 1) + fibonacci(x - 2);
}
}
};
fibonacci(15); #=> 610
$ dart run
>> let fibonacci = fn(x) { if (x == 0) { return 0; } else { if (x == 1) { return 1; } else { fibonacci(x - 1) + fibonacci(x - 2); } } };
>> fibonacci(15)
610
- ktanaka101 - creator, maintainer
MIT