Finding the number of operators in a given C file
%{
#include<stdio.h>
int a;
FILE **yyin;
%}
%%
[+*/-] {a++;}
%%
main()
{
yyin=fopen("operators.txt","r"); //file name of a C file
yylex();
printf("No. of operators are: %d",a);
}
#include<stdio.h>
int a;
FILE **yyin;
%}
%%
[+*/-] {a++;}
%%
main()
{
yyin=fopen("operators.txt","r"); //file name of a C file
yylex();
printf("No. of operators are: %d",a);
}
Comments
Post a Comment