HAL  v4.5.0-83-g30c8f0afc
The Hardware Analyzer - a comprehensive reverse engineering and manipulation framework for gate-level netlists.
hal::netlist_parser_manager Namespace Reference

Typedefs

using ParserFactory = std::function< std::unique_ptr< NetlistParser >()>
 

Functions

ProgramOptions get_cli_options ()
 
void register_parser (const std::string &name, const ParserFactory &parser_factory, const std::vector< std::string > &supported_file_extensions)
 
void unregister_parser (const std::string &name)
 
std::unique_ptr< Netlistparse (const std::filesystem::path &file_name, const ProgramArguments &args)
 
std::unique_ptr< Netlistparse (const std::filesystem::path &file_name, const GateLibrary *gate_library=nullptr)
 
std::vector< std::unique_ptr< Netlist > > parse_all (const std::filesystem::path &file_name)
 
bool can_parse (const std::filesystem::path &file_name)
 
std::unordered_map< std::string, std::vector< std::string > > get_parser_to_extensions ()
 

Detailed Description

The netlist parser manager keeps track of all netlist parsers that are available within HAL. It is used to dispatch parsing tasks to the respective parsers.

Typedef Documentation

◆ ParserFactory

using hal::netlist_parser_manager::ParserFactory = typedef std::function<std::unique_ptr<NetlistParser>()>

Definition at line 49 of file netlist_parser_manager.h.

Function Documentation

◆ can_parse()

bool hal::netlist_parser_manager::can_parse ( const std::filesystem::path &  file_name)

Checks whether there is a parser registered for file extension

Parameters
file_name- The input file
Returns
true if parser could be found, false otherwise.

Definition at line 135 of file netlist_parser_manager.cpp.

References hal::utils::to_lower().

Referenced by hal::FileManager::directoryStatus().

◆ get_cli_options()

ProgramOptions hal::netlist_parser_manager::get_cli_options ( )

Returns the command line interface options of the hdl parser manager

Returns
The options.

Definition at line 130 of file netlist_parser_manager.cpp.

◆ get_parser_to_extensions()

std::unordered_map< std::string, std::vector< std::string > > hal::netlist_parser_manager::get_parser_to_extensions ( )

Returns parser map

Returns
Vector of extensions for each parser plugin

Definition at line 238 of file netlist_parser_manager.cpp.

◆ parse() [1/2]

std::unique_ptr< Netlist > hal::netlist_parser_manager::parse ( const std::filesystem::path &  file_name,
const GateLibrary gate_library = nullptr 
)

Returns the netlist for a file, parsed with a defined gate library.

Parameters
[in]file_name- The input file.
[in]gate_library- The gate library used in the file.
Returns
The netlist representation of the hdl code or a nullpointer on error.

Definition at line 209 of file netlist_parser_manager.cpp.

◆ parse() [2/2]

std::unique_ptr< Netlist > hal::netlist_parser_manager::parse ( const std::filesystem::path &  file_name,
const ProgramArguments args 
)

Returns the netlist for the file and specified command line options.

Parameters
[in]file_name- The input file.
[in]args- The command line options.
Returns
The netlist representation of the hdl code or a nullpointer on error.

Definition at line 185 of file netlist_parser_manager.cpp.

References hal::gate_library_manager::get_gate_library(), hal::ProgramArguments::get_parameter(), hal::ProgramArguments::is_option_set(), and log_error.

Referenced by hal::netlist_factory::load_netlist().

◆ parse_all()

std::vector< std::unique_ptr< Netlist > > hal::netlist_parser_manager::parse_all ( const std::filesystem::path &  file_name)

If gatelibrary name is empty : tries to match the HDL file with each of the preloaded gate libraries and returns a vector of netlist objects for which the matching was successful.

Parameters
[in]file_name- The netlist file.
Returns
A vector containing one netlist per matching gate library.

Definition at line 227 of file netlist_parser_manager.cpp.

Referenced by hal::netlist_factory::load_netlists().

◆ register_parser()

void hal::netlist_parser_manager::register_parser ( const std::string &  name,
const ParserFactory parser_factory,
const std::vector< std::string > &  supported_file_extensions 
)

Registers a new HDL parser for a selection of file types. If parsers for some of the extensions already exist, they are not changed, only the new ones are registered.

Parameters
[in]name- The name of the parser.
[in]parser_factory- A factory function that constructs a new parser instance.
[in]supported_file_extensions- The file extensions this parser can process.

Definition at line 148 of file netlist_parser_manager.cpp.

References log_info, log_warning, name, hal::utils::to_lower(), and hal::utils::trim().

Referenced by hal::plugin_manager::load().

◆ unregister_parser()

void hal::netlist_parser_manager::unregister_parser ( const std::string &  name)

Unregisters a specific parser.

Parameters
[in]name- The name of the parser.

Definition at line 169 of file netlist_parser_manager.cpp.

References log_info, and name.

Referenced by hal::plugin_manager::unload().