CppParser
Loading...
Searching...
No Matches
CppParser Class Reference

Parses C++ source and generates an AST. More...

#include <cppparser.h>

Collaboration diagram for CppParser:
Collaboration graph

Public Types

using ErrorHandler = std::function< void(const char *errLineText, size_t lineNum, size_t errorStartPos, int lexerContext)>
 

Public Member Functions

 CppParser (CppObjFactoryPtr objFactory=nullptr)
 
 CppParser (CppParser &&rhs)
 
void addKnownMacro (std::string knownMacro)
 
void addKnownMacros (const std::vector< std::string > &knownMacros)
 
void addDefinedName (std::string definedName, int value=0)
 
void addUndefinedName (std::string undefinedName)
 
void addUndefinedNames (const std::vector< std::string > &undefinedNames)
 
void addIgnorableMacro (std::string ignorableMacro)
 
void addIgnorableMacros (const std::vector< std::string > &ignorableMacros)
 
void addKnownApiDecor (std::string knownApiDecor)
 
void addKnownApiDecors (const std::vector< std::string > &knownApiDecor)
 
bool addRenamedKeyword (const std::string &keyword, std::string renamedKeyword)
 
void parseEnumBodyAsBlob ()
 
void parseFunctionBodyAsBlob (bool asBlob)
 
CppCompoundPtr parseFile (const std::string &filename)
 
CppCompoundPtr parseString (const std::string &filePathToSave, const std::string &content)
 
CppCompoundPtr parseString (const std::string &content)
 
CppCompoundPtr parseStream (char *stm, size_t stmSize)
 
void setErrorHandler (ErrorHandler errorHandler)
 
void resetErrorHandler ()
 

Private Attributes

CppObjFactoryPtr objFactory_
 

Detailed Description

Parses C++ source and generates an AST.

Warning
Although its a class it is not reentrant because underlying btyacc is not reentrant. So, any change done through this class is global and affects the result of other instances too.

Definition at line 39 of file cppparser.h.

Member Typedef Documentation

◆ ErrorHandler

using CppParser::ErrorHandler = std::function<void(const char* errLineText, size_t lineNum, size_t errorStartPos, int lexerContext)>

Definition at line 42 of file cppparser.h.

Constructor & Destructor Documentation

◆ CppParser() [1/2]

CppParser::CppParser ( CppObjFactoryPtr  objFactory = nullptr)

Definition at line 54 of file cppparser.cpp.

◆ CppParser() [2/2]

CppParser::CppParser ( CppParser &&  rhs)
inline

Definition at line 47 of file cppparser.h.

Member Function Documentation

◆ addDefinedName()

void CppParser::addDefinedName ( std::string  definedName,
int  value = 0 
)

Definition at line 72 of file cppparser.cpp.

◆ addIgnorableMacro()

void CppParser::addIgnorableMacro ( std::string  ignorableMacro)

Definition at line 88 of file cppparser.cpp.

◆ addIgnorableMacros()

void CppParser::addIgnorableMacros ( const std::vector< std::string > &  ignorableMacros)

Definition at line 93 of file cppparser.cpp.

◆ addKnownApiDecor()

void CppParser::addKnownApiDecor ( std::string  knownApiDecor)

Definition at line 99 of file cppparser.cpp.

◆ addKnownApiDecors()

void CppParser::addKnownApiDecors ( const std::vector< std::string > &  knownApiDecor)

Definition at line 104 of file cppparser.cpp.

◆ addKnownMacro()

void CppParser::addKnownMacro ( std::string  knownMacro)

Definition at line 61 of file cppparser.cpp.

◆ addKnownMacros()

void CppParser::addKnownMacros ( const std::vector< std::string > &  knownMacros)

Definition at line 66 of file cppparser.cpp.

◆ addRenamedKeyword()

bool CppParser::addRenamedKeyword ( const std::string &  keyword,
std::string  renamedKeyword 
)

Definition at line 110 of file cppparser.cpp.

◆ addUndefinedName()

void CppParser::addUndefinedName ( std::string  undefinedName)

Definition at line 77 of file cppparser.cpp.

◆ addUndefinedNames()

void CppParser::addUndefinedNames ( const std::vector< std::string > &  undefinedNames)

Definition at line 82 of file cppparser.cpp.

◆ parseEnumBodyAsBlob()

void CppParser::parseEnumBodyAsBlob ( )

Definition at line 121 of file cppparser.cpp.

◆ parseFile()

CppCompoundPtr CppParser::parseFile ( const std::string &  filename)

Definition at line 131 of file cppparser.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ parseFunctionBodyAsBlob()

void CppParser::parseFunctionBodyAsBlob ( bool  asBlob)

Definition at line 126 of file cppparser.cpp.

◆ parseStream()

CppCompoundPtr CppParser::parseStream ( char *  stm,
size_t  stmSize 
)

Definition at line 154 of file cppparser.cpp.

Here is the caller graph for this function:

◆ parseString() [1/2]

CppCompoundPtr CppParser::parseString ( const std::string &  content)

Definition at line 149 of file cppparser.cpp.

Here is the call graph for this function:

◆ parseString() [2/2]

CppCompoundPtr CppParser::parseString ( const std::string &  filePathToSave,
const std::string &  content 
)

Definition at line 141 of file cppparser.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ resetErrorHandler()

void CppParser::resetErrorHandler ( )

Definition at line 167 of file cppparser.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setErrorHandler()

void CppParser::setErrorHandler ( ErrorHandler  errorHandler)

Definition at line 162 of file cppparser.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ objFactory_

CppObjFactoryPtr CppParser::objFactory_
private

Definition at line 82 of file cppparser.h.


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