Program 7 & 8 Compiler Design
Program 7 & 8 Compiler Design
Concept:
Algorithm:
Implementation in C:
#include <stdio.h>
#include <string.h>
char precedence[5][5] = {
{'>', '>', '<', '<', '>'},
{'>', '>', '<', '<', '>'},
{'>', '>', '>', '>', '>'},
{'<', '<', '<', '<', '='},
{'>', '>', '>', '>', '>'}
};
printf("\nParsing Steps:\n");
while (i < strlen(input)) {
char topSymbol = stack[top - 1];
char currSymbol = input[i];
int main() {
char input[20];
printf("Enter expression: ");
scanf("%s", input);
parse(input);
return 0;
}
Experiment-8
Objective:
Concept:
Algorithm:
Implementation in C:
c
CopyEdit
#include <stdio.h>
#include <string.h>
#define MAX 10
char productions[MAX][MAX];
char first[MAX][MAX];
char follow[MAX][MAX];
int numProductions;
int main() {
printf("Enter number of productions: ");
scanf("%d", &numProductions);
printf("Enter productions (E->T+E format):\n");
for (int i = 0; i < numProductions; i++)
scanf("%s", productions[i]);
return 0;
}