%{
#include<stdio.h>
%}
%%
/*** Rules section ***/
[-0-9]*
{
printf("Integer Value");
}
^[-|0-9][0-9]+(.)[0-9]+
{
printf("Float Value");
}
[-0-9]*(.)[0-9]+(E)[-0-9]+
{
printf("Exponential Value");
}
.*
{
printf("Invalid value");
}
%%
int
main()
{
FILE *fp;
fp = fopen("test1.txt",
"r");
if (fp == NULL) { printf("File not
found"); }
yyin = fp;
yylex();
return 0;
}
ScreenShot:
No comments:
Post a Comment