fork download
  1. #include<stdio.h>
  2. int count=0;
  3. %%
  4. [a-z] {}
  5. [A-Z] {}
  6. [0-9] {}
  7. [')'] {count++;}
  8. ['('] {count--;}
  9. [+/%<>$] {}
  10. ['\n'] {
  11. if(count==0)
  12. printf("parenthesis is matched\n");
  13. else if(count > 0)
  14. printf("presence of unmatched right parenthesis\n");
  15. else
  16. printf("presence of unmatched left parenthesis\n");
  17. }
  18. %%
  19. int main () {
  20. printf("Enter the expression: ");
  21. yylex();
  22. return 0;
  23. }
  24.  
Success #stdin #stdout #stderr 0.02s 6924KB
stdin
(a+b)
stdout
Standard output is empty
stderr
ERROR: /home/cXDDAg/prog:23:1: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit