fork download
  1. %{
  2. int lines = 0, words = 0, chars = 0;
  3. %}
  4.  
  5. %%
  6. \n { lines++; chars++; } /* Count new lines */
  7. [ \t]+ { chars += yyleng; } /* Count spaces and tabs */
  8. [^ \t\n]+ { words++; chars += yyleng; } /* Count words and characters */
  9. %%
  10.  
  11. int main()
  12. {
  13. yylex();
  14. printf("Number of lines: %d\n", lines);
  15. printf("Number of words: %d\n", words);
  16. printf("Number of characters: %d\n", chars);
  17. return 0;
  18. }
  19.  
  20. int yywrap() { return 1; }
Success #stdin #stdout #stderr 0.02s 6948KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/my9L8N/prog:20:25: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit