41 std::unique_ptr<languaget> l(factory());
53 if(mode == language.mode)
54 return language.factory();
67 if(identifier.
empty())
70 if(ns.
lookup(identifier, symbol))
82 std::unique_ptr<languaget>
86 if(mode == ID_unknown)
92 "symbol `" +
id2string(identifier) +
"' has unknown mode '" +
102 const std::string &filename)
104 std::size_t ext_pos=filename.rfind(
'.');
106 if(ext_pos==std::string::npos)
109 std::string extension=
110 std::string(filename, ext_pos+1, std::string::npos);
115 for(languagest::const_iterator
121 for(std::set<std::string>::const_iterator
122 e_it=l_it->extensions.begin();
123 e_it!=l_it->extensions.end();
125 if(_stricmp(extension.c_str(), e_it->c_str())==0)
126 return l_it->factory();
128 if(l_it->extensions.find(extension)!=l_it->extensions.end())
129 return l_it->factory();
std::unique_ptr< languaget >(* language_factoryt)()
const std::string & id2string(const irep_idt &d)
virtual std::set< std::string > extensions() const
irep_idt mode
Language mode.
std::unique_ptr< languaget > get_default_language()
Returns the default language.
std::unique_ptr< languaget > get_language_from_mode(const irep_idt &mode)
Get the language corresponding to the given mode.
std::unique_ptr< languaget > get_language_from_filename(const std::string &filename)
Get the language corresponding to the registered file name extensions.
Symbol table entry.This is a symbol in the symbol table, stored in an object of type symbol_tablet...
#define INVARIANT(CONDITION, REASON)
virtual std::string id() const
const irep_idt & get_mode_from_identifier(const namespacet &ns, const irep_idt &identifier)
Get the mode of the given identifier's symbol.
Abstract interface to support a programming language.
#define PRECONDITION(CONDITION)
std::unique_ptr< languaget > get_language_from_identifier(const namespacet &ns, const irep_idt &identifier)
Get the language corresponding to the mode of the given identifier's symbol.
language_factoryt factory
std::list< language_entryt > languagest
void register_language(language_factoryt factory)
Register a language Note: registering a language is required for using the functions in language_util...
bool lookup(const irep_idt &name, const symbolt *&symbol) const override
See namespace_baset::lookup().
std::set< std::string > extensions