Sunday 24 April 2016

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

1 comment: