fork download
  1.  
  2.  
  3. %{
  4. #include <stdio.h>
  5. %}
  6.  
  7. %%
  8.  
  9. [ \t\n]+ { printf(" "); } // Replace whitespace sequence with a single blank
  10. . { putchar(yytext[0]); } // Copy other characters as they are
  11.  
  12. %%
  13.  
  14. int main(int argc, char *argv[]) {
  15. if (argc < 2) {
  16. printf("Usage: %s <filename>\n", argv[0]);
  17. return 1;
  18. }
  19. FILE *fp = fopen(argv[1], "r");
  20. if (!fp) {
  21. printf("Error: Unable to open the file.\n");
  22. return 1;
  23. }
  24. yyin = fp;
  25. yylex();
  26. fclose(fp);
  27. return 0;
  28. }
Success #stdin #stdout #stderr 0.03s 6972KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/Kx4cwo/prog:4:1: Syntax error: Operator expected
ERROR: /home/Kx4cwo/prog:28:0: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit