/* 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;
}
LyogREVTQ1JJUFRJT04vREVGSU5JVElPTiBTRUNUSU9OICovCiV7CiNpbmNsdWRlPHN0ZGlvLmg+CmludCBsYz0wLHNjPTAsdGM9MCxjaD0wLHdjPTA7CSAvLyBHTE9CQUwgVkFSSUFCTEVTCiV9CgovLyBSVUxFIFNFQ1RJT04KJSUKW1xuXSB7IGxjKys7IGNoKz15eWxlbmc7fQpbIFx0XSB7IHNjKys7IGNoKz15eWxlbmc7fQpbXlx0XSB7IHRjKys7IGNoKz15eWxlbmc7fQpbXlx0XG4gXSsgeyB3YysrOyBjaCs9eXlsZW5nO30gCiUlCgppbnQgeXl3cmFwKCl7IHJldHVybiAxOyB9Ci8qCSBBZnRlciBpbnB1dHRpbmcgcHJlc3MgY3RybCtkCQkgKi8KCi8vIE1BSU4gRlVOQ1RJT04KaW50IG1haW4oKXsKCXByaW50ZigiRW50ZXIgdGhlIFNlbnRlbmNlIDogIik7Cgl5eWxleCgpOwoJcHJpbnRmKCJOdW1iZXIgb2YgbGluZXMgOiAlZFxuIixsYyk7CglwcmludGYoIk51bWJlciBvZiBzcGFjZXMgOiAlZFxuIixzYyk7CglwcmludGYoIk51bWJlciBvZiB0YWJzLCB3b3JkcywgY2hhcmMgOiAlZCAsICVkICwgJWRcbiIsdGMsd2MsY2gpOwoJCglyZXR1cm4gMDsKfQo=