fork download
  1. %{#include<stdio.h>
  2. int chars = 0;
  3. int word = 0;
  4. int space = 0;
  5. int line = 0;
  6. %}
  7.  
  8. %%
  9. [^ \n\t]+ {word++, chars+=yyleng;}
  10. \n {line++;}
  11. \t {space++;}
  12. " " {space++;}
  13. %%
  14.  
  15. void main()
  16. {
  17. yyin=fopen("data.txt","r");
  18. yylex();
  19. printf("Statistics\n");
  20. printf("Char: %d\nWord: %d\nSpace: %d\nLine: %d\n", chars, word, space, line);
  21. }
Success #stdin #stdout #stderr 0.02s 6952KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/aMb2IF/prog:21:0: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit