Recently, due to project requirements, QT code has been compiled. Many annotation formats do not meet doxygen requirements.
Requirements:
Find the function implementation in the source code, parse the previous comments, and regenerate the code comments.
The next two requirements are well solved. It is difficult to implement the first requirement.
The first thought was the parser. The first thought was YACC. Unfortunately, after half a day, the production formula of C ++ was not found. It is estimated that C ++ is too complicated.
However, I found the following document to understand how to make an interpreter.
Http://www.nobugs.org/developer/parsingcpp/
Clang is the most powerful open-source tool. However, as a C ++ interpreter, the workload is obviously more than one week.
Learning, researching, and using tools that can be solved in one day.
Next, let's change your mind to see if Perl/Python has a ready-made library.
Python found the library that encapsulates clang, but unfortunately, it tried twice, compilation failed, and installation failed. In the short term, it seems that it cannot be solved, but it can only be abandoned.
Http://eli.thegreenplace.net/2011/07/03/parsing-c-in-python-with-clang/
Pycparser does not support C ++
Cppheaderparser supports the header file explanation format to meet the requirements. Unfortunately, it does not support source code.
Gcc-XML meets requirements
After finding the tool, the next task is simple.
The core issue of the entire implementation is how to know how many classes are defined in a file, how many functions are implemented, and how many lines are implemented in the file.
This information can be obtained, followed by the regular data formatting problem.
CTAG can also solve this problem, but it is inconvenient that CTAG generates a regular expression of the function, which is a little troublesome to use and is not convenient to use without a row number.
Code comment formatting