42 std::unique_ptr<languaget> l(factory());
44 languages.back().extensions=l->extensions();
54 if(mode == language.mode)
55 return language.factory();
68 if(identifier.
empty())
71 if(ns.
lookup(identifier, symbol))
83 std::unique_ptr<languaget>
87 if(mode == ID_unknown)
93 "symbol '" +
id2string(identifier) +
"' has unknown mode '" +
103 const std::string &filename)
105 std::size_t ext_pos=filename.rfind(
'.');
107 if(ext_pos==std::string::npos)
110 std::string extension=
111 std::string(filename, ext_pos+1, std::string::npos);
113 if(extension.empty())
116 for(languagest::const_iterator
122 for(std::set<std::string>::const_iterator
123 e_it=l_it->extensions.begin();
124 e_it!=l_it->extensions.end();
126 if(_stricmp(extension.c_str(), e_it->c_str())==0)
127 return l_it->factory();
129 if(l_it->extensions.find(extension)!=l_it->extensions.end())
130 return l_it->factory();
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
A namespacet is essentially one or two symbol tables bound together, to allow for symbol lookups in t...
bool lookup(const irep_idt &name, const symbolt *&symbol) const override
See documentation for namespace_baset::lookup().
irep_idt mode
Language mode.
const std::string & id2string(const irep_idt &d)
Abstract interface to support a programming language.
std::unique_ptr< languaget > get_language_from_filename(const std::string &filename)
Get the language corresponding to the registered file name extensions.
void register_language(language_factoryt factory)
Register a language Note: registering a language is required for using the functions in language_util...
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.
std::unique_ptr< languaget > get_language_from_mode(const irep_idt &mode)
Get the language corresponding to the given mode.
std::list< language_entryt > languagest
std::unique_ptr< languaget > get_default_language()
Returns the default language.
const irep_idt & get_mode_from_identifier(const namespacet &ns, const irep_idt &identifier)
Get the mode of the given identifier's symbol.
std::unique_ptr< languaget >(* language_factoryt)()
#define PRECONDITION(CONDITION)
#define INVARIANT(CONDITION, REASON)
This macro uses the wrapper function 'invariant_violated_string'.
std::set< std::string > extensions
language_factoryt factory