fork download
  1. %{
  2. #include<stdio.h>
  3. int lines=0, words=0,s_letters=0,c_letters=0, num=0, spl_char=0,total=0;
  4. %}
  5. %%
  6. \n { lines++; words++;}
  7. [\t ' '] words++;
  8. [A-Z] c_letters++;
  9. [a-z] s_letters++;
  10. [0-9] num++;
  11. . spl_char++;
  12. %%
  13. main(void)
  14. {
  15. yyin= fopen("practical9.txt","r");
  16. yylex();
  17. total=s_letters+c_letters+num+spl_char;
  18. printf(" This File contains ...");
  19. printf("\n\t%d lines", lines);
  20. printf("\n\t%d words",words);
  21. printf("\n\t%d small letters", s_letters);
  22. printf("\n\t%d capital letters",c_letters);
  23. printf("\n\t%d digits", num);
  24. printf("\n\t%d special characters",spl_char);
  25. printf("\n\tIn total %d characters.\n",total);
  26. }
  27. int yywrap()
  28. {
  29. return(1)
  30. }
  31. }
  32.  
Success #stdin #stdout #stderr 0.02s 7020KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/PxraWG/prog:2:1: Syntax error: Operator expected
ERROR: /home/PxraWG/prog:31:1: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit