fork download
  1. %{
  2. #include<stdio.h>
  3.  
  4. int scanf_count = 0;
  5. int printf_count = 0;
  6. %}
  7.  
  8. scanf {\
  9. scanf_count++;
  10. printf("readf ");
  11. }
  12.  
  13. printf {\
  14. printf_count++;
  15. printf("writef ");
  16. }
  17.  
  18. %%
  19.  
  20. int main() {
  21. yylex();
  22. printf("\nNumber of scanf statements: %d\n", scanf_count);
  23. printf("Number of printf statements: %d\n", printf_count);
  24. return 0;
  25. }
  26.  
Success #stdin #stdout #stderr 0.02s 6856KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/N9zTXf/prog:25:1: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit