-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTable.h
More file actions
206 lines (162 loc) · 4.21 KB
/
Table.h
File metadata and controls
206 lines (162 loc) · 4.21 KB
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
#include <stdio.h>
#include <string.h>
extern int nb_ligne;
extern int qc;
typedef struct
{
char NomEntite[20];
char CodeEntite[20];
char TypeEntite[20];
int TailleEntite;
int ConstantEntite;
char nomFunction[20];
int param;
}TypeTS;
typedef struct
{
char NomFonction[20];
char TypeEntite[20];
}TypeTF;
typedef struct qdr{
char oper[100];
char op1[100];
char op2[100];
char res[100];
}qdr;
qdr quad[1000];
TypeTF tf[100];
TypeTS ts[100];
int CpTabSym=0;
int cptTypeEntit=0;
int CpTabFct=0;
int recherche(char entite[],char Funct[]){
int i=0;
while(i<CpTabSym)
{
if (strcmp(entite,ts[i].NomEntite)==0 && strcmp(Funct,ts[i].nomFunction)==0) return i;
i++;
}
return -1;
}
void inserer(char entite[], char code[],char Funct[])
{
if ( recherche(entite,Funct)==-1)
{
strcpy(ts[CpTabSym].NomEntite,entite);
strcpy(ts[CpTabSym].CodeEntite,code);
strcpy(ts[CpTabSym].nomFunction,Funct);
CpTabSym++;
cptTypeEntit++;
}
else
{
printf("Double Declaration %s a la ligne %d posTab = %d \n",entite,nb_ligne, recherche(entite,Funct));
}
}
void afficher ()
{
printf("\n/***************Table des symboles ******************/\n");
printf("___________________________________________________________________________________________________\n");
printf("\t| NomEntite | CodeEntite | TypeEntite | Taille Entite| Constant | Nom De Fonction | Parme \n");
printf("___________________________________________________________________________________________________\n");
int i=0;
while(i<CpTabSym)
{
printf("\t|%10s |%12s | %12s | %12d | %12d | %12s | %12d\n",ts[i].NomEntite,
ts[i].CodeEntite,ts[i].TypeEntite,ts[i].TailleEntite,ts[i].ConstantEntite,ts[i].nomFunction+8,ts[i].param);
i++;
}
}
void insererType(char type[])
{
for(int i=cptTypeEntit;i>=0;i--)
{
strcpy(ts[CpTabSym-i].TypeEntite,type);
}
cptTypeEntit=0;
}
void insertTable(char entite[],char code[],int taille,char NomFunct[]){
int x = recherche(entite,NomFunct);
if (x!=-1)
{
strcpy(ts[x].CodeEntite,"Table");
ts[x].TailleEntite=taille;
}
}
void insertCST(char entite[],char funct[])
{
int x = recherche(entite,funct);
ts[x].ConstantEntite=1;
}
void inserePrm(char entite[],char funct[]){
int x = recherche(entite,funct);
if(x!=-1)
{
ts[x].param=1;
}
}
int RecherchFct(char Nom[])
{
int i=0;
while(i<CpTabSym)
{
if (strcmp(Nom,tf[i].NomFonction)==0) return i;
i++;
}
return -1;}
void insererFct(char Entite[])
{
int x = RecherchFct(Entite);
if (x == -1)
{
strcpy(tf[CpTabFct].NomFonction,Entite);
CpTabFct++;
}
else
{
printf("fonction Deja Declaré");
}
}
void insererTypeFct(char Entite[],char Type[])
{
int x = RecherchFct(Entite);
strcpy(tf[x].TypeEntite,Type);
}
void affichTF()
{
printf("\n/***************Table des Fonction ******************/\n");
printf("_______________________________________________________\n");
printf("\t Nom Fonction | Type Fonction \n");
printf("_______________________________________________________\n");
int i=0;
while(i<CpTabFct)
{
printf("%10s | %10s \n",tf[i].NomFonction+8,tf[i].TypeEntite);
i++;
}
}
void quadr(char opr[],char op1[],char op2[],char res[])
{
strcpy(quad[qc].oper,opr);
strcpy(quad[qc].op1,op1);
strcpy(quad[qc].op2,op2);
strcpy(quad[qc].res,res);
qc++;
}
void ajour_quad(int num_quad, int colon_quad, char val [])
{
if (colon_quad==0) strcpy(quad[num_quad].oper,val);
else if (colon_quad==1) strcpy(quad[num_quad].op1,val);
else if (colon_quad==2) strcpy(quad[num_quad].op2,val);
else if (colon_quad==3) strcpy(quad[num_quad].res,val);
}
void afficher_qdr()
{
printf("*********************Les Quadruplets***********************\n");
int i;
for(i=0;i<qc;i++)
{
printf("\n %d - ( %s , %s , %s , %s )",i,quad[i].oper,quad[i].op1,quad[i].op2,quad[i].res);
printf("\n--------------------------------------------------------\n");
}
}