Lex Program to Identify the Type of Number [Compiler]
This is the lex program to identify the type of number using regular expressions
%{
#include<stdio.h>
int a=0,b=0,c=0,d=0;
%}
%%
[+]?[0-9]+ {printf("Postive Integer %d",a);a++;}
[-]{1}[0-9]+ {printf("Negative Integer %d",b);b++;}
[+]?[0-9]+[.]{1}[0-9]+ {printf("Postive Fraction %d",c);c++;}
[-]?[0-9]+[.]{1}[0-9]+ {printf("Negative Fraction %d",d);d++;}
%%
main(){yylex();}
Recent Comments