I am doing a simple program that should count the occurrences of ternary operator ?: in C source code. And I am trying to simplify that as much as it is possible. So I’ve filtered from source code these things:
- String literals ” “
- Character constants ‘ ‘
- Trigraph sequences ??=, ??(, etc.
- Comments
- Macros
And now I am only counting the occurances of questionmarks.
So my question question is: Is there any other symbol, operator or anything else what could cause problem – contain ‘?’ ?
Let’s suppose that the source is syntax valid.
I think you found all places where a question-mark is introduced and therefore eliminated all possible false-positives (for the ternary op). But maybe you eliminated too much: Maybe you want to count those “?:”‘s that get introduced by macros; you dont count those. Is that what you intend? If that’s so, you’re done.