Monkey
Monkey is a C-like interpreter for the monkey language that is built in the book "Writing an interpreter in Go" by Thorsten Ball.
Prerequisites
Before you begin, ensure you have met the following requirements:
- You have knowledge of programming and can do so in Go.
- You have Go v1.7+ installed.
Language Features
- Function literals.
- First class and Higher Order Functions.
- Closures.
- Variable Bindings.
- Prefix and Infix operations.
- Builtin Data types;
- Booleans.
- Strings.
- Hashes.
- Integers.
- Arrays.
- Builtin functions
-
len for length of iterables.
-
first for first element in an array.
-
last for the last element in an array.
-
rest for the elements in an array except the first.
-
push to add a new element to the end of the array.
Personal TODOs:
- Read source code input from files.
- Support Unicode characters.
- Support floating point numbers.
- Postfix operations [?].
- Improve Syntax errors and stack errors.
- Add support for multiline strings.
- Improve string lexing i.e. check for opening and closing double quotes.
Installing monkey
To install monkey, follow these steps:
Using monkey
To use monkey, follow these steps:
$ ./monkey
Hello mus!
__,__
.--. .-" "-. .--.
/ .. \/ .-. .-. \/ .. \
| | '| / Y \ |' | |
| \ \ \ 0 | 0 / / / |
\ '- ,\.-"""""""-./, -' /
''-' /_ ^ ^ _\ '-''
| \._ _./ |
\ \ '~' / /
'._ '-=-' _.'
'-----'
>> 1 + 1
3
>> let newAdder = fn(x) { fn(y) { x + y } };
>> let addTwo = newAdder(2);
>> addTwo(3);
5
Contributing to monkey
To contribute to monkey, follow these steps:
- Fork this repository.
- Create a branch:
git checkout -b <branch_name>.
- Make your changes and commit them:
git commit -m '<commit_message>'
- Push to the original branch:
git push origin <project_name>/<location>
- Create the pull a request.
If you want to contact me you can reach me at [email protected].
License
This project uses the following license: MIT.