%{ 
#include <stdio.h> 
%} 
 
/* Definitions */ 
DIGIT   [0-9] 
ID      [a-zA-Z][a-zA-Z0-9]* 
 
%% 
/* Rules Section */ 
 
/* Keywords */ 
int|float|char|if|else|while|for|return 
                { printf("Keyword        : %s\n", yytext); } 
 
/* Identifiers */ 
{ID}            { printf("Identifier     : %s\n", yytext); } 
 
/* Floating Numbers */ 
{DIGIT}+\.{DIGIT}+  
                { printf("Float Number   : %s\n", yytext); } 
 
/* Integers */ 
{DIGIT}+        { printf("Integer        : %s\n", yytext); } 
 
/* Increment & Decrement */ 
"++"            { printf("Increment Op   : ++\n"); } 
"--"            { printf("Decrement Op   : --\n"); } 
 
/* Operators */ 
"+"|"-"|"*"|"/"|"="|"%"  
                { printf("Operator       : %s\n", yytext); } 
 
/* Special Symbols */ 
"(" | ")" | "{" | "}" | ";" | ","  
                { printf("Special Symbol : %s\n", yytext); } 
/* Ignore spaces and tabs */ 
[ \t\n]+        
; 
/* Any other character */ 
.               
{ printf("Unknown        :%s\n",yytext);}
%% 
int main() { 
printf("Enter input:\n"); 
yylex(); 
return 0; 
} 
int yywrap() { 
return 1; 
} 