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