fork download
  1. %{
  2. #include <stdio.h>
  3. #include <ctype.h>
  4.  
  5. int line_count = 0;
  6. int word_count = 0;
  7. %}
  8.  
  9. %%
  10.  
  11. \n { line_count++; }
  12. [a-zA-Z_][a-zA-Z0-9_]* { word_count++; }
  13.  
  14. %%
  15.  
  16. int main() {
  17. printf("Enter input\n");
  18.  
  19.  
  20. yylex();
  21.  
  22. printf("Lines: %d\n", line_count);
  23. printf("Words: %d\n", word_count);
  24. return 0;
  25. }
Success #stdin #stdout #stderr 0.02s 7004KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/9KxhdL/prog:25:0: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit