lex grammer for C comments

Dave Jones djones at megatest.UUCP
Thu Apr 7 04:55:12 AEST 1988


in article <262 at nyit.UUCP>, michael at nyit.UUCP (Michael Gwilliam) says:
> 
> 
> 
> NOTE: Sorry this reply took so long, but our phone line was out for a long
> time.
> 
> -----
> 
> Well the information is back and I've summerized the replies.  In case
> you forgot the question it is,  "Can C comments be filtered out with
> LEX as regular expressions?"
> 
> The answer is, "Yes, but it may not be a good idea."
> 

   Well... I agree with the "not a good idea" part.

> ...
> Here's what I did -- built my own little automata inside the action
				           ^^^^^^^^ pl.
> for the "/*" pattern.  This is stripped out of working code.
> 
> ...


Considered as a puzzle solution, that's cheating.   Of course you
can do it in C!  My question is, "Is there an LR(k) grammar for C comments?"
If so, show. If not, prove not.  This would make a good assignment in an
automata theory class.
 


	Dave /* ** ****/ Jones



More information about the Comp.lang.c mailing list