%{
/* Declarations */
int wordCount = 0;
int lineCount = 0;
%}
%%
[a-zA-Z]+ { wordCount++; } /* Count words */
\n { lineCount++; } /* Count newlines */
. ; /* Ignore all other characters */
%%
int main() {
yylex();
printf
("
Number of words
: %d\n", wordCount); printf
("
Number of lines
: %d\n", lineCount); return 0;
}
int yywrap() {
return 1;
}
JXsKLyogRGVjbGFyYXRpb25zICovCmludCB3b3JkQ291bnQgPSAwOwppbnQgbGluZUNvdW50ID0gMDsKJX0KCiUlClthLXpBLVpdKyAgICB7IHdvcmRDb3VudCsrOyB9ICAgIC8qIENvdW50IHdvcmRzICovClxuICAgICAgICAgICB7IGxpbmVDb3VudCsrOyB9ICAgIC8qIENvdW50IG5ld2xpbmVzICovCi4gICAgICAgICAgICA7ICAgICAgICAgICAgICAgICAgIC8qIElnbm9yZSBhbGwgb3RoZXIgY2hhcmFjdGVycyAqLwoKJSUKaW50IG1haW4oKSB7CiAgICB5eWxleCgpOwogICAgcHJpbnRmKCJOdW1iZXIgb2Ygd29yZHM6ICVkXG4iLCB3b3JkQ291bnQpOwogICAgcHJpbnRmKCJOdW1iZXIgb2YgbGluZXM6ICVkXG4iLCBsaW5lQ291bnQpOwogICAgcmV0dXJuIDA7Cn0KCmludCB5eXdyYXAoKSB7CiAgICByZXR1cm4gMTsKfQ==