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