示例#1
0
文件: choice.cpp 项目: avigad/lean
void initialize_choice() {
    g_choice_name   = new name("choice");
    g_choice_opcode = new std::string("Choice");
    g_choice        = new macro_definition(new choice_macro_cell());
    register_macro_deserializer(*g_choice_opcode,
                                [](deserializer &, unsigned num, expr const * args) {
                                    return mk_choice(num, args);
                                });
}
示例#2
0
void initialize_typed_expr() {
    g_typed_expr_name = new name("typed_expr");
    g_typed_expr_opcode = new std::string("TyE");
    g_typed_expr = new macro_definition(new typed_expr_macro_definition_cell());
    register_macro_deserializer(*g_typed_expr_opcode,
                                [](deserializer &, unsigned num, expr const * args) {
                                    if (num != 2)
                                        throw corrupted_stream_exception();
                                    return mk_typed_expr(args[0], args[1]);
                                });
}
void initialize_structure_instance() {
    g_structure_instance_name   = new name("structure instance");
    g_structure_instance_opcode = new std::string("STI");
    register_macro_deserializer(*g_structure_instance_opcode,
                                [](deserializer & d, unsigned num, expr const * args) {
                                    list<name> fs;
                                    fs = read_list<name>(d);
                                    if (num < length(fs) + 1)
                                        throw corrupted_stream_exception();
                                    return mk_structure_instance(fs, num, args);
                                });
}
示例#4
0
void initialize_let() {
    g_let_value = new name("letv");
    g_let_value_opcode = new std::string("LetV");
    g_next_let_value_id = new atomic<unsigned>(0);
    register_macro_deserializer(*g_let_value_opcode,
                                [](deserializer &, unsigned num, expr const * args) {
                                    if (num != 1) throw corrupted_stream_exception();
                                    return mk_let_value(args[0]);
                                });
    g_let = new name("let");
    g_let_opcode = new std::string("Let");
    register_macro_deserializer(*g_let_opcode,
                                [](deserializer & d, unsigned num, expr const * args) {
                                    if (num != 2) throw corrupted_stream_exception();
                                    name n;
                                    d >> n;
                                    return mk_let_macro(n, args[0], args[1]);
                                });
示例#5
0
void initialize_resolve_macro() {
    g_resolve_macro_name = new name("resolve");
    g_resolve_opcode = new std::string("Res");
    g_or = new expr(Const(get_or_name()));
    g_not = new expr(Const(get_not_name()));
    g_false = new expr(Const(get_false_name()));
    g_or_elim = new expr(Const(get_or_elim_name()));
    g_or_intro_left = new expr(Const(get_or_intro_left_name()));
    g_or_intro_right = new expr(Const(get_or_intro_right_name()));
    g_absurd_elim = new expr(Const(get_absurd_name()));
    g_var_0 = new expr(mk_var(0));
    g_resolve_macro_definition = new macro_definition(new resolve_macro_definition_cell());
    register_macro_deserializer(*g_resolve_opcode,
                                [](deserializer &, unsigned num, expr const * args) {
                                    if (num != 3)
                                        throw corrupted_stream_exception();
                                    return mk_resolve_macro(args[0], args[1], args[2]);
                                });
}
示例#6
0
文件: string.cpp 项目: sakas--/lean
void initialize_string() {
    g_string_macro    = new name("string_macro");
    g_string_opcode   = new std::string("Str");
    g_nat             = new expr(Const(get_nat_name()));
    g_char            = new expr(Const(get_char_name()));
    g_char_of_nat     = new expr(Const(get_char_of_nat_name()));
    g_string          = new expr(Const(get_string_name()));
    g_empty           = new expr(Const(get_string_empty_name()));
    g_str             = new expr(Const(get_string_str_name()));
    g_fin_mk          = new expr(Const(get_fin_mk_name()));
    g_list_char       = new expr(mk_app(mk_constant(get_list_name(), {mk_level_one()}), *g_char));
    g_list_cons       = new expr(mk_constant(get_list_cons_name(), {mk_level_one()}));
    g_list_nil_char   = new expr(mk_app(mk_constant(get_list_nil_name(), {mk_level_one()}), *g_char));
    register_macro_deserializer(*g_string_opcode,
    [](deserializer & d, unsigned num, expr const *) {
        if (num != 0)
            throw corrupted_stream_exception();
        std::string v = d.read_string();
        return mk_string_macro(v);
    });
}