%{
#include <stdio.h>
#include <string.h>
char targetWord[] = "jai";
int wordPosition = 0;
%}
%%
[a-zA-Z]+ {
if (strcmp(yytext, targetWord) == 0) {
printf("Found '%s' at position %d.\n", yytext, wordPosition);
}
wordPosition++;
}
[ \t\n]+ ;
. {
}
%%
int main() {
printf("Enter a sentence: ");
yylex();
return 0;
}
int yywrap()
{
return 1;
}
JXsKI2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdHJpbmcuaD4KCmNoYXIgdGFyZ2V0V29yZFtdID0gImphaSI7CmludCB3b3JkUG9zaXRpb24gPSAwOyAgICAgICAgCiV9CgolJQoKW2EtekEtWl0rIHsKICAgIGlmIChzdHJjbXAoeXl0ZXh0LCB0YXJnZXRXb3JkKSA9PSAwKSB7CiAgICAgICAgcHJpbnRmKCJGb3VuZCAnJXMnIGF0IHBvc2l0aW9uICVkLlxuIiwgeXl0ZXh0LCB3b3JkUG9zaXRpb24pOwogICAgfQogICAgd29yZFBvc2l0aW9uKys7Cn0KClsgXHRcbl0rIDsKCi4gewogICAKfQoKJSUKCmludCBtYWluKCkgewogICAgcHJpbnRmKCJFbnRlciBhIHNlbnRlbmNlOiAiKTsKICAgIHl5bGV4KCk7CiAgICByZXR1cm4gMDsKfQoKCmludCB5eXdyYXAoKQp7CiAgICByZXR1cm4gMTsgIAp9