%{
int positive_integers = 0;
int negative_integers = 0;
int positive_fractions = 0;
int negative_fractions = 0;
%}
%%
[+-]?[0-9]+ { if (atoi(yytext) > 0) positive_integers++;
else if (atoi(yytext) < 0) negative_integers++; }
[+-]?[0-9]+\.[0-9]+ { if (atof(yytext) > 0) positive_fractions++;
else if (atof(yytext) < 0) negative_fractions++; }
.|\n ;
%%
int main() {
yylex();
printf("Positive Integers: %d\n", positive_integers);
printf("Negative Integers: %d\n", negative_integers);
printf("Positive Fractions: %d\n", positive_fractions);
printf("Negative Fractions: %d\n", negative_fractions);
return 0;
}
JXsKaW50IHBvc2l0aXZlX2ludGVnZXJzID0gMDsKaW50IG5lZ2F0aXZlX2ludGVnZXJzID0gMDsKaW50IHBvc2l0aXZlX2ZyYWN0aW9ucyA9IDA7CmludCBuZWdhdGl2ZV9mcmFjdGlvbnMgPSAwOwolfQoKJSUKWystXT9bMC05XSsgICAgICB7IGlmIChhdG9pKHl5dGV4dCkgPiAwKSBwb3NpdGl2ZV9pbnRlZ2VycysrOyAKICAgICAgICAgICAgICAgICAgICBlbHNlIGlmIChhdG9pKHl5dGV4dCkgPCAwKSBuZWdhdGl2ZV9pbnRlZ2VycysrOyB9ClsrLV0/WzAtOV0rXC5bMC05XSsgICB7IGlmIChhdG9mKHl5dGV4dCkgPiAwKSBwb3NpdGl2ZV9mcmFjdGlvbnMrKzsKICAgICAgICAgICAgICAgICAgICAgICAgIGVsc2UgaWYgKGF0b2YoeXl0ZXh0KSA8IDApIG5lZ2F0aXZlX2ZyYWN0aW9ucysrOyB9Ci58XG4gICAgICAgICAgICAgIDsKCiUlCgppbnQgbWFpbigpIHsKICAgIHl5bGV4KCk7CiAgICBwcmludGYoIlBvc2l0aXZlIEludGVnZXJzOiAlZFxuIiwgcG9zaXRpdmVfaW50ZWdlcnMpOwogICAgcHJpbnRmKCJOZWdhdGl2ZSBJbnRlZ2VyczogJWRcbiIsIG5lZ2F0aXZlX2ludGVnZXJzKTsKICAgIHByaW50ZigiUG9zaXRpdmUgRnJhY3Rpb25zOiAlZFxuIiwgcG9zaXRpdmVfZnJhY3Rpb25zKTsKICAgIHByaW50ZigiTmVnYXRpdmUgRnJhY3Rpb25zOiAlZFxuIiwgbmVnYXRpdmVfZnJhY3Rpb25zKTsKICAgIHJldHVybiAwOwp9Cg==