fork download
  1. %{
  2. #include <stdio.h>
  3. int char_count = 0;
  4. int word_count = 0;
  5. int space_count = 0;
  6. %}
  7.  
  8. %%
  9.  
  10. [ \t\n]+ { space_count += yyleng; char_count += yyleng; }
  11. [^ \t\n]+ { word_count++; char_count += yyleng; }
  12.  
  13. %%
  14.  
  15. int main() {
  16. yylex();
  17. printf("The number of total characters in the given input file\nis: %d\n", char_count);
  18. printf("The number of total words in the given input file is: %d\n", word_count);
  19. printf("The number of total white spaces in the given input\nfile is: %d\n", space_count);
  20. return 0;
  21. }
Success #stdin #stdout #stderr 0.03s 6952KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/BvlI3S/prog:21:0: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit