AALanguage
The best language for those who have nothing to do
Loading...
Searching...
No Matches
LibParser Class Reference

A helper class for getting information about built-in libraries. More...

#include <LibParser.h>

Public Member Functions

 LibParser (std::string libs_)
 Constructor that saves the path to the standard libraries directory.
 
bool add_lib (std::string name)
 Adds the new library to the list of libraries in use, if necessary.
 
std::string parse_lib (std::string name)
 Reads all text from the library file.
 
std::string name_to_path (std::string name)
 Converts the standard library name to its file path.
 

Private Member Functions

std::vector< std::string > split (const std::string &s, char delim)
 
std::string slurp (std::ifstream &in)
 

Private Attributes

std::string libs
 
std::unordered_set< std::string > used
 

Detailed Description

A helper class for getting information about built-in libraries.

Definition at line 10 of file LibParser.h.

Constructor & Destructor Documentation

◆ LibParser()

LibParser::LibParser ( std::string libs_)

Constructor that saves the path to the standard libraries directory.

Parameters
libs_library directory path

Definition at line 3 of file LibParser.cpp.

References libs.

Member Function Documentation

◆ add_lib()

bool LibParser::add_lib ( std::string name)

Adds the new library to the list of libraries in use, if necessary.

Parameters
namelibrary name with . splitting
Returns
True if the library has not yet been used. Otherwise false.

Definition at line 6 of file LibParser.cpp.

References name_to_path(), and used.

Referenced by LexicalAnalyzer::LexicalAnalyzer().

◆ name_to_path()

std::string LibParser::name_to_path ( std::string name)

Converts the standard library name to its file path.

Parameters
namelibrary name with . splitting
Returns
Library file path.

Definition at line 30 of file LibParser.cpp.

References libs, and split().

Referenced by add_lib(), LexicalAnalyzer::LexicalAnalyzer(), and parse_lib().

◆ parse_lib()

std::string LibParser::parse_lib ( std::string name)

Reads all text from the library file.

Parameters
namelibrary name with . splitting
Returns
Full library file text.

Definition at line 19 of file LibParser.cpp.

References name_to_path(), and slurp().

◆ slurp()

std::string LibParser::slurp ( std::ifstream & in)
private

Definition at line 51 of file LibParser.cpp.

Referenced by parse_lib().

◆ split()

std::vector< std::string > LibParser::split ( const std::string & s,
char delim )
private

Definition at line 42 of file LibParser.cpp.

Referenced by name_to_path().

Member Data Documentation

◆ libs

std::string LibParser::libs
private

Definition at line 43 of file LibParser.h.

Referenced by LibParser(), and name_to_path().

◆ used

std::unordered_set<std::string> LibParser::used
private

Definition at line 44 of file LibParser.h.

Referenced by add_lib().


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