A dice expression language and evaluator written in Rust, compiling to both a CLI tool and a WASM package for embedding in websites. Supports dice notation (
2d6, ^d20, vd20) with full arithmetic expressions, operator precedence, and per-roll statistics (min, max, avg).
https://1d20.io
- Rust 99.1%
- Shell 0.9%
- Session struct in lib.rs owns named variable memory (HashMap) and eval history (Vec<EvalResult>) - evaluate() now takes &Session; REPL pushes each result onto history after printing - Lexer recognizes identifiers and keywords: save, no, show - Expr::Var added to AST for future variable resolution |
||
|---|---|---|
| .zed | ||
| scripts | ||
| src | ||
| .gitignore | ||
| Cargo.lock | ||
| Cargo.toml | ||
| LICENSE | ||
| README.md | ||
crabroll
Dice expression evaluator written in Rust. Parses and evaluates standard dice notation with arithmetic, advantage, and disadvantage. Planned WASM build for embedding in websites.
Usage
Run with cargo run. The REPL accepts standard dice notation: 2d6, d20, ^d20 (advantage), vd20 (disadvantage), combined with arithmetic and grouping. Each result shows the rolled value plus theoretical min, max, and average.
> 2d6 + 3
11 (min: 5, max: 15, avg: 10.00)
> ^d20
18 (min: 1, max: 20, avg: 13.83)
> quit
Tests
cargo test