-
Notifications
You must be signed in to change notification settings - Fork 273
/
Copy pathjson_symtab_language.h
90 lines (70 loc) · 2.04 KB
/
json_symtab_language.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
/*******************************************************************\
Module: JSON symbol table language. Accepts a JSON format symbol
table that has been produced out-of-process, e.g. by using
a compiler's front-end.
Author: Chris Smowton, [email protected]
\*******************************************************************/
#ifndef CPROVER_JSON_SYMTAB_LANGUAGE_JSON_SYMTAB_LANGUAGE_H
#define CPROVER_JSON_SYMTAB_LANGUAGE_JSON_SYMTAB_LANGUAGE_H
#include <util/json.h>
#include <util/symbol_table_base.h>
#include <goto-programs/goto_functions.h>
#include <langapi/language.h>
#include <set>
#include <string>
class json_symtab_languaget : public languaget
{
public:
bool parse(
std::istream &instream,
const std::string &path,
message_handlert &message_handler) override;
bool typecheck(
symbol_table_baset &symbol_table,
const std::string &module,
message_handlert &message_handler) override;
void show_parse(std::ostream &out, message_handlert &) override;
bool to_expr(
const std::string &,
const std::string &,
exprt &,
const namespacet &,
message_handlert &) override
{
UNIMPLEMENTED;
}
std::string id() const override
{
return "json_symtab";
}
std::string description() const override
{
return "JSON symbol table";
}
std::set<std::string> extensions() const override
{
return {"json_symtab"};
}
std::unique_ptr<languaget> new_language() override
{
return std::make_unique<json_symtab_languaget>();
}
bool generate_support_functions(
symbol_table_baset &symbol_table,
message_handlert &) override
{
// check if entry point is already there
bool entry_point_exists =
symbol_table.symbols.find(goto_functionst::entry_point()) !=
symbol_table.symbols.end();
return !entry_point_exists;
}
~json_symtab_languaget() override = default;
protected:
jsont parsed_json_file;
};
inline std::unique_ptr<languaget> new_json_symtab_language()
{
return std::make_unique<json_symtab_languaget>();
}
#endif