%{
#include <stdio.h>
%}

%%

"auto"|"break"|"case"|"char"|"const"|"continue"|"default"|"do"|"double"|"else"|"enum"|"extern"|"float"|"for"|"goto"|"if"|"inline"|"int"|"long"|"register"|"restrict"|"return"|"short"|"signed"|"sizeof"|"static"|"struct"|"switch"|"typedef"|"union"|"unsigned"|"void"|"volatile"|"while"  { printf("Keyword: %s\n", yytext); }

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

[0-9]+                  { printf("Integer Literal: %s\n", yytext); }
[0-9]+"."[0-9]+         { printf("Float Literal: %s\n", yytext); }
\"(\\.|[^\\"])*\"       { printf("String Literal: %s\n", yytext); }
\'.\'                   { printf("Character Literal: %s\n", yytext); }

"=="|"!="|"<="|">="|"<"|">" { printf("Relational Operator: %s\n", yytext); }
"="|"+"|"-"|"*"|"/"|"%"     { printf("Arithmetic Operator: %s\n", yytext); }
"&&"|"||"|"!"              { printf("Logical Operator: %s\n", yytext); }
"&"|"|"|"^"|"<<"|">>"      { printf("Bitwise Operator: %s\n", yytext); }

"(" | ")" | "{" | "}" | "[" | "]" | ";" | ","  { printf("Special Symbol: %s\n", yytext); }

"//".*                   { printf("Single-line Comment\n"); }
"/*"([^*]|[\r\n]|"*"[^/])*"*/"  { printf("Multi-line Comment\n"); }

[ \t\n]+                 /* Ignore whitespace */

.                        { printf("Unknown Token: %s\n", yytext); }

%%

int main() {
    yylex();
    return 0;
}

int yywrap() {
    return 1;
}