PROGRAM TO RECOGNIZE A STRING WITH THREE COSECUTIVE 0’s
Algorithm:-
begin
if string=[0-9]*000[0-9]*
then
printf “Algorithm:-
string accepted”
else
printf “string rejected”
end
Program:-
LEX program to recognize a string with three consecutive 0’s
%%
[0-9]*000[0-9]* { printf(“string accepted”);}
[0-9]* { printf(“string rejected”);}
%%
main()
{
yylex();
}\
int yywrap()
{
return 1;
}
OUTPUT:
$./a.out
345000
string accepted
34560
String is rejected