forked from diffblue/cbmc
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathjson_parser.h
63 lines (46 loc) · 1.11 KB
/
json_parser.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/*******************************************************************\
Module:
Author: Daniel Kroening, [email protected]
\*******************************************************************/
#ifndef CPROVER_JSON_JSON_PARSER_H
#define CPROVER_JSON_JSON_PARSER_H
#include <stack>
#include <util/parser.h>
#include <util/json.h>
class json_parsert:public parsert
{
public:
explicit json_parsert(message_handlert &message_handler)
: parsert(message_handler)
{
}
typedef std::stack<jsont, std::vector<jsont> > stackt;
stackt stack;
jsont &top() { return stack.top(); }
bool parse() override;
void push(const jsont &x)
{
stack.push(x);
}
void pop(jsont &dest)
{
PRECONDITION(!stack.empty());
dest.swap(stack.top());
stack.pop();
}
virtual void clear() override
{
stack=stackt();
}
};
// 'do it all' functions
bool parse_json(
std::istream &in,
const std::string &filename,
message_handlert &message_handler,
jsont &dest);
bool parse_json(
const std::string &filename,
message_handlert &message_handler,
jsont &dest);
#endif // CPROVER_JSON_JSON_PARSER_H