fork download
  1. %{
  2. #include <stdio.h>
  3.  
  4. int line_count = 0;
  5. int char_count = 0;
  6. %}
  7.  
  8. %%
  9. \n { line_count++; char_count++; }
  10. . { char_count++; }
  11. %%
  12.  
  13. int yywrap() {
  14. return 1;
  15. }
  16.  
  17. int main() {
  18. printf("Enter text (Ctrl+Z to end on Windows, Ctrl+D on Unix):\n");
  19. yylex();
  20.  
  21. printf("\nNumber of lines: %d\n", line_count);
  22. printf("Number of characters: %d\n", char_count);
  23.  
  24. return 0;
  25. }
Success #stdin #stdout #stderr 0.02s 6736KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/pCEdCV/prog:2:1: Syntax error: Operator expected
ERROR: /home/pCEdCV/prog:25:0: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit