cprover
Toggle main menu visibility
Loading...
Searching...
No Matches
json_parser.cpp
Go to the documentation of this file.
1
/*******************************************************************\
2
3
Module:
4
5
Author: Daniel Kroening, kroening@kroening.com
6
7
\*******************************************************************/
8
9
#include "
json_parser.h
"
10
11
#include <fstream>
12
13
int
yyjsonlex_init_extra
(
json_parsert
*,
void
**);
14
int
yyjsonlex_destroy
(
void
*);
15
int
yyjsonparse
(
json_parsert
&,
void
*);
16
17
bool
json_parsert::parse
()
18
{
19
void
*scanner;
20
yyjsonlex_init_extra
(
this
, &scanner);
21
bool
parse_fail =
yyjsonparse
(*
this
, scanner) != 0;
22
yyjsonlex_destroy
(scanner);
23
return
parse_fail;
24
}
25
26
// 'do it all' function
27
bool
parse_json
(
28
std::istream &in,
29
const
std::string &filename,
30
message_handlert
&message_handler,
31
jsont
&dest)
32
{
33
json_parsert
json_parser{message_handler};
34
35
json_parser.
set_file
(filename);
36
json_parser.
in
=∈
37
38
bool
result=json_parser.
parse
();
39
40
// save result
41
if
(json_parser.
stack
.size()==1)
42
dest.
swap
(json_parser.
stack
.top());
43
44
return
result;
45
}
46
47
// 'do it all' function
48
bool
parse_json
(
49
const
std::string &filename,
50
message_handlert
&message_handler,
51
jsont
&dest)
52
{
53
std::ifstream in(filename);
54
55
if
(!in)
56
return
true
;
57
58
return
parse_json
(in, filename, message_handler, dest);
59
}
json_parsert
Definition
json_parser.h:19
json_parsert::parse
bool parse() override
Definition
json_parser.cpp:17
json_parsert::stack
stackt stack
Definition
json_parser.h:27
jsont
Definition
json.h:27
jsont::swap
void swap(jsont &other)
Definition
json.cpp:161
message_handlert
Definition
message.h:27
parsert::in
std::istream * in
Definition
parser.h:27
parsert::set_file
void set_file(const irep_idt &file)
Definition
parser.h:84
parse_json
bool parse_json(std::istream &in, const std::string &filename, message_handlert &message_handler, jsont &dest)
Definition
json_parser.cpp:27
yyjsonlex_destroy
int yyjsonlex_destroy(void *)
yyjsonlex_init_extra
int yyjsonlex_init_extra(json_parsert *, void **)
yyjsonparse
int yyjsonparse(json_parsert &, void *)
json_parser.h
json
json_parser.cpp
Generated by
1.17.0