cppparser icon indicating copy to clipboard operation
cppparser copied to clipboard

How to generate AST for Single file

Open VenoVeno opened this issue 2 years ago • 2 comments

After building in Linux using the steps https://github.com/satya-das/cppparser#building-cppparser.

cppparsertest binary is generated.

How to Parse a single file?

VenoVeno avatar Mar 03 '23 15:03 VenoVeno

You can use it as a library like this:

#include <string>
struct A{
    std::string x;
};
#include "cppparser.h"
#include <filesystem>
#include <iostream>

namespace fs = std::filesystem;
int main(){
    CppParser parser;
    const auto ast                    = parser.parseFile(std::string("path/to/your/file.cpp"));
}

Then compile, adding pub to your include dirs and linking boost_filesystem, boost_program_options and boost_system, which should have been generated in your build directory.

manuel5975p avatar Jun 09 '23 12:06 manuel5975p

image

I get the following errors when building, could you give some hints how to solve it?

When you referring to " linking boost_filesystem, boost_program_options and boost_system" , does this mean adding the following dirs to the linking path? image

dandelion915 avatar Jun 14 '23 07:06 dandelion915

Are you still getting this error?

satya-das avatar Oct 16 '24 09:10 satya-das

Closing this issue for now. If you are still getting this error, please reopen the issue.

satya-das avatar Oct 21 '24 16:10 satya-das