% {
#include<stdio.h>
#include<string.h>
int lines, spacecount, count;
int tabcount, flag=0;
%}
%
[] { spacecount++;
ccount++;
if (flag){wcount++; flag=0;}}
[\t]{tabcount++; count++;
if(flag){cocount++, flag=0;}}
[\n]{linec++, ccount++;
if(flag){cocount++,flag=0;}}
[b \t /t b](flag=1) count++}
%%
main
{
yylex();
printf("Number of lines %d \n" linecount);
printf("Number of spaces %d \n" spacecount);
printf("Number of character %d \n" ccount);
printf("Number of tab %d \n" tabcount);
}
No comments:
Post a Comment