fork download
  1.  
  2. %{
  3. #include <stdio.h>
  4. int ctChar=0;
  5. int ctSpace=0;
  6. int ctWord=0;
  7. int ctLine=0;
  8. %}
  9. WORD [^ \t\n,\.:]+
  10. EOL [\n]
  11. BLANK [ ]
  12. %%
  13.  
  14. {WORD} {ctWord++; ctChar+=yyleng;}
  15. {BLANK} {ctSpace++;}
  16. {EOL} {ctLine++;}
  17. . {ctChar++;}
  18. %%
  19.  
  20. void main(int argc, char *argv[]){
  21. if(argc!=2){
  22. printf("Usage:\n\t./a.out <FILENAME>\n");
  23. exit(0);
  24. }
  25.  
  26. yyin=fopen(argv[1],"r");
  27. yylex();
  28.  
  29. printf("Word Count: %d\n",ctWord);
  30. printf("Character Count: %d\n",ctChar);
  31. printf("Space Count: %d\n",ctSpace);
  32. printf("Line Count: %d\n",ctLine);
  33. fclose(yyin);
  34.  
  35. }
  36.  
  37. int yywrap(){
  38. return 1;
  39. }
Success #stdin #stdout #stderr 0.03s 6880KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/JbGWZt/prog:3:5: Syntax error: Operator expected
ERROR: /home/JbGWZt/prog:39:0: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit