Program:
// Lex file: com.l
%{
int count=0;
%}
%%
.*com\n {count++;ECHO;}
. ;
%%
main()
{
yylex();
printf("\nCount= %d\n",count);
return 0;
}
Output:
nn@linuxmint ~ $ lex com.l
nn@linuxmint ~ $ gcc lex.yy.c -ll
nn@linuxmint ~ $ ./a.out<com.txt
www.google.com
www.yahoo.com
www.2k8618.blogspot.com
Count= 3
nn@linuxmint ~ $
// com.txt
www.2k8cs.tk
www.google.com
www.yahoo.com
www.2k8618.blogspot.com
www.2k8cse.cu.cc
// Lex file: com.l
%{
int count=0;
%}
%%
.*com\n {count++;ECHO;}
. ;
%%
main()
{
yylex();
printf("\nCount= %d\n",count);
return 0;
}
Output:
nn@linuxmint ~ $ lex com.l
nn@linuxmint ~ $ gcc lex.yy.c -ll
nn@linuxmint ~ $ ./a.out<com.txt
www.google.com
www.yahoo.com
www.2k8618.blogspot.com
Count= 3
nn@linuxmint ~ $
// com.txt
www.2k8cs.tk
www.google.com
www.yahoo.com
www.2k8618.blogspot.com
www.2k8cse.cu.cc
0 comments:
Post a Comment