本文整理汇总了C++中parser::next方法的典型用法代码示例。如果您正苦于以下问题:C++ parser::next方法的具体用法?C++ parser::next怎么用?C++ parser::next使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类parser
的用法示例。
在下文中一共展示了parser::next方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: opaque_hint_cmd
environment opaque_hint_cmd(parser & p) {
environment env = p.env();
bool found = false;
while (p.curr_is_token(g_lparen)) {
p.next();
bool hiding;
auto pos = p.pos();
if (p.curr_is_token_or_id(g_hiding))
hiding = true;
else if (p.curr_is_token_or_id(g_exposing))
hiding = false;
else
throw parser_error("invalid 'opaque_hint', 'hiding' or 'exposing' expected", pos);
p.next();
while (!p.curr_is_token(g_rparen)) {
if (p.curr_is_token(g_module)) {
found = true;
p.next();
env = set_hide_main_opaque(env, hiding);
} else {
name c = p.check_constant_next("invalid 'opaque_hint', constant expected");
found = true;
if (hiding)
env = hide_definition(env, c);
else
env = expose_definition(env, c);
}
}
p.next();
}
if (!found)
throw exception("invalid empty 'opaque_hint' command");
return env;
}
示例2: parse_notation
static notation_entry parse_notation(parser & p, bool overload, notation_entry_group grp, buffer<token_entry> & new_tokens,
bool allow_local) {
bool parse_only = false;
unsigned priority = LEAN_DEFAULT_NOTATION_PRIORITY;
flet<bool> set_allow_local(g_allow_local, allow_local);
if (p.curr_is_token(get_infix_tk()) || p.curr_is_token(get_infixl_tk())) {
p.next();
return parse_mixfix_notation(p, mixfix_kind::infixl, overload, grp, new_tokens, parse_only, priority);
} else if (p.curr_is_token(get_infixr_tk())) {
p.next();
return parse_mixfix_notation(p, mixfix_kind::infixr, overload, grp, new_tokens, parse_only, priority);
} else if (p.curr_is_token(get_postfix_tk())) {
p.next();
return parse_mixfix_notation(p, mixfix_kind::postfix, overload, grp, new_tokens, parse_only, priority);
} else if (p.curr_is_token(get_prefix_tk())) {
p.next();
return parse_mixfix_notation(p, mixfix_kind::prefix, overload, grp, new_tokens, parse_only, priority);
} else if (p.curr_is_token(get_notation_tk())) {
p.next();
return parse_notation_core(p, overload, grp, new_tokens, parse_only, priority);
} else {
throw parser_error("invalid notation, 'infix', 'infixl', 'infixr', 'prefix', "
"'postfix' or 'notation' expected", p.pos());
}
}
示例3: parse_transition
static transition parse_transition(parser & p, optional<parse_table> const & pt, name const & tk,
buffer<expr> & locals, buffer<token_entry> & new_tokens, notation_entry_group grp,
name const & pp_tk) {
if (p.curr_is_token_or_id(get_binder_tk())) {
p.next();
unsigned rbp = parse_binders_rbp(p);
return transition(tk, mk_binder_action(rbp), pp_tk);
} else if (p.curr_is_token_or_id(get_binders_tk())) {
p.next();
unsigned rbp = parse_binders_rbp(p);
return transition(tk, mk_binders_action(rbp), pp_tk);
} else if (p.curr_is_identifier()) {
unsigned default_prec = get_default_prec(pt, tk);
name n = p.get_name_val();
p.next();
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);
return transition(tk, a, pp_tk);
} else if (p.curr_is_quoted_symbol() || p.curr_is_keyword() ||
p.curr_is_token(get_assign_tk()) || p.curr_is_command() || p.curr_is_eof()) {
return transition(tk, mk_skip_action(), pp_tk);
} else {
throw parser_error("invalid notation declaration, quoted-symbol, identifier, "
"'binder', 'binders' expected", p.pos());
}
}
示例4: parse_quoted_symbol_or_token
static name parse_quoted_symbol_or_token(parser & p, buffer<token_entry> & new_tokens, bool & used_default, notation_entry_group grp) {
used_default = false;
if (p.curr_is_quoted_symbol()) {
environment const & env = p.env();
auto pp_tk = p.get_name_val();
auto tks = utf8_trim(pp_tk.to_string());
auto tkcs = tks.c_str();
check_not_forbidden(tkcs);
p.next();
if (p.curr_is_token(get_colon_tk())) {
p.next();
unsigned prec = parse_precedence(p);
new_tokens.push_back(mk_token_entry(tkcs, prec, grp));
} else if (!get_precedence(env, tkcs, grp)) {
new_tokens.push_back(mk_token_entry(tkcs, LEAN_DEFAULT_PRECEDENCE, grp));
used_default = true;
}
return pp_tk;
} else if (p.curr_is_keyword()) {
auto tk = p.get_token_info().token();
check_not_forbidden(tk.to_string().c_str());
p.next();
return tk;
} else {
throw parser_error("invalid notation declaration, symbol expected", p.pos());
}
}
示例5: parse_implicit_infer_modifier
implicit_infer_kind parse_implicit_infer_modifier(parser & p) {
if (p.curr_is_token(get_lcurly_tk())) {
p.next();
p.check_token_next(get_rcurly_tk(), "invalid introduction rule, '}' expected");
return implicit_infer_kind::RelaxedImplicit;
} else if (p.curr_is_token(get_lparen_tk())) {
p.next();
p.check_token_next(get_rparen_tk(), "invalid introduction rule, ')' expected");
return implicit_infer_kind::None;
} else {
return implicit_infer_kind::Implicit;
}
}
示例6: parse_filters
static void parse_filters(parser & p, buffer<std::string> & pos_names, buffer<std::string> & neg_names) {
name plus("+"); name minus("-");
while (p.curr_is_token(get_comma_tk())) {
p.next();
if (p.curr_is_token(plus)) {
p.next();
pos_names.push_back(p.check_id_next("invalid find_decl command, identifier expected").to_string());
} else if (p.curr_is_token(minus)) {
p.next();
neg_names.push_back(p.check_id_next("invalid find_decl command, identifier expected").to_string());
} else {
pos_names.push_back(p.check_id_next("invalid find_decl command, '+', '-', or identifier expected").to_string());
}
}
}
示例7: parse_struct_expr_core
static expr parse_struct_expr_core(parser & p, pos_info const & pos, bool curly_bar) {
expr t = p.parse_expr();
buffer<name> field_names;
buffer<expr> field_values;
buffer<expr> using_exprs;
while (p.curr_is_token(get_comma_tk())) {
p.next();
pair<optional<name>, expr> id_e = p.parse_optional_assignment();
if (id_e.first) {
field_names.push_back(*id_e.first);
field_values.push_back(id_e.second);
} else {
using_exprs.push_back(id_e.second);
}
}
if (curly_bar)
p.check_token_next(get_rcurlybar_tk(), "invalid structure expression, '|}' expected");
else
p.check_token_next(get_rdcurly_tk(), "invalid structure expression, '⦄' expected");
buffer<expr> args;
args.push_back(t);
args.append(field_values);
args.append(using_exprs);
return p.save_pos(mk_structure_instance(to_list(field_names), args.size(), args.data()), pos);
}
示例8: print_cmd
environment print_cmd(parser & p) {
if (p.curr() == scanner::token_kind::String) {
p.regular_stream() << p.get_str_val() << endl;
p.next();
} else if (p.curr_is_token_or_id(g_raw)) {
p.next();
expr e = p.parse_expr();
p.regular_stream() << e << endl;
} else if (p.curr_is_token_or_id(g_options)) {
p.next();
p.regular_stream() << p.ios().get_options() << endl;
} else {
throw parser_error("invalid print command", p.pos());
}
return p.env();
}
示例9: parse_class
static name parse_class(parser & p) {
if (p.curr_is_token(g_lbracket)) {
p.next();
name n;
if (p.curr_is_identifier())
n = p.get_name_val();
else if (p.curr_is_keyword() || p.curr_is_command())
n = p.get_token_info().value();
else
throw parser_error("invalid 'using' command, identifier or symbol expected", p.pos());
p.next();
p.check_token_next(g_rbracket, "invalid 'using' command, ']' expected");
return n;
} else {
return name();
}
}
示例10: some
static optional<unsigned> parse_optional_precedence(parser & p) {
if (p.curr_is_token(get_colon_tk())) {
p.next();
return some(parse_precedence_core(p));
} else {
return optional<unsigned>();
}
}
示例11: set_line_cmd
environment set_line_cmd(parser & p) {
if (!p.curr_is_numeral())
throw parser_error("invalid #setline command, numeral expected", p.pos());
unsigned r = p.get_small_nat();
p.set_line(r);
p.next();
return p.env();
}
示例12: parse_binders_rbp
static unsigned parse_binders_rbp(parser & p) {
if (p.curr_is_token(get_colon_tk())) {
p.next();
return parse_precedence(p);
} else {
return 0;
}
}
示例13: parse
void type_modifiers::parse(parser & p) {
while (true) {
if (p.curr_is_token(get_class_tk())) {
m_is_class = true;
p.next();
} else {
break;
}
}
}
示例14: parse_notation_local
static void parse_notation_local(parser & p, buffer<expr> & locals) {
if (p.curr_is_identifier()) {
name n = p.get_name_val();
p.next();
expr local_type = mk_Prop(); // type used in notation local declarations, it is irrelevant
expr l = mk_local(n, local_type); // remark: the type doesn't matter
p.add_local(l);
locals.push_back(l);
} else {
throw parser_error("invalid notation declaration, identifier expected", p.pos());
}
}
示例15: parse
void parse(parser & p) {
while (true) {
if (p.curr_is_token(get_parsing_only_tk())) {
p.next();
m_parse_only = true;
} else if (auto prio = parse_priority(p)) {
m_priority = *prio;
} else {
return;
}
}
}