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. %%
  9. \n { num_lines++; }
  10. [ \t] { num_spaces++; }
  11. [\x01-\x09\x0b-\x1f\x7f] { num_tabs++; }
  12. . { num_others++; }
  13. %%
  14.  
  15. int main() {
  16. yylex();
  17. printf("Number of lines: %d\n", num_lines);
  18. printf("Number of spaces: %d\n", num_spaces);
  19. printf("Number of tabs/meta characters: %d\n", num_tabs);
  20. printf("Number of other characters: %d\n", num_others);
  21.  
  22. return 0;
  23. }
  24.  
  25. int yywrap() {
  26. return 1;
  27. }
Success #stdin #stdout #stderr 0.03s 6908KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/V2IKHP/prog:2:4: Syntax error: Operator expected
ERROR: /home/V2IKHP/prog:27:1: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit