fork download
  1. %{
  2. #include <stdio.h>
  3. #include <ctype.h>
  4.  
  5. int line_count = 0;
  6. int word_count = 0;
  7. int letter_count = 0;
  8. int special_count = 0;
  9. %}
  10.  
  11. %%
  12.  
  13. \n { line_count++; }
  14. [[:alpha:]]+ { word_count++; letter_count += yyleng; }
  15. [^a-zA-Z0-9\n\t\s] { special_count++; }
  16.  
  17. %%
  18.  
  19. int main() {
  20. yylex(); // Start scanning input
  21. printf("Lines: %d\n", line_count);
  22. printf("Words: %d\n", word_count);
  23. printf("Letters: %d\n", letter_count);
  24. printf("Special characters: %d\n", special_count);
  25. return 0;
  26. }
  27.  
Success #stdin #stdout #stderr 0.02s 6896KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/SRxJAk/prog:26:1: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit