2333333

%{
#include<stdio.h>
%}
%%
int|char|float|return { printf("\n%s=> Keywords",yytext);}
#.* { printf("\n%s=>Preprocessor Directive",yytext);}
printf|scanf|main { printf("\n%s=>functions",yytext);}
["][a-z]+["] { printf("\n%s=>Strings",yytext);}
[[a-z]|[A-Z]][[a-z]|[A-Z]|[0-9]]+ { printf("\n%s=>Identifiers",yytext);}
[0-9] { printf("\n%s=>Numbers",yytext);}
"+"|"-"|"*"|"/"|"%" { printf("\n%s=>Operators",yytext);}
","|";"|"&"|"("|")"| [" ] |"{"|"}" { printf("\n%s=>Special Characters",yytext);}
%%
int main()
{
FILE *fp;
fp=fopen("input.txt","r");
yyin=fp;
yylex();
return 0;
}
int yywrap()
{
return 1;
}

Popular posts from this blog

Ads

4a Reading data from Textfile

Execute Basic Numpy operations