fork download
  1. %{
  2. #include <stdio.h>
  3. int lc = 0, sc = 0, tc = 0, ch = 0;
  4. %}
  5. %%
  6. \n { lc++; }
  7. [ ]+ { sc++; }
  8. \t { tc++; }
  9. . { ch++; }
  10. %%
  11. int main() {
  12. printf("Enter string:\n(After completion, press 'Ctrl' and 'D')\n");
  13. yylex();
  14. printf("\nNo. of lines: %d", lc);
  15. printf("\nNo. of spaces: %d", sc);
  16. printf("\nNo. of tabs: %d", tc);
  17. printf("\nNo. of other characters: %d\n", ch);
  18. return 0;
  19. }
Success #stdin #stdout #stderr 0.03s 6936KB
stdin
my name is 
stdout
Standard output is empty
stderr
ERROR: /home/9BkTsT/prog:2:1: Syntax error: Operator expected
ERROR: /home/9BkTsT/prog:19:0: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit