-
Notifications
You must be signed in to change notification settings - Fork 273
/
Copy pathcpp_language.h
116 lines (86 loc) · 2.7 KB
/
cpp_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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/*******************************************************************\
Module: C++ Language Module
Author: Daniel Kroening, [email protected]
\*******************************************************************/
/// \file
/// C++ Language Module
#ifndef CPROVER_CPP_CPP_LANGUAGE_H
#define CPROVER_CPP_CPP_LANGUAGE_H
#include <memory>
#include <ansi-c/c_object_factory_parameters.h>
#include <langapi/language.h>
#include "cpp_parse_tree.h"
class cpp_languaget:public languaget
{
public:
void
set_language_options(const optionst &options, message_handlert &) override
{
object_factory_params.set(options);
}
bool preprocess(
std::istream &instream,
const std::string &path,
std::ostream &outstream,
message_handlert &message_handler) override;
bool parse(
std::istream &instream,
const std::string &path,
message_handlert &message_handler) override;
bool generate_support_functions(
symbol_table_baset &symbol_table,
message_handlert &message_handler) override;
bool typecheck(
symbol_table_baset &symbol_table,
const std::string &module,
message_handlert &message_handler) override;
bool merge_symbol_table(
symbol_table_baset &dest,
symbol_table_baset &src,
const std::string &module,
class replace_symbolt &replace_symbol) const;
void show_parse(std::ostream &out, message_handlert &) override;
// constructor, destructor
~cpp_languaget() override;
cpp_languaget() { }
// conversion from expression into string
bool from_expr(
const exprt &expr,
std::string &code,
const namespacet &ns) override;
// conversion from type into string
bool from_type(
const typet &type,
std::string &code,
const namespacet &ns) override;
bool type_to_name(
const typet &type,
std::string &name,
const namespacet &ns) override;
// conversion from string into expression
bool to_expr(
const std::string &code,
const std::string &module,
exprt &expr,
const namespacet &ns,
message_handlert &message_handler) override;
std::unique_ptr<languaget> new_language() override
{
return std::make_unique<cpp_languaget>();
}
std::string id() const override { return "cpp"; }
std::string description() const override { return "C++"; }
std::set<std::string> extensions() const override;
void modules_provided(std::set<std::string> &modules) override;
protected:
cpp_parse_treet cpp_parse_tree;
std::string parse_path;
c_object_factory_parameterst object_factory_params;
void show_parse(std::ostream &out, const cpp_itemt &item);
std::string main_symbol()
{
return "main";
}
};
std::unique_ptr<languaget> new_cpp_language();
#endif // CPROVER_CPP_CPP_LANGUAGE_H