%{
#include <stdio.h>
int word_count = 0;
int line_count = 0;
%}
%%
\n { line_count++; }
[^\t\n ]+ { word_count++; }
. { }
%%
int main() {
printf("Enter your text (Press Ctrl+D on Linux/Mac or Ctrl+Z on Windows to finish):\n");
yylex();
printf("\n--- Result Summary ---\n");
printf("Total Words: %d\n", word_count);
printf("Total Lines: %d\n", line_count);
return 0;
}
int yywrap() {
return 1;
}
JXsKI2luY2x1ZGUgPHN0ZGlvLmg+CgppbnQgd29yZF9jb3VudCA9IDA7CmludCBsaW5lX2NvdW50ID0gMDsKJX0KCiUlClxuICAgICAgICAgIHsgbGluZV9jb3VudCsrOyB9ICAgICAgICAgICAgICAgICAgICAKW15cdFxuIF0rICAgeyB3b3JkX2NvdW50Kys7IH0gICAgICAgICAgCi4gICAgICAgICAgIHsgIH0KJSUKCmludCBtYWluKCkgewogICAgcHJpbnRmKCJFbnRlciB5b3VyIHRleHQgKFByZXNzIEN0cmwrRCBvbiBMaW51eC9NYWMgb3IgQ3RybCtaIG9uIFdpbmRvd3MgdG8gZmluaXNoKTpcbiIpOwogICAgeXlsZXgoKTsKICAgIAogICAgcHJpbnRmKCJcbi0tLSBSZXN1bHQgU3VtbWFyeSAtLS1cbiIpOwogICAgcHJpbnRmKCJUb3RhbCBXb3JkczogJWRcbiIsIHdvcmRfY291bnQpOwogICAgcHJpbnRmKCJUb3RhbCBMaW5lczogJWRcbiIsIGxpbmVfY291bnQpOwogICAgCiAgICByZXR1cm4gMDsKfQoKaW50IHl5d3JhcCgpIHsKICAgIHJldHVybiAxOwp9