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