fork download
  1. %{
  2. #include <stdio.h>
  3. %}
  4. %%
  5. (a|b)*ccc{
  6. int a=0;b=0;
  7. for(int i=0;yytext[i]!='\0';i++){
  8. if(yytext[i]=='a')a++;
  9. else(yytext[i]=='b')b++;
  10. }
  11. if(a%2!=0 && b%2==0){
  12. printf("accepted");
  13. }
  14. else{
  15. printf("rejected");
  16. }
  17. }
  18. .*{
  19. printf("reject");
  20. }
  21. %%
  22. int main(){
  23. printf("enter string: ");
  24. yylex();
  25. return 0;
  26. }
  27. int yywrap(){
  28. return 1;
  29. }
Success #stdin #stdout #stderr 0.02s 6848KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/e3mEY4/prog:29:0: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit