Skip to content

jrmoulton/interpreter-rs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

87 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Interpreter-rs

Documentation

A custom hand-written interpreter and compiler from scratch (based on "Building an interpreter in Go" by Thorsten Ball)

What is Interpreter-rs

This project is an interpreter and a compiler (these are separate language implementations that share the same parser) for an expression heavy dynamically typed language with python/rust like syntax.

What is supported

This language supports expressions, functions, assignment, recursion, closures as well as a few language built-ins. The interpreter/evaluator has a more complete implementation than the compiler currently.

Examples

Recursion Example with Fibbonacci

let fib = fn(n) {
   if n < 2 {
       n
   } else {
       fib(n-1) + fib(n-2)
   }
};
fib(25)

Closure Example

let new_adder = fn(x) { 
  fn(y) {x + y} // Implicit return of a function that adds y to the x (this is the magic of the closure)
}; 
let add_two = new_adder(2);
add_two(3) // -> returns 5

About

An interpreter and compiler built in Rust

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages