fork download
  1. %{
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4.  
  5. int balance = 0; // To track balance of parentheses
  6. %}
  7.  
  8. %%
  9. \( { balance++; }
  10. \) { balance--; }
  11. .* { /* Ignore other characters */ }
  12.  
  13. %%
  14. int yywrap() {
  15. return 1;
  16. }
  17. int main(){
  18. yylex();
  19.  
  20. if (balance == 0) {
  21. printf("yes\n");
  22. } else if (balance > 0) {
  23. printf("error missing )\n");
  24. } else {
  25. printf("error missing (\n");
  26. }
  27.  
  28. return 0;
  29. }
  30.  
  31.  
  32.  
Success #stdin #stdout #stderr 0.02s 6924KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/iuJmNV/prog:31:0: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit