1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2025-10-25 19:07:40 +00:00

parser:: error handling now uses exceptions

This commit is contained in:
Zeno Rogue
2019-12-23 21:44:51 +01:00
parent a83220c34e
commit 15000034fd
6 changed files with 63 additions and 29 deletions

View File

@@ -79,7 +79,15 @@ EX namespace arg {
EX const char* argcs() { return args().c_str(); }
EX int argi() { return atoi(argcs()); }
EX unsigned arghex() { return strtoll(argcs(), NULL, 16); }
EX ld argf() { return parseld(args()); }
EX ld argf() {
try {
return parseld(args());
}
catch(hr_parse_exception& ex) {
println(hlog, "error parsing commandline parameters: ", ex.s);
exit(1);
}
}
EX bool argis(const string& s) { if(args()[0] == '-' && args()[1] == '-') return args().substr(1) == s; return args() == s; }
EX void shift_arg_formula(ld& x, const reaction_t& r IS(reaction_t())) {