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