%{
#include<stdio.h>
int w=0; // Word count
int l=0; // Line count
int t=0; // Tab count
int c=0; // Character count
int s=0; // Space count
%}
%%
[\n]+ { l++; } // Count newlines (lines)
[0-9]+ { n++; } // Count numbers
[a-zA-Z]+ { w++; } // Count words (sequences of alphabetic characters)
[ \t]+ { t++; s++; } // Count spaces and tabs (combining space and tab counting)
. { c++; } // Count any other character (including spaces, punctuation, etc.)
%%
int main() {
yylex(); // Start lexing the input
printf("no. of words: %d\n", w);
printf("no. of numbers: %d\n", n);
printf("no. of lines: %d\n", l);
printf("no. of tabs are: %d\n", t);
printf("total no. of characters are: %d\n", c);
printf("total spaces in input are: %d\n", s);
return 0;
}
JXsKI2luY2x1ZGU8c3RkaW8uaD4KaW50IHc9MDsgIC8vIFdvcmQgY291bnQKaW50IG49MDsgIC8vIE51bWJlciBjb3VudAppbnQgbD0wOyAgLy8gTGluZSBjb3VudAppbnQgdD0wOyAgLy8gVGFiIGNvdW50CmludCBjPTA7ICAvLyBDaGFyYWN0ZXIgY291bnQKaW50IHM9MDsgIC8vIFNwYWNlIGNvdW50CiV9CgolJQoKW1xuXSsgICAgIHsgbCsrOyB9ICAvLyBDb3VudCBuZXdsaW5lcyAobGluZXMpClswLTldKyAgICB7IG4rKzsgfSAgLy8gQ291bnQgbnVtYmVycwpbYS16QS1aXSsgeyB3Kys7IH0gIC8vIENvdW50IHdvcmRzIChzZXF1ZW5jZXMgb2YgYWxwaGFiZXRpYyBjaGFyYWN0ZXJzKQpbIFx0XSsgICAgeyB0Kys7IHMrKzsgfSAvLyBDb3VudCBzcGFjZXMgYW5kIHRhYnMgKGNvbWJpbmluZyBzcGFjZSBhbmQgdGFiIGNvdW50aW5nKQouICAgICAgICAgeyBjKys7IH0gIC8vIENvdW50IGFueSBvdGhlciBjaGFyYWN0ZXIgKGluY2x1ZGluZyBzcGFjZXMsIHB1bmN0dWF0aW9uLCBldGMuKQoKJSUKCmludCBtYWluKCkgewogICAgeXlsZXgoKTsgIC8vIFN0YXJ0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