Skip to content

Rust implementation of the famous Monkey programming language.

Notifications You must be signed in to change notification settings

ritchie46/monkey-rust

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rust implementation of the famous Monkey programming language.

Monkey; The programming language that lives in books

This is a Rust implementation of the original book Writing An Interpreter In Go, which (as you've might have guessed) is written in Go. At the moment this is a Work In Progress. The current implementation has:

  • Integers, Booleans, Strings, Arrays, HashMaps
  • A REPL
  • Arithmetic expressions
  • Let statements
  • First-class and higher-order functions
  • (A few) Built-in functions
  • Recursion
  • Closures

Running Monkey:

You can start the REPL by:

$ cargo run --release -p interpreter

Or run a Monkey program by:

$ cargo run --release -p interpreter <some-program.mnl>

Excerpt of the Monkey Language

let fibonacci = fn(x) {
  if (x == 0) {
    0
  } else {
    if (x == 1) {
      return 1;
    } else {
      fibonacci(x - 1) + fibonacci(x - 2);
    }
  }
};

My own flavor

I took the liberty to change some behavior of the language.

  • I don't like puts so we use print
>> print("foo" + "bar")
"foobar"
  • added a insert method for mutable hashes and arrays.
>> let map = {1: "one"};    
>> map.insert(2, "two")
>> map
{1: "one", 2: "two"}

About

Rust implementation of the famous Monkey programming language.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages