/* deceleration section in this sections we will declared the different value and include the header file which we are using in this program to run this program */
%{
#include<stdio.h>
int nc_count=0; // for count the character
int nw_count=0; // for count the word
int ns_count=0; // for count the space
int nl_count=0; // count the line
%}
/* this sections is known as defined section in which we defined the rule and regulation of regular expression which will going to accept or not */
%%
[ ] {ns_count++;nw_count++;}
[\t] {ns_count++;nw_count++;}
[\n] {nl_count++;nw_count++;}
[a-zA-Z] {nc_count++;}
%%
/* main section for calling function */
int main()
{
FILE *fp;
char file[10];
printf("enter the filename\n");
scanf("%s",file);
fp=fopen(file,"r");
yyin=fp;
yylex();
printf("character=%d\nword=%d\nSpace=%d\nLine=%d\n",nc_count,nw_count-1,ns_count,nl_count-1);
return 0;
}
How to run this program
open terminal and run " flex ass1.2.l "
it generates c file run " cc lex.yy.c -o count -ll " as out put in file count
now run for output " ./count "
Casinos for Canadians - DMC
ReplyDeleteThe casinos have the lowest deposit bonus, 제천 출장샵 and you can use the code 'GDSR' on top of that, then try it 태백 출장샵 out for yourself at 보령 출장마사지 the 김해 출장마사지 casino. 부천 출장마사지