fork download
  1. %{
  2. #include<stdio.h>
  3. int lc=0, tc=0, sc=0, cc=0;
  4. %}
  5.  
  6. %%
  7.  
  8. \n { lc++; }
  9. \t { tc++; }
  10. " " { sc++; }
  11. [^\n\t ] { cc++; }
  12.  
  13. %%
  14.  
  15. int yywrap() {
  16. return 1;
  17. }
  18.  
  19. int main() {
  20. printf("Enter text (Ctrl+D to end input):\n");
  21. yylex();
  22.  
  23. printf("The number of lines: %d\n", lc);
  24. printf("The number of blank spaces: %d\n", sc);
  25. printf("The number of tabs: %d\n", tc);
  26. printf("The number of other characters: %d\n", cc);
  27.  
  28. return 0;
  29. }
  30.  
Success #stdin #stdout #stderr 0.03s 6924KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/v2Ccwu/prog:29:1: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit