Skip to content
/ monkey Public

An interpreter for a C-like language named "monkey" that is written in Go

License

Notifications You must be signed in to change notification settings

musale/monkey

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

48 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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:

  • Clone this repository and then:

    $ cd monkey

  • And then build a binary

    $ go build cmd/* -o monkey

  • Finally run the binary

    $ ./monkey

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:

  1. Fork this repository.
  2. Create a branch: git checkout -b <branch_name>.
  3. Make your changes and commit them: git commit -m '<commit_message>'
  4. Push to the original branch: git push origin <project_name>/<location>
  5. Create the pull a request.

Contact

If you want to contact me you can reach me at [email protected].

License

This project uses the following license: MIT.

About

An interpreter for a C-like language named "monkey" that is written in Go

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published