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