CBMC
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
json_parser.h
Go to the documentation of this file.
1/*******************************************************************\
2
3Module:
4
5Author: Daniel Kroening, kroening@kroening.com
6
7\*******************************************************************/
8
9
10#ifndef CPROVER_JSON_JSON_PARSER_H
11#define CPROVER_JSON_JSON_PARSER_H
12
13#include <stack>
14
15#include <util/parser.h>
16#include <util/json.h>
17
19{
20public:
21 explicit json_parsert(message_handlert &message_handler)
22 : parsert(message_handler)
23 {
24 }
25
26 typedef std::stack<jsont, std::vector<jsont> > stackt;
28
29 jsont &top() { return stack.top(); }
30
31 bool parse() override;
32
33 void push(const jsont &x)
34 {
35 stack.push(x);
36 }
37
38 void pop(jsont &dest)
39 {
40 PRECONDITION(!stack.empty());
41 dest.swap(stack.top());
42 stack.pop();
43 }
44};
45
46// 'do it all' functions
47bool parse_json(
48 std::istream &in,
49 const std::string &filename,
50 message_handlert &message_handler,
51 jsont &dest);
52
53bool parse_json(
54 const std::string &filename,
55 message_handlert &message_handler,
56 jsont &dest);
57
58#endif // CPROVER_JSON_JSON_PARSER_H
ait supplies three of the four components needed: an abstract interpreter (in this case handling func...
Definition ai.h:562
void pop(jsont &dest)
Definition json_parser.h:38
std::stack< jsont, std::vector< jsont > > stackt
Definition json_parser.h:26
void push(const jsont &x)
Definition json_parser.h:33
jsont & top()
Definition json_parser.h:29
bool parse() override
json_parsert(message_handlert &message_handler)
Definition json_parser.h:21
Definition json.h:27
void swap(jsont &other)
Definition json.cpp:161
bool parse_json(std::istream &in, const std::string &filename, message_handlert &message_handler, jsont &dest)
Parser utilities.
#define PRECONDITION(CONDITION)
Definition invariant.h:463