Crates.io | droll-cli |
lib.rs | droll-cli |
version | 0.1.0 |
source | src |
created_at | 2023-09-05 20:20:13.783551 |
updated_at | 2023-09-05 20:20:13.783551 |
description | Dice notation parser and interpeter library |
homepage | |
repository | https://github.com/erikjuhani/droll |
max_upload_size | |
id | 964765 |
size | 11,195 |
droll-cli
parses the dice notation by utilizing a operator-precedence
parser according to
the following grammar rules (The grammar is
EBNF
format).
<expr> ::= <roll-expr>
| <expr> '+' <expr>
| <expr> '-' <expr>
<roll-expr> ::= <primary>
| <expr> 'd' <expr>
<primary> ::= <number>
| '+' <primary>
| '-' <primary>
| 'd' <expr>
<number> ::= <non-zero-digit> { <digit> }
<non-zero-digit> ::= '1' .. '9'
<digit> ::= '0' .. '9'
To install droll-cli
, you can use the Rust package manager, Cargo
, with the following command:
cargo install droll
After installing droll-cli
, you can use it by calling it from the shell with the desired dice notation:
droll <dice_notation>
Replace <dice_notation> with actual dice notation like 1d20+10
.
The simplest dice notation is called standard dice
notation and it supports simple
dice rolls like d6
, 2d20
and also additive operations like 2d20+10-2
.
To calculate the roll result, simply call the droll
with the desired dice
notation:
droll 1d20+10
27