From d97c1a6497cc41c30edb6d5322a6deac56fd2293 Mon Sep 17 00:00:00 2001 From: Benji Dial Date: Tue, 30 May 2023 14:02:35 -0400 Subject: rewrite compiler, add for/rof support --- bench/bench_window.cpp | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'bench/bench_window.cpp') 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(w)) { - warriors.push_back(std::get(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(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; -- cgit v1.2.3