%{
#include <stdio.h>
#include <string.h>
#include <ctype.h>

char str[256];
%}

%%

[a-zA-Z]+   { strcpy(str, yytext); }

\n          {
                int i = 0;
                int j = strlen(str) - 1;
                int is_palindrome = 1;

                while (i < j) {
                    if (tolower(str[i]) != tolower(str[j])) {
                        is_palindrome = 0;
                        break;
                    }
                    i++;
                    j--;
                }

                if (is_palindrome)
                    printf("\"%s\" IS a palindrome.\n", str);
                else
                    printf("\"%s\" is NOT a palindrome.\n", str);
            }

.           { /* ignore other characters */ }

%%

int main(void) {
    printf("Enter a string: ");
    yylex();
    return 0;
}

int yywrap(void) {
    return 1;
}