fork download
  1. %{
  2. int c=0,w=0,l=0,s=0;
  3. %}
  4. %%
  5. [\n] l++;
  6. [' '\n\t] s++;
  7. [^' '\t\n]+ w++; c+=yyleng;
  8. %%
  9. int main(int argc, char *argv[])
  10. {
  11. if(argc==2)
  12. {
  13. yyin=fopen(argv[1],"r");
  14. yylex();
  15. printf("\nNUMBER OF SPACES = %d",s);
  16. printf("\nCHARACTER=%d",c);
  17. printf("\nLINES=%d",l);
  18. printf("\nWORD=%d\n",w);
  19. }
  20. else
  21. printf("ERROR");
  22. }
Success #stdin #stdout #stderr 0.03s 6964KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/WK7iJJ/prog:22:0: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit