|
|
@@ -29,29 +29,12 @@ void print(std::vector<dice::dice_roll> const & rs) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-/**
|
|
|
- *
|
|
|
- * @param str A string representation of a dice roll, represented as one of the
|
|
|
- * following expression classes:
|
|
|
- * Die = [1-9]?\d*d[1-9]\d*
|
|
|
- * SingleRoll: ($Die|\d+)((+|-)($Die|\d+))*
|
|
|
- * RepeatRoll: [1-9]\d*\{$SingleRoll\}
|
|
|
- * @return a dice object representing the roll
|
|
|
- * @throws dice::unexpected_token if a parse failure occurs
|
|
|
- */
|
|
|
-dice::dice make_dice(std::string const & str) {
|
|
|
- std::stringstream ss(str);
|
|
|
- dice::dice d;
|
|
|
- ss >> d;
|
|
|
- return d;
|
|
|
-}
|
|
|
-
|
|
|
/**
|
|
|
* @param str {@see make_dice(std::string const &)}
|
|
|
*/
|
|
|
void eval(std::string const & str) {
|
|
|
try {
|
|
|
- auto d = make_dice(str);
|
|
|
+ auto d = dice::from_string(str);
|
|
|
auto rs = dice::roll(d);
|
|
|
std::cout << "Result of '" << d << "': ";
|
|
|
print(rs);
|