create static method
parse the given input into a DiceExpression throws FormatException if invalid
Implementation
static DiceExpression create(String input, [Random? random]) {
final builder = random == null
? _defaultParserBuilder
: parserBuilder(DiceRoller(random));
final result = builder.parse(input);
if (result.isFailure) {
throw FormatException(
"Error parsing dice expression",
input,
result.position,
);
}
return result.value;
}