Monday, June 2, 2014

Weekend prototype #1 C/C++ Enum Parsing

This weekend I prototyped a command line tool written in Lua for parsing C/C++ files to get a list of enums used in the codebase that has been parsed.

Once the codebase has been parsed, the tool will create a new header file (or rewrite an existing one) and save all exported enums as string arrays.

Consider the following C/C++ Header:
 #ifndef _Transform_h_  
 #define _Transform_h_  
 class Transform {  
    enum TransformSource {  
      TS_NONE = 0,  
 #endif //_Transform_h_  

If this file would serve as input to the enum parsing tool, the tool would create the following output:
 const char* TransformSourceStr[] = {  

More informations about the tool and the source code can be found in the BitBucket repository.