fork download
  1. %{
  2. #include <stdio.h>
  3. int wc=0, cc=0, lc=0, sc=0, tc=0
  4. %}
  5.  
  6. %%
  7. [\n] { lc++; cc+=yyleng;}
  8. [ \t] { sc++; cc+=yyleng;}
  9. [^\t] { tc++; cc+=yyleng;}
  10. [^\t\n] { wc++; cc+=yyleng;}
  11. %%
  12.  
  13. yywrap(){ return 1; }
  14.  
  15. int main(){
  16. printf("Enter the Sentence : ");
  17. yylex();
  18. printf("Number of lines : %d\n",lc);
  19. printf("Number of spaces : %d\n",sc);
  20. printf("Number of tabs, words, charc : %d , %d , %d\n",tc,wc,ch);
  21. }
Success #stdin #stdout #stderr 0.03s 6828KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/ONDqHw/prog:21:0: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit