fork download
  1. %{
  2. #include<stdio.h>
  3. int sc=0,wc=0,lc=0,cc=0;
  4. %}
  5. %%
  6. [\n] { lc++; cc+=yyleng;}
  7. [ \t] { sc++; cc+=yyleng;}
  8. [^\t\n ]+ { wc++; cc+=yyleng;}
  9. %%
  10. int main(int argc ,char* argv[ ])
  11. {
  12. printf("Enter the input:\n");
  13. yylex();
  14. printf("The number of lines=%d\n",lc);
  15. printf("The number of spaces=%d\n",sc);
  16. printf("The number of words=%d\n",wc);
  17. printf("The number of characters are=%d\
  18. n",cc);
  19. }
  20. int yywrap( )
  21. {
  22. return 1;
  23. }
Success #stdin #stdout #stderr 0.03s 6864KB
stdin
 you can't see me
 cenaaa
stdout
Standard output is empty
stderr
ERROR: /home/q3x3Mq/prog:23:1: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? ERROR: Unknown option (h for help)
   Exception: (3) program ? EOF: exit