Writing an interpreter in go for the monkey programming language. Following along this book from Thorsten bell.
I'll be documenting the process on seagin.me
October 2023: Lexer & Parser complete
The monkey programming language comes with a REPL. If you wish to run it yourself:
- Go version
1.6
or above
- Clone the repo
cd go-interpreter
- Run
go build -o monkey
(yes, that's it) - Now you can run the monkey repl in your terminal by running:
./monkey
If everything went well you should see this in your terminal:
Welcome to monkey v0.0.0
Press ctrl-d to exit.
>> 5 + 5
10
>> 5 + true;
type mismatch: INTEGER + BOOLEAN
>>
The interpreter has been expteded to be able to evaluate function
literals and Call
expressions.
So you interpret inputs like this:
Welcome to monkey v0.0.1
Press ctrl-d to exit.
>> let newAdder = fn(x) { fn(y) { x + y } };
>> let addTwo = newAdder(2)
>> addTwo(3)
5
>>
Strings and their evaluation is now supported. Might be buggy as \n
, \r
, \
, & \t
are not supported yet.
Although operators: +
, ==
, && !=
now work on string expressions too.