download flex from
http://www.monmouth.com/~wstreett/lex-yacc/flex.exe
write a lex program and save it as prg1.lex
%{
// lex program to identify a given string is NUMBER or WORD
%}
%%
[0-9]+ printf("%s is NUMBER\n",yytext);
[a-zA-Z]+ printf("%s is WORD\n",yytext);
.* printf("%s is NOT a WORD or NUMBER",yytext);
%%
main()
{
yylex();
}
int yywrap()
{
return 1;
}
save the downloaded flex.exe and prg1.l in D:\LEX


No comments:
Post a Comment