%{
// Declare variables to count lines and characters
int line_count = 0;
int char_count = 0;
%}
%%
\n { line_count++; char_count++; } // Increment both line and character count for new lines
. { char_count++; } // Increment character count for any character
%%
int main() {
// Call the Lex
-generated function yylex
() to start processing the input
yylex();
// After processing, print the results
printf
("
Number of lines
: %d\n", line_count); printf
("
Number of characters
: %d\n", char_count);
return 0;
}
int yywrap() {
return 1;
}
JXsKICAgIC8vIERlY2xhcmUgdmFyaWFibGVzIHRvIGNvdW50IGxpbmVzIGFuZCBjaGFyYWN0ZXJzCiAgICBpbnQgbGluZV9jb3VudCA9IDA7CiAgICBpbnQgY2hhcl9jb3VudCA9IDA7CiV9CgolJQpcbiAgICAgICAgICAgICAgeyBsaW5lX2NvdW50Kys7IGNoYXJfY291bnQrKzsgfSAgLy8gSW5jcmVtZW50IGJvdGggbGluZSBhbmQgY2hhcmFjdGVyIGNvdW50IGZvciBuZXcgbGluZXMKLiAgICAgICAgICAgICAgIHsgY2hhcl9jb3VudCsrOyB9ICAgICAgICAgICAgICAgLy8gSW5jcmVtZW50IGNoYXJhY3RlciBjb3VudCBmb3IgYW55IGNoYXJhY3RlcgolJQoKaW50IG1haW4oKSB7CiAgICAvLyBDYWxsIHRoZSBMZXgtZ2VuZXJhdGVkIGZ1bmN0aW9uIHl5bGV4KCkgdG8gc3RhcnQgcHJvY2Vzc2luZyB0aGUgaW5wdXQKICAgIHl5bGV4KCk7CiAgICAKICAgIC8vIEFmdGVyIHByb2Nlc3NpbmcsIHByaW50IHRoZSByZXN1bHRzCiAgICBwcmludGYoIk51bWJlciBvZiBsaW5lczogJWRcbiIsIGxpbmVfY291bnQpOwogICAgcHJpbnRmKCJOdW1iZXIgb2YgY2hhcmFjdGVyczogJWRcbiIsIGNoYXJfY291bnQpOwogICAgCiAgICByZXR1cm4gMDsKfQoKaW50IHl5d3JhcCgpIHsKICAgIHJldHVybiAxOwp9Cg==