CBMC
json_parser.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 #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 
18 class json_parsert:public parsert
19 {
20 public:
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
47 bool parse_json(
48  std::istream &in,
49  const std::string &filename,
50  message_handlert &message_handler,
51  jsont &dest);
52 
53 bool parse_json(
54  const std::string &filename,
55  message_handlert &message_handler,
56  jsont &dest);
57 
58 #endif // CPROVER_JSON_JSON_PARSER_H
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
Definition: json_parser.cpp:17
stackt stack
Definition: json_parser.h:27
json_parsert(message_handlert &message_handler)
Definition: json_parser.h:21
Definition: json.h:27
void swap(jsont &other)
Definition: json.cpp:161
Definition: parser.h:25
bool parse_json(std::istream &in, const std::string &filename, message_handlert &message_handler, jsont &dest)
Definition: json_parser.cpp:27
Parser utilities.
#define PRECONDITION(CONDITION)
Definition: invariant.h:463