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