%{
#include <stdio.h>
%}

%%
"int"|"float"|"if"|"else"|"while"|"for"|"return"|"char"|"double"   { printf("%s : Keyword\n", yytext); }

[a-zA-Z_][a-zA-Z0-9_]*     { printf("%s : Identifier\n", yytext); }

[0-9]+                     { printf("%s : Constant\n", yytext); }

"+"|"-"|"*"|"/"|"="|"<"|">"    { printf("%s : Operator\n", yytext); }

"//".*                     { printf("%s : Comment (Single-line)\n", yytext); }

[ \t\n]                    { /* ignore spaces */ }

.                          { printf("%s : Special Character\n", yytext); }
%%

int main() {
    printf("Enter your code (press Ctrl+D to end):\n");
    yylex();
    return 0;
}
