fork download
  1.  
  2. %{
  3. int line = 1; /* New variable for counting line number*/
  4. int comment = 0;
  5. int debug=1; /* prints out debug statements if desired */
  6. %}
  7. %%
  8. "\n" {line++;
  9. if (!comment) printf("\n");} /* New rule to ignore new lines when they're in comments*/
  10. "/*" {
  11. if (comment && debug) fprintf(stderr,
  12. " >>>>>>>> line %d: Possible Nested comment <<<<<<<<<<\n", line); /*Added ", line" inside fprintf to match line to %d*/
  13. comment = 1;
  14. }
  15.  
  16. "*/" {
  17. if (!comment) printf("%s",yytext); /*print out if it is not in a comment */
  18. comment = 0;
  19. }
  20. . { if (!comment) printf("%s",yytext);}
  21.  
  22. %%
  23.  
  24. int yywrap(void)
  25. { return 1;
  26. }
  27.  
  28. int main()
  29. {
  30. yylex();
  31.  
  32. }
  33.  
  34.  
Success #stdin #stdout #stderr 0.03s 6960KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/NRS1sF/prog:3:12: Syntax error: Operator expected
ERROR: /home/NRS1sF/prog:33:0: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit