CBMC
statement_list_languaget Class Reference

Implements the language interface for the Statement List language. More...

#include <statement_list_language.h>

+ Inheritance diagram for statement_list_languaget:
+ Collaboration diagram for statement_list_languaget:

Public Member Functions

void set_language_options (const optionst &options, message_handlert &message_handler) override
 Sets language specific options. More...
 
bool parse (std::istream &instream, const std::string &path, message_handlert &message_handler) override
 Parses input given by instream and saves this result to this instance's parse tree. More...
 
bool generate_support_functions (symbol_table_baset &symbol_table, message_handlert &) override
 Currently unused. More...
 
bool typecheck (symbol_table_baset &symbol_table, const std::string &module, message_handlert &message_handler, const bool keep_file_local) override
 Converts the current parse tree into a symbol table. More...
 
bool typecheck (symbol_table_baset &symbol_table, const std::string &module, message_handlert &) override
 
bool can_keep_file_local () override
 Is it possible to call three-argument typecheck() on this object? More...
 
void show_parse (std::ostream &out, message_handlert &) override
 Prints the parse tree to the given output stream. More...
 
 ~statement_list_languaget () override
 
 statement_list_languaget ()
 
bool from_expr (const exprt &expr, std::string &code, const namespacet &ns) override
 Formats the given expression in a language-specific way. More...
 
bool from_type (const typet &type, std::string &code, const namespacet &ns) override
 Formats the given type in a language-specific way. More...
 
bool type_to_name (const typet &type, std::string &name, const namespacet &ns) override
 Encodes the given type in a language-specific way. More...
 
bool to_expr (const std::string &code, const std::string &module, exprt &expr, const namespacet &ns, message_handlert &message_handler) override
 Parses the given string into an expression. More...
 
std::unique_ptr< languagetnew_language () override
 
std::string id () const override
 
std::string description () const override
 
std::set< std::string > extensions () const override
 
void modules_provided (std::set< std::string > &modules) override
 
- Public Member Functions inherited from languaget
virtual bool preprocess (std::istream &instream, const std::string &path, std::ostream &outstream, message_handlert &)
 
virtual void dependencies (const std::string &module, std::set< std::string > &modules)
 
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, but doesn't populate that body in languaget::typecheck (i.e. More...
 
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. More...
 
virtual bool final (symbol_table_baset &symbol_table)
 Final adjustments, e.g. More...
 
virtual bool interfaces (symbol_table_baset &symbol_table, message_handlert &message_handler)
 
 languaget ()
 
virtual ~languaget ()
 

Private Attributes

statement_list_parse_treet parse_tree
 
std::string parse_path
 
object_factory_parameterst params
 

Detailed Description

Implements the language interface for the Statement List language.

Includes functions for parsing input streams and for converting the resulting parse tree into a symbol table.

Definition at line 23 of file statement_list_language.h.

Constructor & Destructor Documentation

◆ ~statement_list_languaget()

statement_list_languaget::~statement_list_languaget ( )
override

Definition at line 134 of file statement_list_language.cpp.

◆ statement_list_languaget()

statement_list_languaget::statement_list_languaget ( )

Definition at line 130 of file statement_list_language.cpp.

Member Function Documentation

◆ can_keep_file_local()

bool statement_list_languaget::can_keep_file_local ( )
overridevirtual

Is it possible to call three-argument typecheck() on this object?

Reimplemented from languaget.

Definition at line 81 of file statement_list_language.cpp.

◆ description()

std::string statement_list_languaget::description ( ) const
overridevirtual

Implements languaget.

Definition at line 164 of file statement_list_language.cpp.

◆ extensions()

std::set< std::string > statement_list_languaget::extensions ( ) const
overridevirtual

Implements languaget.

Definition at line 144 of file statement_list_language.cpp.

◆ from_expr()

bool statement_list_languaget::from_expr ( const exprt expr,
std::string &  code,
const namespacet ns 
)
overridevirtual

Formats the given expression in a language-specific way.

Parameters
exprthe expression to format
codethe formatted expression
nsa namespace
Returns
false if conversion succeeds

Reimplemented from languaget.

Definition at line 94 of file statement_list_language.cpp.

◆ from_type()

bool statement_list_languaget::from_type ( const typet type,
std::string &  code,
const namespacet ns 
)
overridevirtual

Formats the given type in a language-specific way.

Parameters
typethe type to format
codethe formatted type
nsa namespace
Returns
false if conversion succeeds

Reimplemented from languaget.

Definition at line 103 of file statement_list_language.cpp.

◆ generate_support_functions()

bool statement_list_languaget::generate_support_functions ( symbol_table_baset symbol_table,
message_handlert message_handler 
)
overridevirtual

Currently unused.

Implements languaget.

Definition at line 31 of file statement_list_language.cpp.

◆ id()

std::string statement_list_languaget::id ( ) const
overridevirtual

Implements languaget.

Definition at line 159 of file statement_list_language.cpp.

◆ modules_provided()

void statement_list_languaget::modules_provided ( std::set< std::string > &  modules)
overridevirtual

Reimplemented from languaget.

Definition at line 139 of file statement_list_language.cpp.

◆ new_language()

std::unique_ptr< languaget > statement_list_languaget::new_language ( )
overridevirtual

Implements languaget.

Definition at line 154 of file statement_list_language.cpp.

◆ parse()

bool statement_list_languaget::parse ( std::istream &  instream,
const std::string &  path,
message_handlert message_handler 
)
overridevirtual

Parses input given by instream and saves this result to this instance's parse tree.

Parameters
instreamInput to parse.
pathPath of the input.
message_handlerMessage handler.
Returns
False if successful.

Implements languaget.

Definition at line 58 of file statement_list_language.cpp.

◆ set_language_options()

void statement_list_languaget::set_language_options ( const optionst options,
message_handlert message_handler 
)
overridevirtual

Sets language specific options.

Parameters
optionsOptions that shall apply during the parse and typecheck process.
message_handlerMessage handler.

Reimplemented from languaget.

Definition at line 24 of file statement_list_language.cpp.

◆ show_parse()

void statement_list_languaget::show_parse ( std::ostream &  out,
message_handlert  
)
overridevirtual

Prints the parse tree to the given output stream.

Implements languaget.

Definition at line 76 of file statement_list_language.cpp.

◆ to_expr()

bool statement_list_languaget::to_expr ( const std::string &  code,
const std::string &  module,
exprt expr,
const namespacet ns,
message_handlert message_handler 
)
overridevirtual

Parses the given string into an expression.

Parameters
codethe string to parse
moduleprefix to be used for identifiers
exprthe parsed expression
nsa namespace
message_handlerMessage handler.
Returns
false if the conversion succeeds

Implements languaget.

Definition at line 120 of file statement_list_language.cpp.

◆ type_to_name()

bool statement_list_languaget::type_to_name ( const typet type,
std::string &  name,
const namespacet ns 
)
overridevirtual

Encodes the given type in a language-specific way.

Parameters
typethe type to encode
namethe encoded type
nsa namespace
Returns
false if the conversion succeeds

Reimplemented from languaget.

Definition at line 112 of file statement_list_language.cpp.

◆ typecheck() [1/2]

bool statement_list_languaget::typecheck ( symbol_table_baset symbol_table,
const std::string &  module,
message_handlert message_handler 
)
overridevirtual

Implements languaget.

Definition at line 86 of file statement_list_language.cpp.

◆ typecheck() [2/2]

bool statement_list_languaget::typecheck ( symbol_table_baset symbol_table,
const std::string &  module,
message_handlert message_handler,
const bool  keep_file_local 
)
overridevirtual

Converts the current parse tree into a symbol table.

Parameters
[out]symbol_tableObject that shall be filled by this function. If the symbol table is not empty when calling this function, its contents are merged with the new entries.
moduleName of the file that has been parsed.
message_handlerMessage handler.
keep_file_localSet to true if local variables of this module should be included in the table.
Returns
False if no errors occurred, true otherwise.

Reimplemented from languaget.

Definition at line 38 of file statement_list_language.cpp.

Member Data Documentation

◆ params

object_factory_parameterst statement_list_languaget::params
private

Definition at line 128 of file statement_list_language.h.

◆ parse_path

std::string statement_list_languaget::parse_path
private

Definition at line 127 of file statement_list_language.h.

◆ parse_tree

statement_list_parse_treet statement_list_languaget::parse_tree
private

Definition at line 126 of file statement_list_language.h.


The documentation for this class was generated from the following files: