|
CppParser
|
The fork's main branch is called my-master (the default branch is still master which could be kept in sync with the parent repo's master). Every change made should have its own branch, DERIVED FROM master branch. Doing this would allow easy and isolated integration of each one of the branches into the original repository.
doxygen: Adds doxygen build target and its github action for automated deployment on repo's github pages.reform-cmake-lib: Changes how the main cmake file adds the static library, allowing the projects that use cppparser to benefit from the modern CMake.example-manual-ast: Adds examples/ to the source directory, including a example file demonstrating how to build AST maunally from nothing and generate the code from it using cppwriter.feature-ast-visitor: Introduces CppVisitorBase, CppVisitorPrinter, and CppVisitorMatcher as simple-to-use visitors and AST-matchers.An easy, fast, and robust library to parse C/C++ source.
CppParser can be used to build tools that need parsing of C/C++ files. I am using it to develop cib which implements ABI stable SDK architecture for C++ library.
To begin with we will see an example of parsing a hello-world program and see what is the AST that CppParser creates:
For the above hello-world program we can expect that when it is parsed the generated AST should look like following:
So, how we are going to access these elements of AST using CppParser? Below is the program written as unit-test for validating the correctness of generated AST:
This example is a real one and is part of actual unit test of CppParser.
Alternatively, if you prefer Ninja instead of make: