%{
#include <stdio.h>
int line_count = 0;
int space_count = 0;
int tab_count = 0;
int other_char_count = 0;
%}
%%
\n { line_count++; } /* Increment line count */
\t { tab_count++; } /* Increment tab count */
" " { space_count++; } /* Increment space count */
. { other_char_count++; } /* Increment other character count */
%%
int main() {
printf("Enter input :\n");
yylex();
printf("Lines: %d\n", line_count);
printf("Spaces: %d\n", space_count);
printf("Tabs: %d\n", tab_count);
printf("Other Characters: %d\n", other_char_count);
return 0;
}
int yywrap() {
return 1;
}
JXsKI2luY2x1ZGUgPHN0ZGlvLmg+CmludCBsaW5lX2NvdW50ID0gMDsKaW50IHNwYWNlX2NvdW50ID0gMDsKaW50IHRhYl9jb3VudCA9IDA7CmludCBvdGhlcl9jaGFyX2NvdW50ID0gMDsKJX0KCiUlClxuICAgICAgICAgICAgeyBsaW5lX2NvdW50Kys7IH0gICAgICAgIC8qIEluY3JlbWVudCBsaW5lIGNvdW50ICovClx0ICAgICAgICAgICAgeyB0YWJfY291bnQrKzsgfSAgICAgICAgIC8qIEluY3JlbWVudCB0YWIgY291bnQgKi8KIiAiICAgICAgICAgIHsgc3BhY2VfY291bnQrKzsgfSAgICAgIC8qIEluY3JlbWVudCBzcGFjZSBjb3VudCAqLwouICAgICAgICAgICAgeyBvdGhlcl9jaGFyX2NvdW50Kys7IH0gIC8qIEluY3JlbWVudCBvdGhlciBjaGFyYWN0ZXIgY291bnQgKi8KJSUKaW50IG1haW4oKSB7CiAgICBwcmludGYoIkVudGVyIGlucHV0IDpcbiIpOwogICAgeXlsZXgoKTsKICAgIHByaW50ZigiTGluZXM6ICVkXG4iLCBsaW5lX2NvdW50KTsKICAgIHByaW50ZigiU3BhY2VzOiAlZFxuIiwgc3BhY2VfY291bnQpOwogICAgcHJpbnRmKCJUYWJzOiAlZFxuIiwgdGFiX2NvdW50KTsKICAgIHByaW50ZigiT3RoZXIgQ2hhcmFjdGVyczogJWRcbiIsIG90aGVyX2NoYXJfY291bnQpOwogICAgcmV0dXJuIDA7Cn0KaW50IHl5d3JhcCgpIHsKICAgIHJldHVybiAxOwp9Cgo=