fork download
  1. %{
  2. #include<stdio.h>
  3. int tw=0, tc=0, ts=0;
  4. %}
  5.  
  6. %%
  7. [a-zA-Z0-9]+ { tw++; tc+= yyleng(); }
  8. [ \t\n] { ts++; tc++; }
  9. . { tc++; }
  10. %%
  11.  
  12. int main()
  13. {
  14. yyin=fopen("input.txt","r");
  15. yylex();
  16. printf("Total words in file: %d", tw);
  17. printf("Total characters in file: %d", tc);
  18. printf("Total space in file: %d", ts);
  19. fclose(file);
  20. return 0;
  21. }
Success #stdin #stdout #stderr 0.03s 6948KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/YxMqCy/prog:2:1: Syntax error: Operator expected
ERROR: /home/YxMqCy/prog:21:0: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit