本文整理汇总了C++中parser::ios方法的典型用法代码示例。如果您正苦于以下问题:C++ parser::ios方法的具体用法?C++ parser::ios怎么用?C++ parser::ios使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类parser
的用法示例。
在下文中一共展示了parser::ios方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: namespace_cmd
environment namespace_cmd(parser & p) {
auto pos = p.pos();
name n = p.check_atomic_id_next("invalid namespace declaration, atomic identifier expected");
if (is_root_namespace(n))
throw parser_error(sstream() << "invalid namespace name, '" << n << "' is reserved", pos);
return push_scope(p.env(), p.ios(), n);
}
示例2: coercion_cmd
environment coercion_cmd(parser & p) {
auto pos = p.pos();
expr f = p.parse_expr();
if (!is_constant(f))
throw parser_error("invalid 'coercion' command, constant expected", pos);
if (p.curr_is_token(g_colon)) {
p.next();
pos = p.pos();
expr C = p.parse_expr();
if (!is_constant(C))
throw parser_error("invalid 'coercion' command, constant expected", pos);
return add_coercion(p.env(), const_name(f), const_name(C), p.ios());
} else {
return add_coercion(p.env(), const_name(f), p.ios());
}
}
示例3: using_cmd
// using [class] id (id ...) (renaming id->id id->id) (hiding id ... id)
environment using_cmd(parser & p) {
environment env = p.env();
while (true) {
name cls = parse_class(p);
bool decls = cls.is_anonymous() || cls == g_decls || cls == g_declarations;
auto pos = p.pos();
name ns = p.check_id_next("invalid 'using' command, identifier expected");
optional<name> real_ns = to_valid_namespace_name(env, ns);
if (!real_ns)
throw parser_error(sstream() << "invalid namespace name '" << ns << "'", pos);
ns = *real_ns;
env = using_namespace(env, p.ios(), ns, cls);
if (decls) {
// Remark: we currently to not allow renaming and hiding of universe levels
buffer<name> exceptions;
bool found_explicit = false;
while (p.curr_is_token(g_lparen)) {
p.next();
if (p.curr_is_token_or_id(g_renaming)) {
p.next();
while (p.curr_is_identifier()) {
name from_id = p.get_name_val();
p.next();
p.check_token_next(g_arrow, "invalid 'using' command renaming, '->' expected");
name to_id = p.check_id_next("invalid 'using' command renaming, identifier expected");
check_identifier(p, env, ns, from_id);
exceptions.push_back(from_id);
env = add_expr_alias(env, to_id, ns+from_id);
}
} else if (p.curr_is_token_or_id(g_hiding)) {
p.next();
while (p.curr_is_identifier()) {
name id = p.get_name_val();
p.next();
check_identifier(p, env, ns, id);
exceptions.push_back(id);
}
} else if (p.curr_is_identifier()) {
found_explicit = true;
while (p.curr_is_identifier()) {
name id = p.get_name_val();
p.next();
check_identifier(p, env, ns, id);
env = add_expr_alias(env, id, ns+id);
}
} else {
throw parser_error("invalid 'using' command option, identifier, 'hiding' or 'renaming' expected", p.pos());
}
if (found_explicit && !exceptions.empty())
throw parser_error("invalid 'using' command option, mixing explicit and implicit 'using' options", p.pos());
p.check_token_next(g_rparen, "invalid 'using' command option, ')' expected");
}
if (!found_explicit)
env = add_aliases(env, ns, name(), exceptions.size(), exceptions.data());
}
if (!p.curr_is_token(g_lbracket) && !p.curr_is_identifier())
break;
}
return env;
}
示例4: check_cmd
environment check_cmd(parser & p) {
expr e = p.parse_expr();
list<expr> ctx = locals_to_context(e, p);
level_param_names ls = to_level_param_names(collect_univ_params(e));
level_param_names new_ls;
std::tie(e, new_ls) = p.elaborate_relaxed(e, ctx);
auto tc = mk_type_checker_with_hints(p.env(), p.mk_ngen(), true);
expr type = tc->check(e, append(ls, new_ls));
auto reg = p.regular_stream();
formatter const & fmt = reg.get_formatter();
options opts = p.ios().get_options();
unsigned indent = get_pp_indent(opts);
format r = group(format{fmt(e), space(), colon(), nest(indent, compose(line(), fmt(type)))});
reg << mk_pair(r, opts) << endl;
return p.env();
}
示例5: 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();
}
示例6: section_cmd
environment section_cmd(parser & p) {
p.push_local_scope();
return push_scope(p.env(), p.ios());
}