cprover
Loading...
Searching...
No Matches
cpp_language.h
Go to the documentation of this file.
1/*******************************************************************\
2
3Module: C++ Language Module
4
5Author: Daniel Kroening, kroening@cs.cmu.edu
6
7\*******************************************************************/
8
11
12#ifndef CPROVER_CPP_CPP_LANGUAGE_H
13#define CPROVER_CPP_CPP_LANGUAGE_H
14
15#include <memory>
16
18
19#include <util/make_unique.h> // unique_ptr
20
21#include <langapi/language.h>
22
23#include "cpp_parse_tree.h"
24
26{
27public:
28 void set_language_options(const optionst &options) override
29 {
31 }
32
33 bool preprocess(
34 std::istream &instream,
35 const std::string &path,
36 std::ostream &outstream) override;
37
38 bool parse(
39 std::istream &instream,
40 const std::string &path) override;
41
42 bool generate_support_functions(symbol_table_baset &symbol_table) override;
43
44 bool typecheck(symbol_table_baset &symbol_table, const std::string &module)
45 override;
46
50 const std::string &module,
51 class replace_symbolt &replace_symbol) const;
52
53 void show_parse(std::ostream &out) override;
54
55 // constructor, destructor
56 ~cpp_languaget() override;
58
59 // conversion from expression into string
60 bool from_expr(
61 const exprt &expr,
62 std::string &code,
63 const namespacet &ns) override;
64
65 // conversion from type into string
66 bool from_type(
67 const typet &type,
68 std::string &code,
69 const namespacet &ns) override;
70
71 bool type_to_name(
72 const typet &type,
73 std::string &name,
74 const namespacet &ns) override;
75
76 // conversion from string into expression
77 bool to_expr(
78 const std::string &code,
79 const std::string &module,
80 exprt &expr,
81 const namespacet &ns) override;
82
83 std::unique_ptr<languaget> new_language() override
85
86 std::string id() const override { return "cpp"; }
87 std::string description() const override { return "C++"; }
88 std::set<std::string> extensions() const override;
89
90 void modules_provided(std::set<std::string> &modules) override;
91
92protected:
94 std::string parse_path;
95
97
98 void show_parse(std::ostream &out, const cpp_itemt &item);
99
100 std::string main_symbol()
101 {
102 return "main";
103 }
104};
105
106std::unique_ptr<languaget> new_cpp_language();
107
108#endif // CPROVER_CPP_CPP_LANGUAGE_H
ait supplies three of the four components needed: an abstract interpreter (in this case handling func...
Definition ai.h:563
bool from_type(const typet &type, std::string &code, const namespacet &ns) override
Formats the given type in a language-specific way.
void set_language_options(const optionst &options) override
Set language-specific options.
bool typecheck(symbol_table_baset &symbol_table, const std::string &module) override
bool type_to_name(const typet &type, std::string &name, const namespacet &ns) override
Encodes the given type in a language-specific way.
std::string id() const override
c_object_factory_parameterst object_factory_params
bool to_expr(const std::string &code, const std::string &module, exprt &expr, const namespacet &ns) override
Parses the given string into an expression.
std::string parse_path
std::string description() const override
bool merge_symbol_table(symbol_table_baset &dest, symbol_table_baset &src, const std::string &module, class replace_symbolt &replace_symbol) const
std::set< std::string > extensions() const override
std::unique_ptr< languaget > new_language() override
std::string main_symbol()
~cpp_languaget() override
bool generate_support_functions(symbol_table_baset &symbol_table) override
Create language-specific support functions, such as __CPROVER_start, __CPROVER_initialize and languag...
bool from_expr(const exprt &expr, std::string &code, const namespacet &ns) override
Formats the given expression in a language-specific way.
bool preprocess(std::istream &instream, const std::string &path, std::ostream &outstream) override
ANSI-C preprocessing.
bool parse(std::istream &instream, const std::string &path) override
void modules_provided(std::set< std::string > &modules) override
cpp_parse_treet cpp_parse_tree
void show_parse(std::ostream &out) override
Base class for all expressions.
Definition expr.h:56
A namespacet is essentially one or two symbol tables bound together, to allow for symbol lookups in t...
Definition namespace.h:91
Replace a symbol expression by a given expression.
The symbol table base class interface.
The type of an expression, extends irept.
Definition type.h:29
std::unique_ptr< languaget > new_cpp_language()
C++ Parser.
Abstract interface to support a programming language.
void set(const optionst &)
Assigns the parameters from given options.