Lex program for recognizing character, digit or any special character
%{
#include<stdio.h>
%}
%%
[a-z A-Z] {printf("%s-charcter \n ",yytext);}
[0-9] {printf("%s-digit \n ",yytext);}
[^a-zA-Z0-9] {printf("%s-special charcter \n ",yytext);} //not starting with
%%
int yywrap() //this functional is optional
{
return(1);
}
int main()
{
yylex();
return 0;
}
#include<stdio.h>
%}
%%
[a-z A-Z] {printf("%s-charcter \n ",yytext);}
[0-9] {printf("%s-digit \n ",yytext);}
[^a-zA-Z0-9] {printf("%s-special charcter \n ",yytext);} //not starting with
%%
int yywrap() //this functional is optional
{
return(1);
}
int main()
{
yylex();
return 0;
}
Comments
Post a Comment