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
int
yyjsonparse
();
19
void
yyjsonrestart
(FILE *input_file);
20
21
class
json_parsert
:
public
parsert
22
{
23
public
:
24
typedef
std::stack<jsont, std::vector<jsont> >
stackt
;
25
stackt
stack
;
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
53
extern
json_parsert
json_parser
;
54
55
int
yyjsonerror
(
const
std::string &error);
56
57
// 'do it all' functions
58
bool
parse_json
(
59
std::istream &in,
60
const
std::string &filename,
61
message_handlert
&message_handler,
62
jsont
&dest);
63
64
bool
parse_json
(
65
const
std::string &filename,
66
message_handlert
&message_handler,
67
jsont
&dest);
68
69
#endif // CPROVER_JSON_JSON_PARSER_H
json_parser
json_parsert json_parser
Definition:
json_parser.cpp:13
parse_json
bool parse_json(std::istream &in, const std::string &filename, message_handlert &message_handler, jsont &dest)
Definition:
json_parser.cpp:16
json_parsert
Definition:
json_parser.h:21
json_parsert::push
void push(const jsont &x)
Definition:
json_parser.h:34
jsont
Definition:
json.h:26
json_parsert::clear
virtual void clear() override
Definition:
json_parser.h:46
json_parsert::stack
stackt stack
Definition:
json_parser.h:25
jsont::swap
void swap(jsont &other)
Definition:
json.cpp:161
yyjsonerror
int yyjsonerror(const std::string &error)
message_handlert
Definition:
message.h:27
parsert
Definition:
parser.h:23
yyjsonrestart
void yyjsonrestart(FILE *input_file)
json_parsert::parse
virtual bool parse() override
Definition:
json_parser.h:29
parser.h
json.h
json_parsert::pop
void pop(jsont &dest)
Definition:
json_parser.h:39
json_parsert::stackt
std::stack< jsont, std::vector< jsont > > stackt
Definition:
json_parser.h:24
yyjsonparse
int yyjsonparse()
json_parsert::top
jsont & top()
Definition:
json_parser.h:27
src
json
json_parser.h
Generated by
1.8.17