Crates.io | yes-lang |
lib.rs | yes-lang |
version | 0.1.0 |
source | src |
created_at | 2021-08-02 20:30:00.060697 |
updated_at | 2021-08-02 20:30:00.060697 |
description | Yet anothEr Scripting Language |
homepage | https://github.com/sergey-melnychuk/yes-lang |
repository | https://github.com/sergey-melnychuk/yes-lang |
max_upload_size | |
id | 430692 |
size | 70,995 |
Simple interpreter in Rust:
Goals:
Non-goals:
$ cargo run
[...]
REPL: enter :q to quit.
> let hi = fn(name) { "hello " + name };
[AST]
<function>
> hi("world")
[AST]
hello world
> :q
$
// examples/fib.yes
fn fib1(n, a, b) {
if n == 0 { a+b }
else { fib1(n-1, a+b, a) }
}
fn fib(n) {
if n <= 0 { 0 }
else {
if n <= 2 { 1 }
else {
fib1(n-2, 1, 0)
}
}
}
fib(42) == 267914296 && fib(84) == 160500643816367088
$ cargo run examples/fib.yes
[...]
true