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. [ \t] { num_spaces++; }
  10. [\x01-\x09\x0b-\x1f\x7f] { 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/meta characters: %d\n", num_tabs);
  18. printf("Number of other characters: %d\n", num_others);
  19. return 0;
  20. }
  21. int yywrap() {
  22. return 1;
  23. }
Success #stdin #stdout #stderr 0.03s 6892KB
stdin
Helllow word
stdout
Standard output is empty
stderr
ERROR: /home/e1yYML/prog:2:4: Syntax error: Operator expected
ERROR: /home/e1yYML/prog:23:0: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit