0

This has been asked before but I have a specialised case which I should be able to handle with a regular expression.

I'm trying to read the warning log from Doxygen and the source is in C (so far, I dread to think about C++).

I need to match the functions and variable definitions found in that log and pick up the function and variable names.

More specifically the log has lines like

/home/me/blaa.c:10:Warning: Member a_function(int a, int b) (function) of file blaa.c is not documented

and

/home/me/blaa.h:10:Warning: Member a_variable[SOME_CONST(sizeof(SOME_STRUCT), 64)*ANOTHER_CONST] (variable) of file blaa.h is not documented

With all the variations you can have in C...

Can I match those with just one regexp or should I not even bother? The word in after the "parameter" (I use this loosely to also include the variables) list in parentheses is a set of certain words (function, variable, enum, etc) so if nothing else helps, I could match with those but I'd rather not in case there are types that I haven't seen yet in the logs.

My current attempt looks like

'(?P<full_path>.+):\d+:\s+Warning:\s+Member\s+(?P<member_name>.+)([\(\[](\**)\s*\w+([,)])[\)\]))*\s+\((?P<member_type>.+)\) of file\s+(?P<filename>.+)\s+is not documented'

(I use Python's re package.)

But it still fails to catch everything.

EDIT: There's some mistake in there that I have done in the last edit.

2
  • Could you provide an example of a warning that is not caught? Commented Oct 11, 2011 at 16:26
  • I can catch the warnings, but the function and variable names in e.g. the examples above are not parsed correctly. That is, the name sometimes contains the stuff within parentheses or brackets. Commented Oct 12, 2011 at 5:56

1 Answer 1

1

You were allowing zero or more matches between <member_name> and <member_type>. Try this instead:

'(?P<full_path>.+):\d+:\s+Warning:\s+Member\s+(?P<member_name>\w+).*\s+\((?P<member_type>\w+)\) of file\s+(?P<filename>.+)\s+is not documented'
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.