fork download
  1. %{
  2. int num_lines = 0;
  3. int num_spaces = 0;
  4. int num_tabs = 0;
  5. int num_others = 0;
  6. %}
  7. %%
  8. \n { num_lines++; }
  9. " " { num_spaces++; }
  10. "\t" { num_tabs++; }
  11. . { num_others++; }
  12. %%
  13. int main() {
  14. yylex();
  15. printf("Number of lines: %d\n", num_lines);
  16. printf("Number of spaces: %d\n", num_spaces);
  17. printf("Number of tabs: %d\n", num_tabs);
  18. printf("Number of other characters: %d\n", num_others);
  19. return 0;
  20. }
  21.  
  22. int yywrap() {
  23. return 1;
  24. }
  25.  
Success #stdin #stdout #stderr 0.03s 6820KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/2y6qIN/prog:2:4: Syntax error: Operator expected
ERROR: /home/2y6qIN/prog:24:1: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit