%{
#include<stdio.h>
%}
%%
[a-z]* printf("matched
string %s and length is %d",yytext,yyleng);
.* printf("%s
invalid",yytext);
%%
int yywrap()
{
return 1;
}
main()
{
FILE *fp;
fp=fopen("text.txt","r");
if(fp==NULL)
{
printf("file not found");
}
yyin=fp;
yylex();
fclose(fp);
}
ScreenShot:
No comments:
Post a Comment