本文整理汇总了C++中parser::set_option方法的典型用法代码示例。如果您正苦于以下问题:C++ parser::set_option方法的具体用法?C++ parser::set_option怎么用?C++ parser::set_option使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类parser
的用法示例。
在下文中一共展示了parser::set_option方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: find_cmd
environment find_cmd(parser & p) {
expr e; level_param_names ls;
{
bool save_options = true;
parser::local_scope scope(p, save_options);
p.set_option(get_elaborator_ignore_instances_name(), true);
std::tie(e, ls) = parse_local_expr(p);
}
buffer<std::string> pos_names, neg_names;
parse_filters(p, pos_names, neg_names);
environment env = p.env();
auto tc = mk_opaque_type_checker(env, p.mk_ngen());
flycheck_information info(p.regular_stream());
if (info.enabled()) {
p.display_information_pos(p.cmd_pos());
}
p.regular_stream() << "find_decl result:\n";
unsigned max_steps = get_find_max_steps(p.get_options());
bool cheap = !get_find_expensive(p.get_options());
bool found = false;
env.for_each_declaration([&](declaration const & d) {
if (std::all_of(pos_names.begin(), pos_names.end(),
[&](std::string const & pos) { return is_part_of(pos, d.get_name()); }) &&
std::all_of(neg_names.begin(), neg_names.end(),
[&](std::string const & neg) { return !is_part_of(neg, d.get_name()); }) &&
match_pattern(*tc.get(), e, d, max_steps, cheap)) {
found = true;
p.regular_stream() << " " << get_decl_short_name(d.get_name(), env) << " : " << d.get_type() << endl;
}
});
if (!found)
p.regular_stream() << "no matches\n";
return env;
}
示例2: set_option_cmd
environment set_option_cmd(parser & p) {
auto id_pos = p.pos();
name id = p.check_id_next("invalid set option, identifier (i.e., option name) expected");
auto decl_it = get_option_declarations().find(id);
if (decl_it == get_option_declarations().end()) {
// add "lean" prefix
name lean_id = name("lean") + id;
decl_it = get_option_declarations().find(lean_id);
if (decl_it == get_option_declarations().end()) {
throw parser_error(sstream() << "unknown option '" << id << "', type 'help options.' for list of available options", id_pos);
} else {
id = lean_id;
}
}
option_kind k = decl_it->second.kind();
if (k == BoolOption) {
if (p.curr_is_token_or_id(g_true))
p.set_option(id, true);
else if (p.curr_is_token_or_id(g_false))
p.set_option(id, false);
else
throw parser_error("invalid Boolean option value, 'true' or 'false' expected", p.pos());
p.next();
} else if (k == StringOption) {
if (!p.curr_is_string())
throw parser_error("invalid option value, given option is not a string", p.pos());
p.set_option(id, p.get_str_val());
p.next();
} else if (k == DoubleOption) {
p.set_option(id, p.parse_double());
} else if (k == UnsignedOption || k == IntOption) {
p.set_option(id, p.parse_small_nat());
} else {
throw parser_error("invalid option value, 'true', 'false', string, integer or decimal value expected", p.pos());
}
p.updt_options();
return p.env();
}