5. Lex program to count the number of identifiers

 

Lex program to count the number of identifiers


//Lex program to count the number of identifiers
%{#include<iostream.h>
int count=0;
char ch=0;
%}
digit[0-9]
letter[a-zA-Z_]

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

%%
int main()
{
 yylex();
 printf("count: %d",count);
 return 0;
} 
 
// Output of the above Program
Lex program to count the number of identifiers
Lex program to count the number of identifiers

Comments

Popular posts from this blog

Compiler Design

3. Lex program to find the length of the longest word

6. Lex program to count the number of words,small and capital letters, digits and special characters in a C file