1/*******************************************************************\
3Module: Abstract interface to support a programming language
5Author: Daniel Kroening, kroening@kroening.com
7\*******************************************************************/
12#ifndef CPROVER_LANGAPI_LANGUAGE_H
13#define CPROVER_LANGAPI_LANGUAGE_H
19#include <memory> // unique_ptr
22#include <unordered_set>
31 #define OPT_FUNCTIONS \
34 #define HELP_FUNCTIONS " {y--function} {uname} \t set main function name\n"
48 const std::string &path,
61 const std::string &path,
76 // add external dependencies of a given module to set
80 std::set<std::string> &modules);
82 // add modules provided by currently parsed file to set
86 (
void)modules;
// unused parameter
96 (
void)methods;
// unused parameter
111 (
void)message_handler;
118 // type check interfaces of currently parsed file
124 // type check a module in the currently parsed file
128 const std::string &
module,
148 const std::string &
module,
150 const bool keep_file_local)
154 "three-argument typecheck should only be called for files written"
155 " in a language that allows file-local symbols, like C");
158 // language id / description
160 virtual std::string
id()
const = 0;
169 // conversion of expressions
209 const std::string &code,
210 const std::string &
module,
217 // constructor / destructor
223#endif // CPROVER_UTIL_LANGUAGE_H
ait supplies three of the four components needed: an abstract interpreter (in this case handling func...
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
Base class for all expressions.
virtual void modules_provided(std::set< std::string > &modules)
virtual std::string description() const =0
virtual bool can_keep_file_local()
Is it possible to call three-argument typecheck() on this object?
virtual void dependencies(const std::string &module, std::set< std::string > &modules)
virtual bool typecheck(symbol_table_baset &symbol_table, const std::string &module, message_handlert &message_handler, const bool keep_file_local)
typecheck without removing specified entries from the symbol table
virtual bool from_type(const typet &type, std::string &code, const namespacet &ns)
Formats the given type in a language-specific way.
virtual bool parse(std::istream &instream, const std::string &path, message_handlert &message_handler)=0
virtual bool type_to_name(const typet &type, std::string &name, const namespacet &ns)
Encodes the given type in a language-specific way.
virtual std::string id() const =0
virtual std::set< std::string > extensions() const =0
virtual bool from_expr(const exprt &expr, std::string &code, const namespacet &ns)
Formats the given expression in a language-specific way.
virtual void convert_lazy_method(const irep_idt &function_id, symbol_table_baset &symbol_table, message_handlert &message_handler)
Requests this languaget should populate the body of method function_id in symbol_table.
virtual bool generate_support_functions(symbol_table_baset &symbol_table, message_handlert &message_handler)=0
Create language-specific support functions, such as __CPROVER_start, __CPROVER_initialize and languag...
virtual bool typecheck(symbol_table_baset &symbol_table, const std::string &module, message_handlert &message_handler)=0
virtual bool preprocess(std::istream &instream, const std::string &path, std::ostream &outstream, message_handlert &)
virtual std::unique_ptr< languaget > new_language()=0
virtual bool interfaces(symbol_table_baset &symbol_table, message_handlert &message_handler)
virtual bool to_expr(const std::string &code, const std::string &module, exprt &expr, const namespacet &ns, message_handlert &message_handler)=0
Parses the given string into an expression.
virtual void methods_provided(std::unordered_set< irep_idt > &methods) const
Should fill methods with the symbol identifiers of all methods this languaget can provide a body for,...
virtual void set_language_options(const optionst &, message_handlert &)
Set language-specific options.
virtual void show_parse(std::ostream &out, message_handlert &message_handler)=0
A namespacet is essentially one or two symbol tables bound together, to allow for symbol lookups in t...
The symbol table base class interface.
The type of an expression, extends irept.
#define INVARIANT(CONDITION, REASON)
This macro uses the wrapper function 'invariant_violated_string'.