Identifying words of length 4-8 characters long.

%{
#include<stdio.h.>
int a=0;
%}

%%
[a-zA-Z0-9._]+ {a=yyleng; if(a==4||a==5||a==6||a==7||a==8) printf("Word accepted");}
%%

main()
{
yylex();
}

Comments

Popular posts from this blog

A program to find FIRST of non-terminals of the given grammar

Desk Calculator

Write a context free grammar for structure of a english sentence, where a pronoun is followed by a verb and verb is followed by determiner. Determiner is followed by noun and noun can be followed by noun. Statement can begin with noun or a proper noun. **following program is written for example sentence"I prefer a morning flight from New Delhi".