896+ Capstone Project is Available: Whatsapp: +91-7011258995, Email: sharecodepoint@gmail.com

Program to recognize and count the number of identifiers in a given input file. | Compiler Design Lab Programs


Compiler Design Lap Program :

%{
 #include<stdio.h>
 int id=0;
%}
%%
[a-zA-Z][a-zA-Z0-9_]* { id++ ; ECHO; printf(“\n”);}
.+ { ;}
\n { ;}
%%
int yywrap()
{
return 1;
}
main (int argc, char *argv[])
{
 if(argc!=2)
 {
 printf(“Usage: <./a.out> <sourcefile>\n”);
 exit(0);
 }
 yyin=fopen(argv[1],”r”);
 printf(“Valid identifires are\n”);
 yylex();
 printf(“No of identifiers = %d\n”,id);

Sharecodepoint

Sharecodepoint is the junction where every essential thing is shared for college students in the well-defined packets of codes. We are focused on providing you the best material package like Question papers, MCQ'S, and one NIGHT STUDY MATERIAL. facebook twitter youtube instagram

Post a Comment

Previous Post Next Post

Contact Form