identify a sentence and return the length of each word.

%{
int a=0;
int a2;
%}
%%
" " {a++;}
[a-zA-Z]+ {printf("word: %s \t\t letters in the word: %d\n",yytext,yyleng);}
%%
main()
{
yylex();
a=a+1;
printf("Sentence lenght: %d",a);
}

Comments

Popular posts from this blog

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

Implementation of Symbol Table

Desk Calculator