fork download
  1. %{
  2. #include <stdio.h>
  3. int lc=0,sc=0,wc=0,ch=0;
  4. %}
  5. %%
  6. [\n]{lc++;ch+=yyleng;}
  7. [\t]{sc++;ch+=yyleng;}
  8. [^\t\n]{wc++;ch+=yyleng;}
  9. %%
  10. int yywrap(){};
  11. int main()
  12. {
  13. printf("give any sentence");
  14. yylex();
  15. printf("no of lines :%d\n",lc);
  16. printf("no of lines :%d\n",wc);
  17. printf("no of lines :%d\n",sc);
  18. printf("no of lines :%d\n",ch);
  19. yylex();
  20. return 0;
  21. }
  22.  
Success #stdin #stdout #stderr 0.03s 6968KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/t6FrGz/prog:21:1: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit