cprover
converter.cpp
Go to the documentation of this file.
1 /*******************************************************************\
2 
3 Module:
4 
5 Author: Daniel Kroening, kroening@kroening.com
6 
7 \*******************************************************************/
8 
9 
10 #include <iostream>
11 #include <string>
12 
13 bool has_prefix(const std::string &s, const std::string &prefix)
14 {
15  return std::string(s, 0, prefix.size())==prefix;
16 }
17 
18 int main()
19 {
20  std::string line;
21  bool first=true;
22 
23  std::cout << "{\n";
24 
25  while(getline(std::cin, line))
26  {
27  if(has_prefix(line, "/* FUNCTION: "))
28  {
29  if(first)
30  first=false;
31  else
32  std::cout << "},\n";
33 
34  std::string function=std::string(line, 13, std::string::npos);
35  std::size_t pos=function.find(' ');
36  if(pos!=std::string::npos)
37  function=std::string(function, 0, pos);
38 
39  std::cout << "{ \"" << function << "\",\n";
40  std::cout << " \"#line 1 \\\"<builtin-library-"
41  << function << ">\\\"\\n\"\n";
42  }
43  else if(!first)
44  {
45  std::cout << " \"";
46 
47  for(unsigned i=0; i<line.size(); i++)
48  {
49  const char ch=line[i];
50  if(ch=='\\')
51  std::cout << "\\\\";
52  else if(ch=='"')
53  std::cout << "\\\"";
54  else if(ch=='\r' || ch=='\n')
55  {
56  }
57  else
58  std::cout << ch;
59  }
60 
61  std::cout << "\\n\"\n";
62  }
63  }
64 
65  if(!first)
66  std::cout << "},\n";
67 
68  std::cout <<
69  "{ 0, 0 }\n"
70  "}";
71 }
literalt pos(literalt a)
Definition: literal.h:193
bool has_prefix(const std::string &s, const std::string &prefix)
Definition: converter.cpp:13
int main()
Definition: converter.cpp:18