fork download
  1. %{
  2. // Description Part
  3. #include<stdio.h>
  4.  
  5. int lines = 0, spaces = 0, tabs = 0, characters = 0;
  6. %}
  7.  
  8. %%
  9. // Rule Section
  10.  
  11. \n { lines++; characters++; }
  12. \t { tabs++; characters++; }
  13. " " { spaces++; characters++; }
  14. . { characters++; }
  15.  
  16. %%
  17.  
  18. int main() {
  19. // Main Section
  20. yylex();
  21. printf("Characters = %d\n", characters);
  22. printf("Tabs = %d\n", tabs);
  23. printf("Spaces = %d\n", spaces);
  24. printf("Lines = %d\n", lines);
  25. return 0;
  26. }
  27.  
  28. int yywrap() {
  29. return 1;
  30. }
  31.  
Success #stdin #stdout #stderr 0.02s 6912KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/9b5KvL/prog:2:8: Syntax error: Operator expected
ERROR: /home/9b5KvL/prog:30:1: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit