%{
#include <stdio.h>
#include <ctype.h>
int vowel_count = 0;
int consonant_count = 0;
%}
%%
[aeiouAEIOU] { vowel_count++; }
[b-df-hj-np-tv-zB-DF-HJ-NP-TV-Z] { consonant_count++; }
. { /* Ignore other characters */ }
%%
int main(void) {
yylex(); // Start scanning
printf("Total vowels: %d\n", vowel_count);
printf("Total consonants: %d\n", consonant_count);
return 0;
}
void yyerror(char *s) {
fprintf(stderr, "Error: %s\n", s);
}
/*
output:
Hello World
Total vowels: 3
Total consonants: 7
*/
JXsKI2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxjdHlwZS5oPgoKaW50IHZvd2VsX2NvdW50ID0gMDsKaW50IGNvbnNvbmFudF9jb3VudCA9IDA7CiV9CgolJQpbYWVpb3VBRUlPVV0gICAgIHsgdm93ZWxfY291bnQrKzsgfQpbYi1kZi1oai1ucC10di16Qi1ERi1ISi1OUC1UVi1aXSB7IGNvbnNvbmFudF9jb3VudCsrOyB9Ci4gICAgICAgICAgICAgICAgeyAvKiBJZ25vcmUgb3RoZXIgY2hhcmFjdGVycyAqLyB9CgolJQoKaW50IG1haW4odm9pZCkgewogICAgeXlsZXgoKTsgIC8vIFN0YXJ0IHNjYW5uaW5nCiAgICBwcmludGYoIlRvdGFsIHZvd2VsczogJWRcbiIsIHZvd2VsX2NvdW50KTsKICAgIHByaW50ZigiVG90YWwgY29uc29uYW50czogJWRcbiIsIGNvbnNvbmFudF9jb3VudCk7CiAgICByZXR1cm4gMDsKfQoKdm9pZCB5eWVycm9yKGNoYXIgKnMpIHsKICAgIGZwcmludGYoc3RkZXJyLCAiRXJyb3I6ICVzXG4iLCBzKTsKfQoKCi8qCm91dHB1dDoKSGVsbG8gV29ybGQKClRvdGFsIHZvd2VsczogMwpUb3RhbCBjb25zb25hbnRzOiA3Ciov