fork download
  1. %{
  2. #include<stdio.h>
  3. int c=0,l=0,t=0,s=0;
  4. %}
  5. %%
  6. \n {l++;}
  7. \t {t++;}
  8. " " {s++;}
  9. . {c++;}
  10. %%
  11.  
  12. int main()
  13. {
  14. printf("Enter the text \n");
  15. yylex();
  16. printf("The number of lines are: %d\n",l);
  17. printf("The number of spaces are: %d\n",s);
  18. printf("The number of tab-meta characters are: %d\n",t);
  19. printf("The rest of the characters are: %d\n",c);
  20. return 0;
  21. }
  22.  
  23. int yywrap()
  24. {
  25. return 1;
  26. }
Success #stdin #stdout #stderr 0.02s 6896KB
stdin
hi 
compiler design 
stdout
Standard output is empty
stderr
ERROR: /home/iXY24L/prog:2:3: Syntax error: Operator expected
ERROR: /home/iXY24L/prog:26:0: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? Options:
+:                  spy        -:              no spy
/c|e|r|f|u|a goal:  find       .:              repeat find
a:                  abort      A:              alternatives
b:                  break      c (ret, space): creep
[depth] d:          depth      e:              exit
f:                  fail       [ndepth] g:     goals (backtrace)
h (?):              help       i:              ignore
l:                  leap       L:              listing
n:                  no debug   p:              print
r:                  retry      s:              skip
u:                  up         w:              write
m:                  exception details
C:                  toggle show context
   Exception: (3) program ? EOF: exit