fork download
  1. #include<stdio.h> #include<string.h> void main()
  2. {
  3. char input[100], l[50],r[50],temp[10],tempprod[20],productions[25][50]; int i=0,j=0,flag=0,consumed=0;
  4. printf(“Enter the Productions:); scanf(%ls->%s”, l, r);
  5. printf(%s”, r);
  6. while(sscanf(r+consumed,% [^l] s”, temp) == 1 &&consumed<=strlen(r))
  7. {
  8. if(temp[0] == l[0])
  9. {
  10. flag = 1;
  11. sprintf(productions[i++],%s->%s%s ‘\0”, l,temp+1,1);
  12. }
  13. else
  14. sprintf(productions[i++],%s->%s%s ‘\0”,l, temp,1); consumed += strlen(temp)+1;
  15. }
  16. if(flag==1)
  17. {
  18. sprintf(productions[i++],%s->€ \0”, 1);
  19. printf(“the productions after eliminating left recursion are:\n”); for(j=0;j<i;j++)
  20. printf(%s \n “, productions[j]);
  21. }
  22. else
  23. printf(“ The Given Grammar has no Left Recursion”);
  24. }
  25.  
  26.  
  27.  
  28.  
  29.  
  30.  
Success #stdin #stdout #stderr 0.02s 6960KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/4XZyv0/prog:29:0: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit