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