Hi I am new to lex and have been trying to write a program to extract identifiers. But it shows error on line 9
{id} {printf("%s:IDENTIFIER",yytext);}
"unrecognized rule" Here is the code:
%{
#include<stdio.h>
%}
digit [0-9]
letter [a-zA-Z]
id {letter}{letter|digit}*
%%
{id} {printf("%s:IDENTIFIER",yytext);}
%%
int main()
{
yylex();
return 0;
}
I have seen other questions also but could find the error in this code.Please help.