diff options
author | Benji Dial <benji@benjidial.net> | 2023-05-30 14:02:35 -0400 |
---|---|---|
committer | Benji Dial <benji@benjidial.net> | 2023-05-30 14:02:35 -0400 |
commit | d97c1a6497cc41c30edb6d5322a6deac56fd2293 (patch) | |
tree | 07920c6b83e687b75b268db44937f5fa362febd0 /bench | |
parent | 6678dccccdfffb9c40f64a828fd769c53bb2d29f (diff) | |
download | lib94-d97c1a6497cc41c30edb6d5322a6deac56fd2293.tar.gz |
rewrite compiler, add for/rof support
Diffstat (limited to 'bench')
-rw-r--r-- | bench/bench_window.cpp | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/bench/bench_window.cpp b/bench/bench_window.cpp index d872de7..767198b 100644 --- a/bench/bench_window.cpp +++ b/bench/bench_window.cpp @@ -223,22 +223,19 @@ void bench_window::on_add_warrior_dialog_response(int response_id, Gtk::FileChoo gsize length; file->load_contents(contents, length); - auto w = lib94::compile_warrior(std::string(contents, length)); - - delete contents; - - if (std::holds_alternative<lib94::warrior *>(w)) { - warriors.push_back(std::get<lib94::warrior *>(w)); + try { + warriors.push_back(lib94::compile_warrior(std::string(contents, length))); on_click_new_round(); } - - else { - Gtk::MessageDialog *md = new Gtk::MessageDialog(std::string("Failed to compile: ") + std::get<std::string>(w)); + catch (const lib94::compiler_exception &ex) { + Gtk::MessageDialog *md = new Gtk::MessageDialog(std::string("failed to compile: ") + ex.message + " on line " + std::to_string(ex.line_number)); md->set_transient_for(*this); md->set_modal(); md->signal_response().connect([md](int) {delete md;}); md->show(); } + + delete contents; } delete dialog; |