fork download
  1. %{
  2. #include <stdio.h>
  3. int line_number = 1;
  4. %}
  5. %option noyywrap
  6. %%
  7. \n { printf("%d: ", line_number++); ECHO; }
  8. . { ECHO; }
  9. %%
  10. int main() {
  11. FILE *file = fopen("lines.txt","r");
  12. if (!file){
  13. printf("ERROR");
  14. return 1;
  15. }
  16. yyin=file;
  17. yylex();
  18. fclose(file);
  19. return 0;
  20. }
Success #stdin #stdout #stderr 0.03s 6920KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/SDJiRM/prog:2:1: Syntax error: Operator expected
ERROR: /home/SDJiRM/prog:20:0: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit