Student Seminar Report & Project Report With Presentation (PPT,PDF,DOC,ZIP)

Full Version: Program in “LEX” to count number of Identifiers and Keywords
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Objective
Program in “LEX” to count number of Identifiers and Keywords.


digit[0-9]
letter[A-Za-z]
Code:
%{
int count1=0;
int count2=0;
%}
%%
intI
floatI
char      {count++;printf("%s is keyword",yytext);}
{letter}I({letter}I{digit})*{count2++;}
[a-zA-Z]+ {printf("%s is not keyword",yytext);}
.I\n {ECHO;}
%%
main()
{
yylex();
printf("%d no of keyword %d no of id",count1,count2);
}

Guest

fprintf(file,"\t\t\t");
sprintf(buffer, "%d", sum);
fprintf(file,buffer);