CD 8
CD 8
PROGRAM:
#include <stdio.h>
#include <string.h>
#define MAX_PRODUCTIONS 10
#define MAX_STRING_LENGTH 10
void main() {
char pro[MAX_PRODUCTIONS][MAX_STRING_LENGTH];
char first[MAX_PRODUCTIONS][MAX_STRING_LENGTH];
char follow[MAX_PRODUCTIONS][MAX_STRING_LENGTH];
char res[MAX_PRODUCTIONS][MAX_PRODUCTIONS][MAX_STRING_LENGTH];
int count[MAX_PRODUCTIONS][MAX_PRODUCTIONS];
scanf("%d", &npro);
// Initialize arrays
memset(count, 0, sizeof(count));
flag = 0;
if (nt[j] == pro[i][0]) {
flag = 1;
break;
if (!flag) {
nt[nont] = pro[i][0];
nont++;
scanf("%s", first[i]);
}
printf("\nEnter the follow values:\n");
scanf("%s", follow[i]);
// Extract terminals
flag = 0;
if (ter[k] == first[i][j]) {
flag = 1;
break;
ter[noter++] = first[i][j];
flag = 0;
if (ter[k] == follow[i][j]) {
flag = 1;
break;
if (!flag) {
ter[noter++] = follow[i][j];
flag = 0;
if (first[i][j] == '#') {
col = i;
if (ter[n] == follow[col][m]) {
row = n;
break;
count[col][row]++;
} else {
for (n = 0; n < noter; n++) {
if (ter[n] == first[i][j]) {
row = n;
break;
if (nt[i] == pro[k][0]) {
col = i;
count[col][row]++;
} else {
flag = 0;
if (nt[m] == pro[k][3]) {
index = m;
flag = 1;
break;
if (flag) {
if (first[i][j] == first[index][m]) {
sprintf(res[col][row], "%s", pro[k]);
count[col][row]++;
break;
printf("LL1 Table\n\n");
printf("\t");
printf("%c\t", ter[i]);
printf("\n\n%c", nt[j]);
printf("\t%s", res[j][k]);
}
}
flag = 0;
if (count[i][j] > 1) {
flag = 1;
break;
if (flag) {
} else {
}
OUTPUT :