cprover
Loading...
Searching...
No Matches
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
19void yyjsonrestart(FILE *input_file);
20
22{
23public:
24 typedef std::stack<jsont, std::vector<jsont> > stackt;
26
27 jsont &top() { return stack.top(); }
28
29 virtual bool parse() override
30 {
31 return yyjsonparse()!=0;
32 }
33
34 void push(const jsont &x)
35 {
36 stack.push(x);
37 }
38
39 void pop(jsont &dest)
40 {
41 assert(!stack.empty());
42 dest.swap(stack.top());
43 stack.pop();
44 }
45
46 virtual void clear() override
47 {
48 stack=stackt();
49 yyjsonrestart(nullptr);
50 }
51};
52
54
55int yyjsonerror(const std::string &error);
56
57// 'do it all' functions
58bool parse_json(
59 std::istream &in,
60 const std::string &filename,
61 message_handlert &message_handler,
62 jsont &dest);
63
64bool parse_json(
65 const std::string &filename,
66 message_handlert &message_handler,
67 jsont &dest);
68
69#endif // CPROVER_JSON_JSON_PARSER_H
void pop(jsont &dest)
Definition json_parser.h:39
std::stack< jsont, std::vector< jsont > > stackt
Definition json_parser.h:24
void push(const jsont &x)
Definition json_parser.h:34
jsont & top()
Definition json_parser.h:27
virtual bool parse() override
Definition json_parser.h:29
virtual void clear() override
Definition json_parser.h:46
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)
int yyjsonparse()
int yyjsonerror(const std::string &error)
void yyjsonrestart(FILE *input_file)
json_parsert json_parser
Parser utilities.