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