cprover
lispexpr.h
Go to the documentation of this file.
1 /*******************************************************************\
2 
3 Module:
4 
5 Author: Daniel Kroening, kroening@kroening.com
6 
7 \*******************************************************************/
8 
9 
10 // THIS HEADER IS DEPRECATED AND WILL GO AWAY
11 
12 #ifndef CPROVER_UTIL_LISPEXPR_H
13 #define CPROVER_UTIL_LISPEXPR_H
14 
15 #if defined(_WIN32) && !defined(__MINGW32__)
16 #include <cstring>
17 #define strcasecmp _strcmpi
18 #else
19 #include <strings.h>
20 #endif
21 
22 #include <string>
23 #include <vector>
24 #include <iosfwd>
25 
26 class lispsymbolt:public std::string
27 {
28  public:
29  // NOLINTNEXTLINE(runtime/explicit)
30  lispsymbolt(const char *a):std::string(a)
31  {
32  }
33 
34  lispsymbolt():std::string()
35  {
36  }
37 
38  // NOLINTNEXTLINE(runtime/explicit)
39  lispsymbolt(const std::string &a):std::string(a)
40  {
41  }
42 
43  bool operator== (const lispsymbolt &b) const
44  { return strcasecmp(c_str(), b.c_str())==0; }
45 
46  bool operator!= (const lispsymbolt &b) const
47  { return strcasecmp(c_str(), b.c_str())!=0; }
48 
49  bool operator== (const char *b) const
50  { return strcasecmp(c_str(), b)==0; }
51 
52  bool operator!= (const char *b) const
53  { return strcasecmp(c_str(), b)!=0; }
54 };
55 
56 inline bool operator== (const char *a, const lispsymbolt &b)
57 { return strcasecmp(a, b.c_str())==0; }
58 
59 inline bool operator!= (const char *a, const lispsymbolt &b)
60 { return strcasecmp(a, b.c_str())!=0; }
61 
62 inline bool operator== (const lispsymbolt &a, const std::string &b)
63 { return strcasecmp(a.c_str(), b.c_str())==0; }
64 
65 inline bool operator!= (const lispsymbolt &a, const std::string &b)
66 { return strcasecmp(a.c_str(), b.c_str())!=0; }
67 
68 inline bool operator== (const std::string &a, const lispsymbolt &b)
69 { return strcasecmp(a.c_str(), b.c_str())==0; }
70 
71 inline bool operator!= (const std::string &a, const lispsymbolt &b)
72 { return strcasecmp(a.c_str(), b.c_str())!=0; }
73 
74 class lispexprt:public std::vector<lispexprt>
75 {
76 public:
77  enum { String, Symbol, Number, List } type;
79  std::string expr2string() const;
80  bool parse(const std::string &s);
81  bool is_nil() const
82  { return type==Symbol && value=="nil"; }
83 
84  void make_nil()
85  {
86  clear();
87  type=Symbol;
88  value="nil";
89  }
90 
91 protected:
92  bool parse(const std::string &s, std::string::size_type &ptr);
93 };
94 
95 inline std::ostream &operator<<(
96  std::ostream &out,
97  const lispexprt &expr)
98 {
99  return out << expr.expr2string();
100 }
101 
102 int test_lispexpr();
103 
104 #endif // CPROVER_UTIL_LISPEXPR_H
lispsymbolt(const char *a)
Definition: lispexpr.h:30
std::string expr2string() const
Definition: lispexpr.cpp:15
int test_lispexpr()
Definition: lispexpr.cpp:152
bool operator==(const lispsymbolt &b) const
Definition: lispexpr.h:43
bool parse(const std::string &s)
Definition: lispexpr.cpp:54
unsignedbv_typet size_type()
Definition: c_types.cpp:58
lispsymbolt()
Definition: lispexpr.h:34
enum lispexprt::@7 type
bool operator!=(const lispsymbolt &b) const
Definition: lispexpr.h:46
std::ostream & operator<<(std::ostream &out, const lispexprt &expr)
Definition: lispexpr.h:95
bool is_nil() const
Definition: lispexpr.h:81
lispsymbolt value
Definition: lispexpr.h:78
bool operator==(const char *a, const lispsymbolt &b)
Definition: lispexpr.h:56
lispsymbolt(const std::string &a)
Definition: lispexpr.h:39
void make_nil()
Definition: lispexpr.h:84
bool operator!=(const char *a, const lispsymbolt &b)
Definition: lispexpr.h:59