https://github.com/object88/rot
https://github.com/object88/rot
Last synced: 8 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/object88/rot
- Owner: object88
- Created: 2025-09-28T03:29:24.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2025-09-29T04:13:40.000Z (8 months ago)
- Last Synced: 2025-09-29T06:11:35.732Z (8 months ago)
- Language: Rust
- Size: 5.86 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# rot
The [book](https://interpreterbook.com/), _Writing an Interpreter in Go_ by Thurston Ball, works through creating an interpreter for the Monkey language.
This repo is an attempt to follow the guidance of the book, to develop a language, using [rust](https://rust-lang.org/).
## Examples
```
// comments begin with two forward slashes
// declarations follow the pattern of `let` or `const`, then an idenfier, a colon, the type, an equals, and the value.
// the format depends on the type.
let x: int64 = 5;
// functions are declared as:
// let : fn = <- { };
let foo: fn = (z: i64) <- (x: i64, y:i64) { return i64.add(x, y); };
let result = foo(1, 2)
// defining functions
proto unary_math_operation: fn = (res: i64) <- (x: i64);
const square: unary_math_operation = (out: i64) <- (in: i64) {
out = i64.mul(in, in);
};
let sum_of_squares: fn = (res: i64) <- (op: unary_math_operation, x: i64) {
res = op(x);
};
```
## Mathmatic operations
```
// let out = 5 + 6;
let out = i64.add(5, 6);
let out = i64.sub(5, 6);
let out = i64.mul(5, 6);
let out = i64.div(5, 6);
let out = i64.mod(5, 6);
```
## Thoughts
1. Types shall not be inferred but may be extrapolated.
1. No null values.
1. Primitive types:
- bool: true / false
- fn: function
- i64: 64 bit signed integer
1. First class functions