%{
#include <stdio.h>

int word_count = 0;      // To count the number of words
int char_count = 0;      // To count the number of characters
int line_count = 0;      // To count the number of lines
%}

%%

\n              { line_count++; }   // Increment line count on newline
[ \t]+          { /* Ignore spaces and tabs */ }
[A-Za-z0-9]+    { word_count++; char_count += yyleng; }  // Count words and characters
.               { char_count++; }   // Count other characters (including punctuation)

%%

int main() {
    yylex();
    printf("Lines: %d\n", line_count);
    printf("Words: %d\n", word_count);
    printf("Characters: %d\n", char_count);
    return 0;
}
