1 unstable release
0.1.0 | Sep 5, 2023 |
---|
#7 in #ebnf
20KB
356 lines
droll-cli
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'
Installation
To install droll-cli
, you can use the Rust package manager, Cargo
, with the following command:
cargo install droll
Usage
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
.
Standard dice notation
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
Dependencies
~1.5MB
~20K SLoC