/* DESCRIPTION/DEFINITION SECTION */
%{
#include<stdio.h>
int lc=0,sc=0,tc=0,ch=0,wc=0; // GLOBAL VARIABLES
%}
// RULE SECTION
%%
[\n] { lc++; ch+=yyleng;}
[ \t] { sc++; ch+=yyleng;}
[^\t] { tc++; ch+=yyleng;}
[^\t\n ]+ { wc++; ch+=yyleng;}
%%
int yywrap(){ return 1; }
/* After inputting press ctrl+d */
// MAIN FUNCTION
int main(){
printf("Enter the Sentence : ");
yylex();
printf
("
Number of lines
: %d\n",lc); printf
("
Number of spaces
: %d\n",sc); printf
("
Number of tabs
, words
, charc
: %d , %d , %d\n",tc,wc,ch);
return 0;
}
IC8qIERFU0NSSVBUSU9OL0RFRklOSVRJT04gU0VDVElPTiAqLwolewojaW5jbHVkZTxzdGRpby5oPgppbnQgbGM9MCxzYz0wLHRjPTAsY2g9MCx3Yz0wOwkgLy8gR0xPQkFMIFZBUklBQkxFUwolfQoKLy8gUlVMRSBTRUNUSU9OCiUlCltcbl0geyBsYysrOyBjaCs9eXlsZW5nO30KWyBcdF0geyBzYysrOyBjaCs9eXlsZW5nO30KW15cdF0geyB0YysrOyBjaCs9eXlsZW5nO30KW15cdFxuIF0rIHsgd2MrKzsgY2grPXl5bGVuZzt9IAolJQoKaW50IHl5d3JhcCgpeyByZXR1cm4gMTsgfQovKgkgQWZ0ZXIgaW5wdXR0aW5nIHByZXNzIGN0cmwrZAkJICovCgovLyBNQUlOIEZVTkNUSU9OCmludCBtYWluKCl7CglwcmludGYoIkVudGVyIHRoZSBTZW50ZW5jZSA6ICIpOwoJeXlsZXgoKTsKCXByaW50ZigiTnVtYmVyIG9mIGxpbmVzIDogJWRcbiIsbGMpOwoJcHJpbnRmKCJOdW1iZXIgb2Ygc3BhY2VzIDogJWRcbiIsc2MpOwoJcHJpbnRmKCJOdW1iZXIgb2YgdGFicywgd29yZHMsIGNoYXJjIDogJWQgLCAlZCAsICVkXG4iLHRjLHdjLGNoKTsKCQoJcmV0dXJuIDA7Cn0KCg==