本文整理汇总了C++中buffer::back方法的典型用法代码示例。如果您正苦于以下问题:C++ buffer::back方法的具体用法?C++ buffer::back怎么用?C++ buffer::back使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类buffer
的用法示例。
在下文中一共展示了buffer::back方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: get_rec_args
void get_rec_args(environment const & env, name const & n, buffer<buffer<bool>> & r) {
lean_assert(inductive::is_inductive_decl(env, n));
type_checker tc(env);
name_generator ngen;
declaration ind_decl = env.get(n);
declaration rec_decl = env.get(inductive::get_elim_name(n));
unsigned nparams = *inductive::get_num_params(env, n);
unsigned nminors = *inductive::get_num_minor_premises(env, n);
unsigned ntypeformers = *inductive::get_num_type_formers(env, n);
buffer<expr> rec_args;
to_telescope(ngen, rec_decl.get_type(), rec_args);
buffer<name> typeformer_names;
for (unsigned i = nparams; i < nparams + ntypeformers; i++) {
typeformer_names.push_back(mlocal_name(rec_args[i]));
}
lean_assert(typeformer_names.size() == ntypeformers);
r.clear();
// add minor premises
for (unsigned i = nparams + ntypeformers; i < nparams + ntypeformers + nminors; i++) {
r.push_back(buffer<bool>());
buffer<bool> & bv = r.back();
expr minor_type = mlocal_type(rec_args[i]);
buffer<expr> minor_args;
to_telescope(ngen, minor_type, minor_args);
for (expr & minor_arg : minor_args) {
buffer<expr> minor_arg_args;
expr minor_arg_type = to_telescope(tc, mlocal_type(minor_arg), minor_arg_args);
bv.push_back(is_typeformer_app(typeformer_names, minor_arg_type));
}
}
}
示例2: comma_list
std::string comma_list(const buffer& buf)
{
std::string str;
if (buf.size() == 0)
str = "";
else if (buf.size() == 1)
str = buf.front();
else if (buf.size() == 2)
str = buf.front() + " and " + buf.back();
else
{
buffer::const_iterator it = buf.begin();
str = "and " + *(it++);
for (;it != buf.end(); it++)
str = *it + ", " + str;
}
return str;
}
示例3: parse_notation_core
static notation_entry parse_notation_core(parser & p, bool overload, notation_entry_group grp, buffer<token_entry> & new_tokens, bool parse_only,
unsigned priority) {
buffer<expr> locals;
buffer<transition> ts;
parser::local_scope scope(p);
bool is_nud = true;
optional<parse_table> pt;
optional<parse_table> reserved_pt;
if (p.curr_is_numeral()) {
lean_assert(p.curr_is_numeral());
mpz num = p.get_num_val().get_numerator();
p.next();
p.check_token_next(get_assign_tk(), "invalid numeral notation, `:=` expected");
auto e_pos = p.pos();
expr e = p.parse_expr();
check_notation_expr(e, e_pos);
return notation_entry(num, e, overload, parse_only);
} else if (p.curr_is_identifier()) {
parse_notation_local(p, locals);
is_nud = false;
pt = get_led_table(p.env());
if (grp != notation_entry_group::Reserve)
reserved_pt = get_reserved_led_table(p.env());
} else {
pt = get_nud_table(p.env());
if (grp != notation_entry_group::Reserve)
reserved_pt = get_reserved_nud_table(p.env());
}
bool used_default = false;
while ((grp != notation_entry_group::Reserve && !p.curr_is_token(get_assign_tk())) ||
(grp == notation_entry_group::Reserve && !p.curr_is_command() && !p.curr_is_eof())) {
name pp_tk = parse_quoted_symbol_or_token(p, new_tokens, used_default, grp).to_string();
name tk = utf8_trim(pp_tk.to_string());
if (auto at = find_next(reserved_pt, tk)) {
// Remark: we are ignoring multiple actions in the reserved notation table
transition const & trans = head(at).first;
action const & a = trans.get_action();
reserved_pt = head(at).second;
if (!p.curr_is_quoted_symbol())
pp_tk = trans.get_pp_token();
switch (a.kind()) {
case notation::action_kind::Skip:
if (!p.curr_is_quoted_symbol() && !p.curr_is_keyword() && !p.curr_is_token(get_assign_tk())) {
if (g_allow_local && !p.curr_is_token_or_id(get_binders_tk())) {
ts.push_back(parse_transition(p, pt, tk, locals, new_tokens, grp, pp_tk));
break;
}
p.check_token_or_id_next(get_binders_tk(),
"invalid notation declaration, quoted-symbol, keyword or `:=` expected "
"(declaration prefix matches reserved notation)");
}
ts.push_back(transition(tk, a, pp_tk));
break;
case notation::action_kind::Binder:
if (g_allow_local && !p.curr_is_token_or_id(get_binder_tk())) {
ts.push_back(parse_transition(p, pt, tk, locals, new_tokens, grp, pp_tk));
break;
}
p.check_token_or_id_next(get_binder_tk(),
"invalid notation declaration, 'binder' expected "
"(declaration prefix matches reserved notation)");
ts.push_back(transition(tk, a, pp_tk));
break;
case notation::action_kind::Binders:
if (g_allow_local && !p.curr_is_token_or_id(get_binders_tk())) {
ts.push_back(parse_transition(p, pt, tk, locals, new_tokens, grp, pp_tk));
break;
}
p.check_token_or_id_next(get_binders_tk(),
"invalid notation declaration, 'binders' expected "
"(declaration prefix matches reserved notation)");
ts.push_back(transition(tk, a, pp_tk));
break;
case notation::action_kind::Expr: case notation::action_kind::Exprs: case notation::action_kind::ScopedExpr:
case notation::action_kind::Ext: {
if (g_allow_local && !p.curr_is_identifier()) {
ts.push_back(parse_transition(p, pt, tk, locals, new_tokens, grp, pp_tk));
break;
}
name n = p.check_id_next("invalid notation declaration, identifier expected "
"(declaration prefix matches reserved notation)");
if (p.curr_is_token(get_colon_tk())) {
if (g_allow_local) {
unsigned default_prec = get_default_prec(pt, tk);
action a = parse_action(p, tk, default_prec, locals, new_tokens, grp);
expr local_type = mk_Prop(); // type used in notation local declarations, it is irrelevant
expr l = mk_local(n, local_type);
p.add_local(l);
locals.push_back(l);
ts.push_back(transition(tk, a, pp_tk));
break;
} else {
throw parser_error("invalid notation declaration, invalid ':' occurrence "
"(declaration prefix matches reserved notation)", p.pos());
}
} else {
expr local_type = mk_Prop(); // type used in notation local declarations, it is irrelevant
expr l = mk_local(n, local_type);
p.add_local(l);
locals.push_back(l);
//.........这里部分代码省略.........