| 123456789101112131415161718192021222324252627282930313233343536 |
- //
- // main.cpp
- // dice-roll
- //
- // Created by Sam Jaffe on 12/1/18.
- // Copyright © 2018 Sam Jaffe. All rights reserved.
- //
- #include "die.h"
- #include "exception.h"
- #include "roll.h"
- #include <iostream>
- #include <sstream>
- void eval(std::string const & str) {
- try {
- std::stringstream ss(str);
- dice::dice d;
- ss >> d;
- dice::roll(d);
- } catch (dice::unexpected_token const & ut) {
- std::cerr << "Error in roll: '" << str << "': " << ut.what() << "\n";
- std::cerr << " " << ut.pointer(str.size()+1) << std::endl;
- }
- }
- int main(int argc, const char * argv[]) {
- std::string line;
- std::cout << "> ";
- while (std::getline(std::cin, line)) {
- eval(line);
- std::cout << "> ";
- }
- return 0;
- }
|