Implementation of a Monkey compiler, as described in Writing a Compiler in Go.
- Integers, booleans, strings, arrays, hash maps
- Arithmetic expressions, let statements, recursions, closures
- First-class and higher-order functions
- Built-in functions
let people = [{"name": "Anna", "age": 24}, {"name": "Bob", "age": 99}];
let getName = fn(person) { person["name"]; };
getName(people[0]);
let fibonacci = fn(x) {
if (x == 0) {
0
} else {
if (x == 1) {
return 1;
} else {
fibonacci(x - 1) + fibonacci(x - 2);
}
}
};