fork download
  1. %{
  2. #include <stdio.h>
  3. int lines = 0, spaces = 0, tabs = 0, other_chars = 0;
  4. %}
  5.  
  6. %%
  7. \n { lines++; }
  8. " " { spaces++; }
  9. \t { tabs++; }
  10. . { other_chars++; }
  11. %%
  12.  
  13. int main() {
  14. printf("Enter the input (Ctrl+D to end input in Linux/Mac, Ctrl+Z in Windows):\n");
  15. yylex();
  16. printf("Lines: %d\nSpaces: %d\nTabs: %d\nOther characters: %d\n", lines, spaces, tabs, other_chars);
  17. return 0;
  18. }
  19.  
  20. int yywrap() {
  21. return 1;
  22. }
Success #stdin #stdout #stderr 0.02s 6836KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/1kGw0d/prog:2:1: Syntax error: Operator expected
ERROR: /home/1kGw0d/prog:22:0: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit