fork download
  1. %{
  2. #include <stdio.h>
  3.  
  4. int yylex();
  5. void yyerror(const char* s);
  6.  
  7. int t = 0;
  8. %}
  9.  
  10. %token '(' ')'
  11.  
  12. %%
  13.  
  14. input: /* empty */
  15. | input '(' input ')'
  16. ;
  17.  
  18. %%
  19.  
  20. void yyerror(const char* s) {
  21. t = 1;
  22. }
  23.  
  24. int main() {
  25. yyparse();
  26. if (t == 0)
  27. printf("Parentheses are well-formed.\n");
  28. else
  29. printf("Not well-formed.\n");
  30. }
  31.  
Success #stdin #stdout #stderr 0.02s 6936KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/nhAzrX/prog:30:1: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit