CppParser¶
class CppParser
C++ source parser.
Variables¶
Name | Description |
---|---|
entities | Stack of entities while parsing. |
starts | Stack of start bytes, corresponding to entities , while parsing. |
ends | Stack of end bytes, corresponding to entities , while parsing. |
parser | C++ parser. |
query | C++ entities query. |
query_exclude | C++ exclusions query. |
query_include | C++ inclusions query. |
Functions¶
Name | Description |
---|---|
CppParser | Constructor. |
~CppParser | Destructor. |
parse | Parse C++ source. |
push | Push onto the stack. |
pop | Pop the stack down to the parent of an entity, according to its byte range. |
preprocess | Preprocess C++ source, replacing preprocessor macros as defined in the config file and attempting to recover from any parse errors. |
report | Report errors after preprocessing. |
Variable Details¶
entities¶
std::list<Entity> entities
Stack of entities while parsing.
starts¶
std::list<uint32_t> starts
Stack of start bytes, corresponding to entities
, while parsing.
ends¶
std::list<uint32_t> ends
Stack of end bytes, corresponding to entities
, while parsing.
parser¶
TSParser* parser
C++ parser.
query¶
TSQuery* query
C++ entities query.
query_exclude¶
TSQuery* query_exclude
C++ exclusions query.
query_include¶
TSQuery* query_include
C++ inclusions query.
Function Details¶
CppParser¶
CppParser()
Constructor.
~CppParser¶
~CppParser()
Destructor.
parse¶
void parse(const std::filesystem::path& filename, const std::unordered_map<std::string,std::string>& defines, Entity& root)
Parse C++ source.
-
file
- C++ source file name.
-
defines
- Macro definitions.
-
root
- Root entity.
push¶
void push(Entity&& entity, const uint32_t start, const uint32_t end)
Push onto the stack.
-
entity
- Entity to push.
-
start
- Start byte of range.
-
end
- End byte of range.
pop¶
Entity& pop(const uint32_t start = 0, const uint32_t end = 0)
Pop the stack down to the parent of an entity, according to its byte range.
-
start
- Start byte of range.
-
end
- End byte of range.
- Return
- The parent.
If both start
and end
are zero, this is interpreting as popping the
stack down to the root node and returning it.
preprocess¶
std::string preprocess(const std::filesystem::path& file, const std::unordered_map<std::string,std::string>& defines)
Preprocess C++ source, replacing preprocessor macros as defined in the config file and attempting to recover from any parse errors. This is silent and does not report uncorrectable errors, these are reported later.
-
file
- C++ source file name.
-
defines
- Macro definitions.
- Return
- Preprocessed source.
report¶
void report(const std::filesystem::path& file, const std::string& in, TSTree* tree)
Report errors after preprocessing.
-
file
- C++ source file name.
-
in
- Preprocessed source.
-
tree
- Parse tree for file.