Exemplo n.º 1
0
void cvc_dect::read_assert(std::istream &in, std::string &line)
{
  // strip ASSERT
  line=std::string(line, strlen("ASSERT "), std::string::npos);
  if(line=="") return;
  
  // bit-vector
  if(line[0]=='(')
  {
    // get identifier
    std::string::size_type pos=
      line.find(' ');

    std::string identifier=std::string(line, 1, pos-1);
    
    // get value
    if(!std::getline(in, line)) return;

    // skip spaces    
    pos=0;
    while(pos<line.size() && line[pos]==' ') pos++;
    
    // get final ")"
    std::string::size_type pos2=line.rfind(')');
    if(pos2==std::string::npos) return;    
    
    std::string value=std::string(line, pos, pos2-pos);

    #if 0    
    std::cout << ">" << identifier << "< = >" << value << "<";
    std::cout << std::endl;
    #endif
  }
  else
  {
    // boolean
    bool value=true;
    
    if(has_prefix(line, "NOT "))
    {
      line=std::string(line, strlen("NOT "), std::string::npos);
      value=false;
    }
    
    if(line=="") return;
    
    if(line[0]=='l')
    {
      unsigned number=unsafe_c_str2unsigned(line.c_str()+1);
      assert(number<no_boolean_variables);
      assert(no_boolean_variables==boolean_assignment.size());
      boolean_assignment[number]=value;
    }
  }
}
Exemplo n.º 2
0
unsigned get_max(
  const std::string &prefix,
  const symbol_tablet::symbolst &symbols)
{
  unsigned max_nr=0;

  forall_symbols(it, symbols)
    if(has_prefix(id2string(it->first), prefix))
      max_nr=
        std::max(unsafe_c_str2unsigned(it->first.c_str()+prefix.size()),
                 max_nr);

  return max_nr;
}