Professional Documents
Culture Documents
Day8 Ak
Day8 Ak
Day8 Ak
h>
#include <stdlib.h>
#include <string.h>
void main()
{
printf("\nAkhil Jose Francis\n");
input_ptr = 0;
stack_top = -1;
int i;
for (i = 0; i < no_of_productions; i++){
reduce = 1;
for (int j = stack_top, k = strlen(productions[i]) - 1;
j >= 0, k >= 2; j--, k--)
if (stack[j] != productions[i][k])
reduce = 0;
if (reduce == 1)
break;
}
if (reduce == 1){
int j, k;
for (j = stack_top, k = strlen(productions[i]) - 1;
j >= 0, k >= 2; j--, k--);
stack[j + 1] = productions[i][0];
stack[j + 2] = '\0';
stack_top -= strlen(productions[i]) - 2 - 1;
printf("String rejected.\n");
}