CBMC
Loading...
Searching...
No Matches
json_parser.cpp
Go to the documentation of this file.
1/*******************************************************************\
2
3Module:
4
5Author: Daniel Kroening, kroening@kroening.com
6
7\*******************************************************************/
8
9#include "json_parser.h"
10
11#include <fstream>
12
16
18{
19 void *scanner;
21 bool parse_fail = yyjsonparse(*this, scanner) != 0;
23 return parse_fail;
24}
25
26// 'do it all' function
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=&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
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}
ait supplies three of the four components needed: an abstract interpreter (in this case handling func...
Definition ai.h:562
bool parse() override
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 yyjsonlex_destroy(void *)
int yyjsonlex_init_extra(json_parsert *, void **)
int yyjsonparse(json_parsert &, void *)