I have a simple flex source code which skips the comments in /* */
and should get the count of comments found:
%{
int in_comment = 0;
int count = 0;
%}
%%
\/\* { in_comment = 1; count++; }
\*\/ { in_comment = 0; }
. { if (!in_comment) ECHO; }
%%
int main(void)
{
yylex();
printf("Comments found %d\n", count); // never executed
return 0;
}
First half works fine - it really skips the comments, but they are not counted... what can I do to execute printf
line?