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