fork download
  1. %{
  2. #include <stdio.h>
  3.  
  4. int line_count=1;
  5. int char_count=0;
  6. %}
  7.  
  8. %%
  9. \n {line_count++; char_count++;}
  10. . {char_count++;}
  11. %%
  12.  
  13. int yywrap(void){
  14. return 1;
  15. }
  16.  
  17. int main(int argc, char *argv[]){
  18. FILE *file = fopen(argv[1],"r");
  19. yyin = file;
  20.  
  21. yylex();
  22. printf("Number of lines : %d\n",line_count);
  23. printf("Number of characters : %d\n",char_count);
  24.  
  25. return 0;
  26. }
Success #stdin #stdout #stderr 0.03s 6940KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/5R7s4l/prog:2:1: Syntax error: Operator expected
ERROR: /home/5R7s4l/prog:26:0: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit