spcc4 (1)
spcc4 (1)
UID 2022300062
Subject SPCC
Code :
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include <stdlib.h>
int count, n = 0;
char calc_first[10][100];
char calc_follow[10][100];
int m = 0;
char f[10];
int k;
char ck;
int e;
int jm = 0;
int km = 0;
int i, choice;
char c, ch;
printf("How many productions ? :");
scanf("%d", &count);
printf("\nEnter %d productions in form A=B where A and B are grammar symbols :\n\n", count);
int temp;
char done[count];
// Initialize calc_first
calc_first[k][temp] = '!';
c = production[k][0];
point2 = 0;
xxx = 0;
if (c == done[temp]) {
xxx = 1;
}
if (xxx == 1) {
continue;
findfirst(c, 0, 0);
ptr += 1;
done[ptr] = c;
calc_first[point1][point2++] = c;
if (first[i] == calc_first[point1][len]) {
chk = 1;
break;
if (chk == 0) {
calc_first[point1][point2++] = first[i];
printf("}\n");
jm = n;
point1++;
printf("\n");
char donee[count];
ptr = -1;
// Initialize calc_follow
calc_follow[k][temp] = '!';
point1 = 0;
int land = 0;
ck = production[e][0];
point2 = 0;
xxx = 0;
if (ck == donee[temp]) {
xxx = 1;
}
if (xxx == 1) {
continue;
land += 1;
follow(ck);
ptr += 1;
donee[ptr] = ck;
calc_follow[point1][point2++] = ck;
if (f[i] == calc_follow[point1][len]) {
chk = 1;
break;
if (chk == 0) {
calc_follow[point1][point2++] = f[i];
printf(" }\n\n");
km = m;
point1++;
}
char ter[10];
ter[k] = '!';
// Find terminals
if (!isupper(production[k][temp]) &&
production[k][temp] != '\0') {
vp = 0;
if (production[k][temp] == ter[ap]) {
vp = 1;
break;
if (vp == 0) {
ter[s] = production[k][temp];
s++;
}
}
ter[s] = '$';
s++;
printf("\n\t\t\t\t\t\t\t The LL(1) Parsing Table for the above grammer :- ");
printf("%c\t\t", ter[ap]);
char first_prod[count][s];
int destiny = 0;
k = 2;
int ct = 0;
char tem[100];
if (!isupper(production[ap][k])) {
tem[ct++] = production[ap][k];
tem[ct++] = '_';
tem[ct++] = '\0';
k++;
break;
} else {
int zap = 0;
int tuna = 0;
if (calc_first[zap][0] == production[ap][k]) {
for (tuna = 1; tuna < 100; tuna++) {
if (calc_first[zap][tuna] != '!') {
tem[ct++] = calc_first[zap][tuna];
} else {
break;
break;
tem[ct++] = '_';
k++;
if (tem[tuna] == '#') {
zap = 1;
if (zap == 1) {
zap = 0;
} else {
break;
} else {
first_prod[ap][destiny++] = tem[tuna];
}
char table[land][s + 1];
ptr = -1;
table[ap][temp] = '!';
ck = production[ap][0];
xxx = 0;
if (ck == table[temp][0]) {
xxx = 1;
if (xxx == 1) {
continue;
} else {
ptr = ptr + 1;
table[ptr][0] = ck;
int tuna = 0;
while (first_prod[ap][tuna] != '\0') {
int to, ni = 0;
if (first_prod[ap][tuna] == ter[to]) {
ni = 1;
if (ni == 1) {
char xz = production[ap][0];
int cz = 0;
cz = cz + 1;
int vz = 0;
vz = vz + 1;
tuna++;
if (calc_first[k][temp] == '!') {
break;
} else if (calc_first[k][temp] == '#') {
int fz = 1;
char xz = production[k][0];
int cz = 0;
cz = cz + 1;
int vz = 0;
vz = vz + 1;
table[k][vz + 1] = '#';
fz++;
break;
if (table[ap][temp] == '!') {
printf("\t\t");
printf("%c=#\t\t", table[ap][0]);
} else {
int mum = (int)(table[ap][temp]);
mum -= 65;
printf("%s\t\t", production[mum]);
printf("\n\n");
// Input parsing
int j;
char input[100];
printf("\t\t\t\t\t\tStack\t\t\tInput\t\t\tAction");
char stack[100];
stack[0] = '$';
stack[1] = table[0][0];
printf("\t\t\t\t\t\t");
int vamp = 0;
printf("%c", stack[vamp]);
printf("\t\t\t");
vamp = i_ptr;
vamp++;
printf("\t\t\t");
s_ptr--;
if (!isupper(him)) {
if (her == him) {
i_ptr++;
printf("POP ACTION\n");
} else {
if (ter[i] == her) {
break;
char produ[100];
if (him == table[j][0]) {
if (table[j][i + 1] == '#') {
printf("%c=#\n", table[j][0]);
produ[0] = '#';
produ[1] = '\0';
mum -= 65;
strcpy(produ, production[mum]);
printf("%s\n", produ);
} else {
int le = strlen(produ);
le = le - 1;
if (le == 0) {
continue;
s_ptr++;
stack[s_ptr] = produ[j];
printf("\n");
if (input[i_ptr] == '\0') {
} else {
printf("\n");
return 0;
void follow(char c)
int i, j;
if (production[0][0] == c) {
f[m++] = '$';
if (production[i][j] == c) {
if (production[i][j + 1] != '\0') {
follow(production[i][0]);
int j;
if (!(isupper(c))) {
first[n++] = c;
if (production[j][0] == c) {
if (production[j][2] == '#') {
if (production[q1][q2] == '\0') {
first[n++] = '#';
} else {
first[n++] = '#';
} else if (!isupper(production[j][2])) {
first[n++] = production[j][2];
} else {
findfirst(production[j][2], j, 3);
int k;
if (!(isupper(c))) {
f[m++] = c;
} else {
int i = 0, j = 1;
for (i = 0; i < count; i++) {
if (calc_first[i][0] == c) {
break;
if (calc_first[i][j] != '#') {
f[m++] = calc_first[i][j];
} else {
if (production[c1][c2] == '\0') {
follow(production[c1][0]);
} else {
j++;
Output