| Crates.io | rustleaf |
| lib.rs | rustleaf |
| version | 0.1.0 |
| created_at | 2025-08-14 03:46:14.703266+00 |
| updated_at | 2025-08-14 03:46:14.703266+00 |
| description | A simple programming language interpreter written in Rust |
| homepage | https://github.com/barsae/rustleaf |
| repository | https://github.com/barsae/rustleaf |
| max_upload_size | |
| id | 1794407 |
| size | 1,761,153 |
A lightweight, dynamically-typed scripting language with Rust-inspired syntax and functional programming features.
RustLeaf is designed to be an embeddable scripting language that combines the elegance of Rust's syntax with the flexibility of dynamic typing. It features expression-oriented semantics, pattern matching, and a powerful pipeline operator for functional programming.
match expressions with destructuring| for readable data transformations${...}# Clone the repository
git clone https://github.com/barsae/rustleaf.git
cd rustleaf
# Build and install
cargo install --path .
print("Hello, World!");
// Variables and functions
var x = 42;
fn greet(name) {
print("Hello, ${name}!");
}
// Pattern matching
var result = match x {
0 => "zero",
1..10 => "single digit",
_ => "large number"
};
// Pipeline operations
var sum = range(1, 11)
| filter(|n| n % 2 == 0)
| map(|n| n * n)
| sum();
// Classes
class Point {
var x = 0;
var y = 0;
fn distance() {
sqrt(self.x * self.x + self.y * self.y)
}
}
42, 3.14, 0xFF, 0b1010"hello", 'world', `multiline`true, false() (empty value)[1, 2, 3]{name: "Alice", age: 30}1..10 (exclusive), 1..=10 (inclusive)// If expressions
var max = if a > b { a } else { b };
// While loops
while condition {
// ...
}
// For loops
for item in collection {
print(item);
}
// Loop with break
loop {
if done { break; }
}
// Function declaration
fn add(a, b = 0) {
a + b
}
// Lambda expressions
var double = |x| x * 2;
var sum = |a, b| { a + b };
// Rest parameters
fn sum_all(...numbers) {
numbers | sum()
}
// Match expressions
// TODO: Verify pattern syntax, especially enum patterns
match value {
Pattern::Variant(x) => x * 2,
[first, ...rest] => process(first, rest),
{x, y} => Point { x, y },
_ => default_value
}
// Destructuring
// TODO: Verify destructuring assignment syntax
var [head, ...tail] = list;
var {x, y} = point;
// Raise errors
if invalid {
raise "Invalid input";
}
// Assert conditions
assert(x > 0, "x must be positive");
# Run tests
just test
# Build release version
cargo build --release
rustleaf/
├── src/
│ ├── lexer/ # Tokenization
│ ├── parser/ # AST generation
│ ├── eval/ # Interpreter
│ └── core/ # Core types and traits
├── specs/ # Language specification
├── tests/ # Integration tests
├── project-euler/ # Example solutions
├── rustleaf-macros/ # Proc macros
└── vscode-extension/ # VS Code syntax highlighting
We welcome contributions! Please see CONTRIBUTING.md for guidelines.
RustLeaf is dual-licensed under either:
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in RustLeaf by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.