Professional Documents
Culture Documents
CDP 1
CDP 1
CDP 1
h>
#include<stdlib.h>
#include<string.h>
#define S 20
int main()
{
char P[S], A[S], B[S];
int non,i,j, index=3;
non=P[0];
if(non==P[index]) //Checking if the Grammar is LEFT RECURSIVE
{
//Getting Alpha
for(i=++index,j=0;P[i]!='|';i++,j++){
A[j]=P[i];
//Checking if there is NO Vertical Bar (|)
if(P[i+1]==0){
printf("This Grammar CAN'T BE REDUCED.\n");
exit(0); //Exit the Program
}
}
A[j]='\0'; //String Ending NULL Character