Skip to content

🚧 A compiler for thorsten ball's monkey language written with no dependencies in C. Currently a functional interpreter with integer and boolean types, function calls, closures and conditional expressions(if).

Notifications You must be signed in to change notification settings

RS2007/compiler-for-monkey

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

77 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Current progress

  • Functional interpreter with support for:
  1. function calls
  2. operator precedence
  3. closures
  4. higher order functions
  5. primitive data structures with builtin functionality:
    • string
    • boolean
    • integers
    • hashmaps
    • arrays

Demonstration

output_file.mp4

Usage

  • If you are not using an x86 64 machine, change the TARGET value in the makefile accordingly

Compile

  make compile

Execute

  ./bin/mc # for repl
  ./bin/mc <path-to-file> # for executing a file

Sample program

Fibonnaci numbers

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

TODO

  • adding support for strings and arrays
  • adding support for hashmaps/hashtables
  • build a bytecode compiler

About

🚧 A compiler for thorsten ball's monkey language written with no dependencies in C. Currently a functional interpreter with integer and boolean types, function calls, closures and conditional expressions(if).

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages