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