I think you are missing the /* comment */
case.
Darin Dimitrov
2009-10-24 16:20:39
The fun ones are formed by trigraphs and line continuations. My personal favorite is:
/??/
* this is a comment *??/
/
You don't seem to handle escaped quotes, like:
"Comment\"//also inside string"
versus
"Comment"//not inside string"
I think you can't handle
puts("Test \
// not a comment");
and this is also likely to make problems:
puts("'"); // this is a comment
The handling of \
character at the end of the line is performed at the earlier translation phase (phase 2) than replacement of comments (phase 3). For this reason, a //
comment can actually occupy more than one line in the original source file
// This \
whole thing \
is actually \
a single comment
P.S. Oh... I see this is already posted. OK, I'll keep it alive just for mentioning phases of translation :)