I have a cpp file with a huge class implementation. Now I have to modify the source file itself.
For this, is there a library/api/tool that will tokenize this file for me and give me one token each time i request.
My requirement is as below.
OpenCPPFile()
While (!EOF)
token = GetNextToken();
process something based on this token
EndWhile
I am happy now
Regards,
AJ
Boost.Waveoffers a standard C++ lexer among many other tools like a standard preprocessor which are built on top ofBoost.Spirit. Check the following sample in the boost directory:For example, if you have the following file which is called
main.cpp:You apply the lexer which I named
cpp_lex(assuming they are in the same directory):You get:
Here is the code, for more information check Boost.Wave manual: