-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathll.c
115 lines (93 loc) · 1.81 KB
/
ll.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#include"ll1.h"
int main(int argc, char **argv)
{
int i;
char filename[30];
printf("hi fellas");
if(argc<=1) {
printf("Please Enter the file name also\n");
return -1;
}
printf("Am i entering main");
strcpy(filename,argv[1]);
readfile(filename);
/*
* Initializing the First Set array of
* structures
*/
initFirstSet();
for(i=0; first[i].var!='@';i++) {
if(first[i].epsilon == 1)
strcat(first[i].firsts,"#");
}
i = 0;
while(grammar[i]!=NULL) {
V[i] = grammar[i]->variables;
i++;
}
V[i] = '\0';
i=0;
while(strlen(V)!=0) {
firstFinding(V[i]);
i++;
}
/*
* finishing touches to firstSet
*/
deleteDup();
/* for(i=0; first[i].var!='@';i++) {
if(first[i].epsilon == 1)
strcat(first[i].firsts,"#");
}
*/
/*
* printing the variables and its firsts
*/
i=0;
while(first[i].var!='@') {
printf("\nVariable %c ",first[i].var);
printf(" %s",first[i].firsts);
i++;
}
/*
* FINDING FOLLOW
*/
i=0;
while(grammar[i]!=NULL) {
toFindFollowList[i] = grammar[i]->variables;
i++;
}
// puts("hi");
toFindFollowList[i] = '\0';
initFollowSet();
follow[0].follows[0] = '$';
follow[0].follows[1] = '\0';
// puts("\nhello");
i = 0;
while(strlen(toFindFollowList)!=0) {
followFinding(toFindFollowList[i]);
i++;
}
i=0;
while(follow[i].var!='@') {
removeEpsilon(follow[i].follows);
i++;
}
/*
*Printing the variables and its follows
*/
/* i = 0;
while(follow[i].var!='@') {
printf("\nVAr %c %s\n",follow[i].var,follow[i].follows);
i++;
}
*/
deleteDupFollow();
i=0;
while(follow[i].var!='@') {
printf("\nVAR %c %s",follow[i].var,follow[i].follows);
i++;
}
// puts(giveFirstList('S'));
return 0;
}