Lex program to count the number of identifiers

//Lex program to count the number of identifiers


%{
#include<iostream.h>
int count_identifiers=0;
%}
digit[0-9]
letter[a-zA-Z_]

%%
{letter}({letter}|{digit})* {
 count_identifiers++;
}

%%
int main()
{
 yylex();
 printf("count: %d",count_identifiers);
 return 0;

output:


No comments:

Post a Comment

Featured post

Amazon Interview Process

On July 5, 1994, Jeff Bezos started the world's most "customer-centric" firm out of his garage in Bellevue, Washington. The A...