LEX rule, anyone???
mark
mark at linqdev.UUCP
Tue Dec 12 04:39:24 AEST 1989
> /* this is a regular expression to match a c comment */
> /* written by cml 890922 (probably not minimal) */
>%%
>"/*"([^*]|[*]*[^*/])*[*]+"/" {printf("saw a c comment.\n");}
>. {putchar(*yytext);}
>----snip----
>
>chris...
>--
As a friend the the office here pointed out, this particular
way of handling C comments tends to 'grow' the parser.
Here is his solution which I thought was a neat way to do it
and save some space:
"/*" {
do {
yytext[0] = yytext[1];
if( !( yytext[1] = input() ) )
yyerror(
"EOF in comment. Missing \"*/\"." );
} while( yytext[0] != '*' || yytext[1] != '/' );
}
01010000010000010100001101001011010001010101010000100000010000100100001001010011
* Mark R. Holbrook-WS7M uw-beaver! Interlinq Software Corp *
* Issaquah, WA 98027 sumax!ole! /mark 10230 NE Points Dr #200 *
* HM:206-392-9672 Voice linqdev! Kirkland, WA 98033-???? *
* HM:206-392-9673 Data \ws7m!ws7m WK:206-827-1112 Ext:152 *
* Opinions..? Yes, they are mine and mine alone! I'll sell 'em cheap however! *
00100000010101110101001100110111010011010100000001010111010100110011011101001101
More information about the Comp.lang.c
mailing list