Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
C Style commenting
#27
Quote:The first question in my mind is: Why would you want to strip the comments from a C program anyway? Is this a practical requirement or just an exercise?

Just an exercise.

Quote:While scanning over 100 C programs, I couldn't find the // prefix for on-line comments. I only found the leading /* and the trailing */ even if the comment was only on a single line. Are you sure the // option exists on all versions of C?

I didn't know that // wasn't allowed because I've never programmed in C before, as Nek pointed out in an earlier post. I do a lot of PHP programming and // is allowed in PHP, and PHP has (I'm told) a C like syntax, so...

Quote:1) It's possible that /* or */ or // could appear inside of a quoted string, and some quoted strings are delimited by double quotes (") and others by single quotes ('). So every time the program finds one of these supposed comment delimeters, it would have to do several scans to make sure that they were not found within quoted strings, which of course would have to be ignored. This is not as easy as it sounds. Watch out, 'cause the comments themselves could contain either of the quotes or even embedded delimiters themselves.

Well that makes the challenge a little harder then! That way people's entries will vary and I'll be able to judge which program is better.

Quote:2) An absolute "must" requirement is that the C source code has already been successfully compiled. You can appreciate that if the source code has errors, then the comment removing program will go bananas. In any event, the program will have to detect certain fatal errors, like a multi-line comment that has no subsequent */ terminator.

OKay, the programs that I'll test it on will already be able to be successfully compiler, however I may throw a couple of wonky ones at your entries just to see what happens Wink

Quote:3) Another "must" is to successfully compile the new uncommented code and then compare the object code to the original. If they don't match, then the comment remover doesn't work.

That's a way to test whether it's worked, yes.

Quote:Since you mentioned "C style" programs, perhaps the program will have to ask the user up front what comment delimeters he wants to use. Maybe this can be on a little parameter file as input.

I've already stated this feature as being worth bonus points Wink

Quote:In summary, if you have a practical use for this program, I'd be interested in taking a crack at it. If it's just an exercise, I'll pass.
*****

Awww go on... pretend it's a "hypothetical exercise" Wink
Reply


Messages In This Thread
C Style commenting - by oracle - 01-01-2004, 03:18 AM
C Style commenting - by red_Marvin - 01-01-2004, 03:35 AM
C Style commenting - by oracle - 01-01-2004, 04:16 AM
C Style commenting - by adosorken - 01-01-2004, 05:18 AM
C Style commenting - by Zack - 01-01-2004, 05:52 AM
C Style commenting - by oracle - 01-01-2004, 06:08 AM
C Style commenting - by Plasma - 01-01-2004, 06:16 AM
C Style commenting - by oracle - 01-01-2004, 06:18 AM
C Style commenting - by Plasma - 01-01-2004, 07:45 AM
C Style commenting - by adosorken - 01-01-2004, 08:02 AM
C Style commenting - by Agamemnus - 01-01-2004, 08:29 AM
C Style commenting - by adosorken - 01-01-2004, 08:45 AM
C Style commenting - by Plasma - 01-01-2004, 10:17 AM
C Style commenting - by Anonymous - 01-01-2004, 10:31 AM
C Style commenting - by adosorken - 01-01-2004, 10:46 AM
C Style commenting - by Zack - 01-01-2004, 08:39 PM
C Style commenting - by wildcard - 01-01-2004, 08:46 PM
C Style commenting - by Zack - 01-01-2004, 08:47 PM
C Style commenting - by Fling-master - 01-01-2004, 08:49 PM
C Style commenting - by Moneo - 01-02-2004, 06:52 AM
C Style commenting - by na_th_an - 01-02-2004, 06:56 AM
C Style commenting - by Moneo - 01-02-2004, 07:06 AM
C Style commenting - by na_th_an - 01-02-2004, 07:13 AM
C Style commenting - by Moneo - 01-02-2004, 07:40 AM
C Style commenting - by na_th_an - 01-02-2004, 07:48 AM
C Style commenting - by Moneo - 01-02-2004, 07:55 AM
C Style commenting - by oracle - 01-02-2004, 08:06 AM
C Style commenting - by na_th_an - 01-02-2004, 08:26 AM
C Style commenting - by oracle - 01-02-2004, 10:01 AM
C Style commenting - by na_th_an - 01-02-2004, 10:27 AM
C Style commenting - by oracle - 01-02-2004, 10:30 AM
C Style commenting - by adosorken - 01-02-2004, 10:31 AM
C Style commenting - by Mango - 01-02-2004, 03:37 PM
C Style commenting - by Rhiannon - 01-02-2004, 04:46 PM
C Style commenting - by LooseCaboose - 01-04-2004, 12:30 PM
C Style commenting - by Agamemnus - 01-05-2004, 01:10 AM
C Style commenting - by oracle - 01-06-2004, 03:59 AM
C Style commenting - by Agamemnus - 01-06-2004, 08:39 PM
C Style commenting - by oracle - 01-07-2004, 03:33 AM
C Style commenting - by Agamemnus - 01-07-2004, 07:02 AM
C Style commenting - by oracle - 01-07-2004, 08:23 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)