bool settings_parser_c::parse(int argc, char *argv[]) { arg_c = argc; arg_v = argv; position = 1; for (int i = 0; i < parsers.size(); ++i) { parsers[i]->invoke_initialization(*this); } while (current_position() < argc && !stopped) { for (auto parser = parsers.begin(); parser != parsers.end(); parser++) { fetch_current_position(); if ((*parser)->parse(*this)) { save_current_position((*parser)); } restore_position(); } if (saved_count() == 1) { try { pop_saved_parser()->invoke(*this); } catch (std::string error) { std::cerr << "Invalid parameter value: " << arg_v[position - 1] << " with error: " << error << std::endl; return false; } } else if (saved_count() > 1) { //ambiguous arguments //throw std::cerr << "ambiguous arguments" << std::endl; } else { if (is_program()) { parse_program(); //parse_program//until separator detected } else { //unknown_argument std::cerr << "unknown argument " << arg_v[position] << std::endl; //throw ""; return false; } } } return true; }
static VALUE call_at_line(VALUE context_obj, debug_context_t *dc, VALUE file, VALUE line) { save_current_position(dc, file, line); return call_at(context_obj, dc, rb_intern("at_line"), 2, file, line); }