Friday, April 12, 2019

Lex program to recognize identifiers in C (" ▪ It should start with either letter or underscore (_) sign. ▪ It should not contain special symbols. ")


%{
#include<stdio.h>
%}
%%
^[a-zA-Z_][_a-zA-Z0-9]+ {printf("Identifier\n");}
.* {printf("Not a Identifier\n");}
%%
main()
{
yylex();
}
ScreenShot:

No comments:

Post a Comment