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

const char *keywords[] = {"int", "float", "if", "else", "for", "while", "return", "void"};
const int num_keywords = sizeof(keywords) / sizeof(keywords[0]);

void check_keyword(char *word) {
    for (int i = 0; i < num_keywords; i++) {
        if (strcmp(word, keywords[i]) == 0) {
            printf("Keyword: %s\n", word);
            return;
        }
    }
    printf("Identifier: %s\n", word);
}
%}

%%
// Operators
[+\-*/%=<>!]            { printf("Operator: %s\n", yytext); }
[ \t\n]                  { /* Ignore whitespace */ }
[a-zA-Z_][a-zA-Z0-9_]*   { check_keyword(yytext); }
.                        { printf("Enter a valid input.\n"); }

%% 

int main() {
    yylex(); // Start the scanning process
    return 0;
}
