fork download
  1. %{
  2. #include<stdio.h>
  3. int lc=0, sc=0, wc=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. printf("NO. of words are: %d\n",wc);
  17. printf("NO. of Characters are: %d\n",cc);
  18. printf("NO. of new lines are: %d\n",lc);
  19. printf("NO. of spaces are: %d\n",sc);
  20. }
  21.  
  22. int yywrap()
  23. {
  24. return 1;
  25. }
  26.  
Success #stdin #stdout #stderr 0.02s 6924KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/hbrYd0/prog:25:1: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit