Parsing and generating C code


I have a very small task to solve and want to do it with Julia:
Removing curtain functions from a C code module. The names of the functions to remove are given as string list, there is an input file and an output file.

How would you approach this problem?

Finding the start of a function should be easy, but how to find the end?


I guess you could always keep count of how many { and } braces you encounter after the beginning of a function.

Thanks, I will try that.

So there is no library for parsing C/C++ code that I could use?

In Python there is pycparser for example.

You need to ignore comments and solve problems with conditional #ifdef-s as well

There could be also evil #include-s and evil macros with odd numbers of braces

1 Like

Thanks for the link!

One more question: Any idea to obtain the line number of a function, using Clang.jl?