fork download
  1. %{
  2. #include<stdio.h>
  3. int lc=0, sc=0, tc=0, cc=0;
  4. %}
  5.  
  6. %%
  7. \n { lc++; }
  8. [] { sc++; }
  9. \t { tc++; }
  10. . { cc++; }
  11. %%
  12.  
  13. int yywrap()
  14. {
  15. return 1;
  16. }
  17.  
  18. int main()
  19. {
  20. printf("Enter the string:\n\n"};
  21. yylex();
  22. printf("\nThe no. of lines are: %d\n", lc );
  23. printf("\nThe no. of space are: %d\n", sc );
  24. printf("\nThe no. of tab-meta char. are: %d\n", tc);
  25. printf("\nThe no. of other char. are: %d\n", cc );
  26. return 0;
  27. }
Success #stdin #stdout #stderr 0.03s 6964KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/cjPZlT/prog:2:6: Syntax error: Operator expected
ERROR: /home/cjPZlT/prog:27:0: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit