Read C++ enum in python
Neil Hodgson
nyamatongwe+thunder at gmail.com
Wed Aug 19 04:12:48 EDT 2009
AggieDan04:
> file_data = open(filename).read()
> # Remove comments and preprocessor directives
> file_data = ' '.join(line.split('//')[0].split('#')[0] for line in
> file_data.splitlines())
> file_data = ' '.join(re.split(r'\/\*.*\*\/', file_data))
For some headers I tried it didn't work until the .* was changed to a
non-greedy .*? to avoid removing from the start of the first comment to
the end of the last comment.
file_data = ' '.join(re.split(r'\/\*.*?\*\/', file_data))
Neil
More information about the Python-list
mailing list