Beispiel #1
0
 unsigned aig_exporter::mk_input_var(const expr *e) {
     SASSERT(!m_aig_expr_id_map.contains(e));
     unsigned id = mk_expr_id();
     m_input_vars.push_back(id);
     if (e)
         m_aig_expr_id_map.insert(e, id);
     return id;
 }
Beispiel #2
0
    unsigned aig_exporter::mk_and(unsigned id1, unsigned id2) {
        if (id1 > id2)
            std::swap(id1, id2);

        std::pair<unsigned,unsigned> key(id1, id2);
        and_gates_map::const_iterator I = m_and_gates_map.find(key);
        if (I != m_and_gates_map.end())
            return I->second;

        unsigned id = mk_expr_id();
        m_buffer << id << ' ' << id1 << ' ' << id2 << '\n';
        m_and_gates_map[key] = id;
        ++m_num_and_gates;
        return id;
    }
Beispiel #3
0
expr_t parse_id_expr(tokenizer_t t){
  char* v = strdup(cur_tok(t).name);
  eat_it(t, TOK_ID);
  // printf("parse_id_expr: %s\n", v);

  if(cur_tok(t).kind == TOK_LPAREN)
  { // 関数呼び出し
    eat_it(t, TOK_LPAREN);    
    expr_list_t list = parse_arg_expr(t);
    eat_it(t, TOK_RPAREN);
    return mk_expr_call(t->filename, t->line, v, list);
  }
  else
  { // 変数名
    return mk_expr_id(t->filename, t->line, v);
  }
}
Beispiel #4
0
expr_t parse_unary_expr(tokenizer_t t) {
    char * filename = cur_tok(t).filename;
    int line = cur_tok(t).line_num;
    char * f =(char *)safe_malloc(sizeof(char) * 50) ;
    if(cur_tok(t).kind == TOK_INT_LITERAL) {
        strcpy(f, cur_tok(t).num);
        f = (char *)realloc(f, sizeof(char) * strlen(f) + 1);
        eat_it(t, TOK_INT_LITERAL);
        return mk_expr_int_literal(filename, line, f);
    }
    else if(cur_tok(t).kind == TOK_ID) {
        strcpy(f, parse_identifier(t));
        f = (char *)realloc(f, sizeof(char) * strlen(f) + 1);
        if(cur_tok(t).kind == TOK_LPAREN) {
            eat_it(t, TOK_LPAREN);
            expr_list_t args = parse_arg_expr_list(t);
            eat_it(t, TOK_RPAREN);
            return mk_expr_call(filename, line, f, args);
        }
        else {
            return mk_expr_id(filename, line, f);
        }
    }
    else if(cur_tok(t).kind == TOK_LPAREN) {
        eat_it(t, TOK_LPAREN);
        expr_t e = parse_expr(t);
        eat_it(t, TOK_RPAREN);
        return mk_expr_paren(filename, line, e);
    }
    else if((cur_tok(t).kind == TOK_PLUS)|(cur_tok(t).kind == TOK_MINUS)|(cur_tok(t).kind == TOK_BANG)) {
        op_kind_t op = parse_unary_oper(t);
        expr_t exp = parse_unary_expr(t);
        return mk_expr_un_op(filename, line, op, exp);
    }
    else {
        printf("exit_5\n");
        exit(1);
    }
}
Beispiel #5
0
 unsigned aig_exporter::mk_var(const expr *e) {
     SASSERT(!m_aig_expr_id_map.contains(e));
     unsigned id = mk_expr_id();
     m_aig_expr_id_map.insert(e, id);
     return id;
 }