Wednesday, July 27, 2011

Recognize (0+1)*000(0+1)*

Share Orkut


%{
#include <stdio.h>
int count=0;
%}
str     [0-1]*"000"[0-1]*
err     [a-zA-Z0-9]+
%%
{str} {    count++; }
{err}
%%
int main()
{
       yylex();
       printf("The pattern (0+1)*000(0+1)* found %d times \n",count);
}
int yywrap()
{
       return 1;
}

No comments:

Post a Comment