https://github.com/jrmoulton/interpreter-rs
An interpreter and compiler built in Rust
https://github.com/jrmoulton/interpreter-rs
compiler interpreter lexer parser rust
Last synced: 10 months ago
JSON representation
An interpreter and compiler built in Rust
- Host: GitHub
- URL: https://github.com/jrmoulton/interpreter-rs
- Owner: jrmoulton
- Created: 2022-09-04T01:03:45.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2023-02-08T07:06:41.000Z (over 3 years ago)
- Last Synced: 2025-08-24T15:29:17.126Z (10 months ago)
- Topics: compiler, interpreter, lexer, parser, rust
- Language: Rust
- Homepage:
- Size: 1.86 MB
- Stars: 6
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Interpreter-rs
[](https://docs.rs/dacx0501)
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
```rust
let fib = fn(n) {
if n < 2 {
n
} else {
fib(n-1) + fib(n-2)
}
};
fib(25)
```
### Closure Example
``` rust
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
```