fork download
  1. %{
  2. #include <stdio.h>
  3. int char_count = 0, word_count = 0, line_count = 0;
  4. %}
  5.  
  6. %%
  7. [^\t\n ]+ { word_count++; char_count += yyleng; }
  8. [\t ]+ { char_count += yyleng; }
  9. \n { line_count++; char_count++; }
  10. . { char_count++; }
  11. %%
  12.  
  13. int yywrap() { return 1; }
  14.  
  15. int main() {
  16. yylex();
  17. printf("Characters: %d\nWords: %d\nLines: %d\n", char_count, word_count, line_count);
  18. return 0;
  19. }
Success #stdin #stdout #stderr 0.03s 6784KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/xLsh9P/prog:2:1: Syntax error: Operator expected
ERROR: /home/xLsh9P/prog:19:0: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit