fork download
  1. %{
  2. #include <stdio.h>
  3. int line_count = 0, space_count = 0, tab_count = 0, other_count = 0;
  4. %}
  5.  
  6. %%
  7. \n { line_count++; }
  8. " " { space_count++; }
  9. \t { tab_count++; }
  10. . { other_count++; }
  11. %%
  12.  
  13. int main() {
  14. printf("Enter input :\n");
  15. yylex();
  16. printf("Lines: %d\n", line_count);
  17. printf("Spaces: %d\n", space_count);
  18. printf("Tabs: %d\n", tab_count);
  19. printf("Other Characters: %d\n", other_count);
  20. return 0;
  21. }
  22.  
  23. int yywrap() {
  24. return 1;
  25. }
  26.  
Success #stdin #stdout #stderr 0.02s 6892KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/DnCWd4/prog:2:1: Syntax error: Operator expected
ERROR: /home/DnCWd4/prog:25:1: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit