cprover
Loading...
Searching...
No Matches
json_symtab_language.h
Go to the documentation of this file.
1/*******************************************************************\
2
3Module: JSON symbol table language. Accepts a JSON format symbol
4 table that has been produced out-of-process, e.g. by using
5 a compiler's front-end.
6
7Author: Chris Smowton, chris.smowton@diffblue.com
8
9\*******************************************************************/
10
11#ifndef CPROVER_JSON_SYMTAB_LANGUAGE_JSON_SYMTAB_LANGUAGE_H
12#define CPROVER_JSON_SYMTAB_LANGUAGE_JSON_SYMTAB_LANGUAGE_H
13
14#include <util/json.h>
15#include <util/make_unique.h>
17
19
20#include <langapi/language.h>
21
22#include <set>
23#include <string>
24
26{
27public:
28 bool parse(std::istream &instream, const std::string &path) override;
29
30 bool typecheck(symbol_table_baset &symbol_table, const std::string &module)
31 override;
32
33 void show_parse(std::ostream &out) override;
34
35 bool
36 to_expr(const std::string &, const std::string &, exprt &, const namespacet &)
37 override
38 {
40 }
41
42 std::string id() const override
43 {
44 return "json_symtab";
45 }
46 std::string description() const override
47 {
48 return "JSON symbol table";
49 }
50
51 std::set<std::string> extensions() const override
52 {
53 return {"json_symtab"};
54 }
55
56 std::unique_ptr<languaget> new_language() override
57 {
59 }
60
62 {
63 // check if entry point is already there
64 bool entry_point_exists =
65 symbol_table.symbols.find(goto_functionst::entry_point()) !=
66 symbol_table.symbols.end();
67 return !entry_point_exists;
68 }
69
70 ~json_symtab_languaget() override = default;
71
72protected:
74};
75
76inline std::unique_ptr<languaget> new_json_symtab_language()
77{
79}
80
81#endif
Base class for all expressions.
Definition expr.h:56
static irep_idt entry_point()
Get the identifier of the entry point to a goto model.
std::string id() const override
bool typecheck(symbol_table_baset &symbol_table, const std::string &module) override
Typecheck a goto program in json form.
bool generate_support_functions(symbol_table_baset &symbol_table) override
Create language-specific support functions, such as __CPROVER_start, __CPROVER_initialize and languag...
void show_parse(std::ostream &out) override
Output the result of the parsed json file to the output stream passed as a parameter to this function...
~json_symtab_languaget() override=default
std::set< std::string > extensions() const override
std::unique_ptr< languaget > new_language() override
bool parse(std::istream &instream, const std::string &path) override
Parse a goto program in json form.
std::string description() const override
bool to_expr(const std::string &, const std::string &, exprt &, const namespacet &) override
Parses the given string into an expression.
Definition json.h:27
A namespacet is essentially one or two symbol tables bound together, to allow for symbol lookups in t...
Definition namespace.h:91
The symbol table base class interface.
const symbolst & symbols
Read-only field, used to look up symbols given their names.
Goto Programs with Functions.
std::unique_ptr< languaget > new_json_symtab_language()
Abstract interface to support a programming language.
std::unique_ptr< T > util_make_unique(Ts &&... ts)
Definition make_unique.h:19
#define UNIMPLEMENTED
Definition invariant.h:558
Author: Diffblue Ltd.