fork download
  1. %{
  2. #include <stdio.h>
  3. int catCount = 0;
  4. int dogCount = 0;
  5. %}
  6.  
  7. %%
  8. cat { catCount++; }
  9. dog { dogCount++; }
  10. . ;
  11.  
  12. %%
  13.  
  14. int main() {
  15. yylex();
  16.  
  17. printf("Number of occurrences of 'cat': %d\n", catCount);
  18. printf("Number of occurrences of 'dog': %d\n", dogCount);
  19.  
  20. return 0;
  21. }
  22.  
Success #stdin #stdout #stderr 0.04s 6956KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/DG5NSb/prog:2:1: Syntax error: Operator expected
ERROR: /home/DG5NSb/prog:21:1: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit