#include<stdio.h>
int count,cont;
%}
%%
"//" count++;
"/*"([^*]|[*][^/])*"*/"
{cont++;}
.
\n
%%
int main()
{
FILE *fp;
fp=fopen("test.c","r");
if(fp==NULL)
{
printf("File cant oprn");
return 0;
}
yyin=fp;
yylex();
printf("single line comments is=%d",count);
printf("\nMultiple line commentis=%d",cont);
}
ScreenShot:
No comments:
Post a Comment