fork download
  1. %{
  2. #include <stdio.h>
  3.  
  4. int nl = 0; /* number of lines */
  5. int nw = 0; /* number of words */
  6. int nb = 0; /* number of blank spaces */
  7. int nc = 0; /* number of characters */
  8. %}
  9.  
  10. %%
  11. \n { nl++; }
  12. [ \t]+ { nb++; }
  13. [a-zA-Z0-9]+ { nw++; nc += yyleng; }
  14. . { nc++; }
  15. %%
  16.  
  17. int yywrap()
  18. {
  19. return 1;
  20. }
  21.  
  22. int main()
  23. {
  24. yylex();
  25.  
  26. printf("Lines : %d\nWords : %d\nCharacters : %d\nBlanks : %d\n",
  27. nl, nw, nc, nb);
  28.  
  29. return 0;
  30. }
Success #stdin #stdout #stderr 0.03s 6936KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/QGU5DK/prog:2:1: Syntax error: Operator expected
ERROR: /home/QGU5DK/prog:30:0: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit