-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path3_A4_translator.c
727 lines (683 loc) · 23.7 KB
/
3_A4_translator.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
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
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
// Group 03: julius-stabs-back
// Gautam Ahuja, Nistha Singh
#include "3_A4_translator.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
// #include "3_A4.tab.h"
extern void yyerror(char *s); // This function is called when there is a parsing error
extern int yyparse(void);
/**************************************************************************/
/* GLOBAL VARIABLES */
/**************************************************************************/
qArray* quadArray; // pointer to the head of the quad array linked list
var_type_stack var_type; // declare the stack
string_list* string_head; // linked list for string literals
symboltable* globalST; // pointer to Global Symbol Table
symboltable* currST; // pointer to Current Symbol Table
symboltable* new_ST; // pointer to new Symbol Table -- used in function declaration
static int tempCount = 0; // count of the temporary variables
/**************************************************************************/
/* Expression, Statement, and Function Structures */
/**************************************************************************/
// to create a new expression -- all fields are initialized to NULL
expression* create_expression(){
expression* newExp = (expression*)malloc(sizeof(expression));
newExp->isBool = false;
newExp->isArray = false;
newExp->isPtr = false;
newExp->isFunc = false;
newExp->loc = NULL;
newExp->arrBase = NULL;
newExp->trueList = NULL;
newExp->falseList = NULL;
newExp->nextList = (int*)malloc(sizeof(int));
newExp->nextList[0] = -1;
newExp->returnLabel = 0;
return newExp;
}
// to create a new statement
statement* create_statement(){
statement* newStmt = (statement*)malloc(sizeof(statement));
// end of list is -1
newStmt->nextList = (int*)malloc(sizeof(int));
newStmt->nextList[0] = -1;
newStmt->returnLabel = 0;
return newStmt;
}
// backpatch() -- backpatch a list of labels with a label
// nextList is updated by nextInstr() which already increments the count -- no need to increment again
// point directly to the required instruction in quadArray
void backpatch(int* list, int label){
// printf("Backpatching\n");
char str[50];
sprintf(str, "%d", label);
if (str==NULL){
str[0] = '0';
}
// printf("\n\nList[%d]: %d\n\n", i, list[i]);
// list contains the list of labels to be backpatched
int i=0;
while(list[i] != -1){
// printf("List[%d]: %d\n", i, list[i]);
// go to list[i] of quadArray and update the result
// quadArray is a linked list of quad arrays
qArray* curr = quadArray;
while(curr->count != list[i]){
curr = curr->nextQuad;
}
// update the result
curr->arr->result = strdup(str);
// printf("Updated result: %s\n", curr->arr->result);
i=i+1;
}
return;
}
// makelist
int* makelist(int label){
int* list = (int*)malloc(2*sizeof(int));
list[0] = label;
list[1] = -1;
return list;
}
// merge
int* merge(int* list1, int* list2){
// get lengths of both lists
int len1 = 0;
while(list1[len1] != -1){
len1++;
}
int len2 = 0;
while(list2[len2] != -1){
len2++;
}
// create a new list
int* newMerged = (int*)calloc((len1+len2+1), sizeof(int));
int i=0;
while(list1[i] != -1){
newMerged[i] = list1[i];
i++;
}
int j=0;
while(list2[j] != -1){
// Check if list2[j] is already in newMerged
int k;
for (k = 0; k < i; ++k) {
if (newMerged[k] == list2[j]) {
break;
}
}
// If list2[j] is not already in newMerged, add it
if (k == i) {
newMerged[i] = list2[j];
i++;
}
j++;
}
newMerged[i] = -1;
return newMerged;
}
// Bool to Int
expression* bool2int(expression* expr){
if(expr->isBool){
// generate a new temp
expr->loc = gentemp(create_symboltype(TYPE_INT, 1, NULL), NULL);
// backpatch the true list with next instruction
backpatch(expr->trueList, nextInstr());
// emit the quad for true
emit(OP_ASSIGN, "true", NULL, expr->loc->name);
// goto the end of the false list
char str[100];
int pNext = nextInstr()+1;
sprintf(str, "%d", pNext);
emit(OP_GOTO, NULL, NULL, str);
// backpatch the false list with next instruction
backpatch(expr->falseList, nextInstr());
// emit the quad for false
emit(OP_ASSIGN, "false", NULL, expr->loc->name);
}
return expr;
}
// Int to Bool
expression* int2bool(expression* expr){
if(expr->isBool == false){
expr->falseList = makelist(nextInstr());
// emit == 0
emit(OP_EQUALS, expr->loc->name, "0", NULL);
// print_quadArray(quadArray);
expr->trueList = makelist(nextInstr());
// emit goto
emit(OP_GOTO, NULL, NULL, NULL);
}
return expr;
}
/**************************************************************************/
/* VARIABLE STACK */
/**************************************************************************/
// stact initialization
void stack_intialize(var_type_stack *s){
// printf("Initializing Stack\n");
s->top = -1;
}
// push -- add a new type to the stack at end
void push(var_type_stack *s, enum symboltype_enum type){
if(s->top == MAX_STACK-1){
// yyerror("Stack Overflow");
exit(1);
}
s->top++;
s->type[s->top] = type;
// printf("Pushed %d\n", type);
}
// pop -- remove the last type from the stack
enum symboltype_enum pop(var_type_stack *s){
if(s->top == -1){
// yyerror("Stack Underflow");
exit(1);
}
enum symboltype_enum type = s->type[s->top];
s->top--;
return type;
}
// String List initialization -- create a new head
string_list* string_list_initialize(){
string_list* head = (string_list*)malloc(sizeof(string_list));
head->str = NULL;
head->entries = 0;
head->next = NULL;
return head;
}
// insert a new string at the end of the linked list
void ll_insert(string_list* head, char* str){
// check if it is the first entry
if(head->str == NULL){
head->str = strdup(str);
head->entries++;
return;
}
// insert new entry at the end
string_list* temp = (string_list*)malloc(sizeof(string_list));
temp->str = strdup(str);
// compute the number of entries
int count = 0;
string_list* curr = head;
while(curr->next != NULL){
count++;
curr = curr->next;
}
temp->entries = count+1;
temp->next = NULL;
curr->next = temp;
}
// delete the linked list end entry
void ll_delete(string_list* head){
string_list* curr = head;
while(curr != NULL){
string_list* temp = curr;
curr = curr->next;
free(temp);
}
}
/**************************************************************************/
/* SYMBOL TABLE FUNCTIONS */
/**************************************************************************/
// return the size of the type
int get_size(symboltype* type){
if(type == NULL){
return 0;
}
switch(type->type){
case TYPE_VOID:
return size_of_void;
case TYPE_INT:
return size_of_int;
case TYPE_CHAR:
return size_of_char;
case TYPE_PTR:
return size_of_pointer;
case TYPE_ARRAY:
return type->width * get_size(type->ptr);
case TYPE_STRING:
return type->width;
case TYPE_FUNC:
return size_of_pointer;
}
}
// update the size of the symbol table entry
char* printType(symboltype* type){
if(type == NULL){
return "NULL";
}
char* str = NULL;
char* str1 = NULL;
switch(type->type){
case TYPE_VOID:
return "void";
case TYPE_INT:
return "int";
case TYPE_CHAR:
return "char";
case TYPE_PTR:
str = (char*)malloc(sizeof(char)*10);
sprintf(str, "*%s", printType(type->ptr));
return str;
case TYPE_ARRAY:
str1 = (char*)malloc(sizeof(char)*50);
sprintf(str1, "array(%d,%s)", type->width, printType(type->ptr));
return str1;
case TYPE_FUNC:
// TO EDIT: int x (int, char) -> int, etc.
return "function";
case TYPE_STRING:
return "string";
default:
return "NULL";
}
}
// print category of the symbol table entry
char* printCategory(enum category_enum category){
switch(category){
case TYPE_LOCAL:
return "local";
case TYPE_GLOBAL:
return "global";
case TYPE_PARAM:
return "param";
case TYPE_TEMP:
return "temp";
case TYPE_FUNCTION:
return "function";
default:
return "NULL";
}
}
// check the types of two symbol types. 1 == true, 0 == false
int typecheck(symboltype* type1, symboltype* type2){
if(type1 == NULL && type2 == NULL){
return 0;
}
if(type1->type == type2->type){
if(type1->type == TYPE_ARRAY || type1->type == TYPE_PTR){
return typecheck(type1->ptr, type2->ptr);
}
else{
return 1;
}
}
else{
return 0;
}
}
// parent lookup -- lookup in the parent symbol table
symboltableentry* parentLookup(symboltable* currST, char* yytext){
for(int i=0; i < currST->count; i++){ // for all the entries in the symbol table, check if the name matches
if(strcmp((currST->table_entries[i])->name, yytext) == 0){
return (currST->table_entries[i]); // return the entry if found
}
}
return NULL;
}
// lookup if entry exist, create if dont.
symboltableentry *lookup(symboltable* currST, char* yytext){
// printf("\nSymbol %s LookUp in table, %s\n", yytext, currST->name);
for(int i=0; i <currST->count; i++){ // for all the entries in the symbol table, check if the name matches
if(strcmp((currST->table_entries[i])->name, yytext) == 0){
return (currST->table_entries[i]); // return the entry if found
}
}
// check if the entry is in the parent symbol table
if(currST->parent != NULL){
// printf("Symbol not found. Checking in parent table \"%s\"\n", currST->parent->name);
symboltableentry* parentEntry = parentLookup(currST->parent, yytext);
if(parentEntry){
return parentEntry;
}
}
// printf("\nSymbol not found in parent table. Creating a new entry for \"%s\" in %s\n", yytext, currST->name);
// Create a new entry if not found
symboltableentry* entry = (symboltableentry*)malloc(sizeof(symboltableentry));
entry->name = strdup(yytext);
entry->type = NULL;
entry->initial_value = NULL;
entry->size = 0;
entry->offset = 0;
entry->next = NULL;
(currST->parent)?(entry->category = TYPE_LOCAL):(entry->category = TYPE_GLOBAL); // if parent is not null, then it is local, else global
// insert the entry in the symbol table
currST->table_entries = (symboltableentry**)realloc(currST->table_entries, sizeof(symboltableentry)*(currST->count+1));
currST->table_entries[currST->count] = entry;
currST->count++;
return entry;
}
// cretae a new symbol table with ONLY name set
symboltable* create_symboltable(char* name, symboltable* parent){
symboltable* newST = (symboltable*)malloc(sizeof(symboltable));
newST->name = name;
newST->parent = parent;
newST->count = 0;
// newST->tempCount = 0;
newST->paramCount = 0;
newST->_argList = NULL;
newST->table_entries = NULL;
newST->_retVal = NULL;
newST->next = NULL;
newST->returnLabel = 0;
return newST;
}
// create a new symbol type with type. width by default is 1. Pointer is NULL by default
symboltype* create_symboltype(enum symboltype_enum type, int width, symboltype* ptr){
symboltype* newType = (symboltype*)malloc(sizeof(symboltype));
newType->type = type;
newType->width = width;
newType->ptr = ptr;
return newType;
}
// update type and size of of the symbol table entry
void update_type(symboltableentry* entry, symboltype* type){
// printf("Pointer to entry: %p\n", entry);
// printf("Pointer to type: %p\n", type);
entry->type = type;
entry->size = get_size(type);
// printf("Updated type of %s to %s\n", entry->name, printType(type));
return;
}
// generate a temporary variable.
// the lookup function generates and stores the entry in currentST.
symboltableentry* gentemp(symboltype* type, char* initial_value) {
char tempName[20];
sprintf(tempName, "t%d", tempCount++);
// Lookup or create a new entry for the temporary variable
symboltableentry* tempEntry = lookup(currST, tempName);
// Update type and initial value
update_type(tempEntry, type);
(initial_value==NULL)?(tempEntry->initial_value = NULL):(tempEntry->initial_value = strdup(initial_value));
tempEntry->category = TYPE_TEMP;
return tempEntry;
}
// generate pramaeter type
// the lookup function generates and stores the entry in currentST.
symboltableentry* genparam(symboltype* type, char* initial_value) {
char paramName[20];
sprintf(paramName, "para%d", currST->paramCount++);
// Lookup or create a new entry for the temporary variable
symboltableentry* paramEntry = lookup(currST, paramName);
// Update type and initial value
update_type(paramEntry, type);
(initial_value==NULL)?(paramEntry->initial_value = NULL):(paramEntry->initial_value = strdup(initial_value));
paramEntry->category = TYPE_PARAM;
return paramEntry;
}
// add a new argument to the argument list of the function. Linked List end addition
void push_args(symboltable* currST, symboltableentry* arg){
if(currST->_argList == NULL){
currST->_argList = (symboltableentry**)malloc(sizeof(symboltableentry*));
currST->_argList[0] = arg;
return;
}
int count = 0;
while(currST->_argList[count] != NULL){
count++;
}
currST->_argList = (symboltableentry**)realloc(currST->_argList, sizeof(symboltableentry*)*(count+1));
currST->_argList[count] = arg;
return;
}
// Update count of return label
void update_return_ST(symboltable* currST, int update){
currST->returnLabel += update;
return;
}
// add a new entry to the symbol table
void update_ST(symboltable* currST, symboltableentry* entry){
currST->table_entries = (symboltableentry**)realloc(currST->table_entries, sizeof(symboltableentry)*(currST->count+1));
currST->table_entries[currST->count] = entry;
currST->count++;
return;
}
void print_ST(symboltable *currST){
printf("\n\n==================================================================================================================\n");
(currST->parent) ? printf("Symbol Table: %-50s Parent: ST.%s\n", currST->name, currST->parent->name) : printf("Symbol Table: %-35s Parent: NULL\n", currST->name);
printf("------------------------------------------------------------------------------------------------------------------\n");
printf("%-15s%-15s%-20s%-20s%-15s%-15s%-20s\n", "Name", "Type", "Category", "Initial Value", "Size", "Offset", "Nested Table");
printf("------------------------------------------------------------------------------------------------------------------\n");
for(int i=0; i< currST->count; i++){
symboltableentry* entry = (currST->table_entries[i]);
printf("%-15s", entry->name);
printf("%-15s", printType(entry->type));
printf("%-20s", printCategory(entry->category));
(entry->initial_value) ? printf("%-20s", entry->initial_value) : printf("%-20s", "-");
printf("%-15d", entry->size);
printf("%-15d", entry->offset); // offset is not updated
if(entry->next != NULL){
printf("%-20s\n", entry->next->name);
}
else{
printf("-\n");
}
}
// printf("\n");
printf("==================================================================================================================\n");
// print the nested symbol tables
for(int i=0; i< currST->count; i++){
symboltableentry* entry = (currST->table_entries[i]);
if(entry->next != NULL && entry->category == TYPE_FUNCTION){
print_ST(entry->next);
printf("\n");
}
}
}
/**************************************************************************/
/* QUADS and TAC */
/**************************************************************************/
// Operator Codes -- char* op
char* printOP(enum op_code op){
switch(op){
case OP_PLUS:
return "+";
case OP_MINUS:
return "-";
case OP_MULT:
return "*";
case OP_DIV:
return "/";
case OP_MOD:
return "\%";
case OP_EQUALS:
return "==";
case OP_NOT_EQUALS:
return "!=";
case OP_LT:
return "<";
case OP_LT_EQUALS:
return "<=";
case OP_GT:
return ">";
case OP_GT_EQUALS:
return ">=";
case OP_GOTO:
return "goto";
case OP_ASSIGN:
return "=";
case OP_ASSIGN_STR:
return "=str";
case OP_ASSIGN_AMPER:
return "=&";
case OP_ASSIGN_ASTERISK:
return "=*";
case OP_ASTERISK_ASSIGN:
return "*=";
case OP_UMINUS:
return "uminus";
case OP_ASSIGN_BOX:
return "=[]";
case OP_BOX_ASSIGN:
return "[]=";
case OP_RETURN:
case OP_RETURN_VOID:
return "return";
case OP_PARAM:
return "param";
case OP_CALL:
case OP_CALL_VOID:
return "call";
case OP_FUNC:
return "function";
case OP_LABEL:
return "label";
default:
return "NULL";
}
}
// print the quad
void print_quad(quad* arr){
switch(arr->op){
case OP_PLUS:
case OP_MINUS:
case OP_MULT:
case OP_DIV:
case OP_MOD:
printf("%s = %s %s %s\n", arr->result, arr->arg1, printOP(arr->op), arr->arg2);
break;
case OP_EQUALS:
case OP_NOT_EQUALS:
case OP_LT:
case OP_LT_EQUALS:
case OP_GT:
case OP_GT_EQUALS:
printf("if %s %s %s goto %s\n", arr->arg1, printOP(arr->op), arr->arg2, arr->result);
break;
case OP_GOTO:
printf("goto %s\n", arr->result);
break;
case OP_ASSIGN:
printf("%s = %s\n", arr->result , arr->arg1);
break;
case OP_ASSIGN_STR:
printf("%s = string(%s)\n", arr->result, arr->arg1);
break;
case OP_ASSIGN_AMPER:
printf("%s = &%s\n", arr->result, arr->arg1);
break;
case OP_ASSIGN_ASTERISK:
printf("%s = *%s\n", arr->result, arr->arg1);
break;
case OP_ASTERISK_ASSIGN:
printf("*%s = %s\n", arr->result, arr->arg1);
break;
case OP_UMINUS:
printf("%s = -%s\n", arr->result, arr->arg1);
break;
case OP_ASSIGN_BOX:
printf("%s = %s[%s]\n", arr->result, arr->arg1, arr->arg2);
break;
case OP_BOX_ASSIGN:
printf("%s[%s] = %s\n", arr->result, arr->arg1, arr->arg2);
break;
case OP_RETURN:
printf("return %s\n", arr->result);
break;
case OP_RETURN_VOID:
printf("return\n");
break;
case OP_PARAM:
printf("param %s\n", arr->result);
break;
case OP_CALL:
printf("%s = call %s, %s\n", arr->result, arr->arg1, arr->arg2);
break;
case OP_CALL_VOID:
printf("call %s, %s\n", arr->arg1, arr->arg2);
break;
case OP_FUNC:
printf("function %s:\n", arr->result);
break;
case OP_LABEL:
printf("%s:\n", arr->result);
break;
case OP_ENDFUNC:
printf("end %s\n", arr->result);
break;
default:
printf("NULL\n");
}
}
// print the quad array -- this function prints the Three Address Code
void print_quadArray(qArray* head){
qArray* curr = head;
printf("=============================================================================================================\n");
printf("THREE ADDRESS CODE\n");
printf("-------------------------------------------------------------------------------------------------------------\n");
// if empty
if(curr->arr == NULL){
printf("NULL\n");
printf("\n=============================================================================================================\n\n");
return;
}
while(curr != NULL && curr->count != 0){
printf("%d: ", curr->count);
print_quad(curr->arr);
curr = curr->nextQuad;
}
printf("\n=============================================================================================================\n\n");
}
// initilize quadArray
qArray* quadArray_initialize(qArray* head){
head = (qArray*)malloc(sizeof(qArray));
head->arr = NULL;
head->count = 1;
head->nextQuad = NULL;
return head;
}
// Emit a quad -- add to quadArray
void emit(enum op_code op, char* arg1, char* arg2, char* result){
// initial case -- nextQuad is NULL
if(quadArray->arr == NULL){
quadArray->arr = (quad*)malloc(sizeof(quad));
quadArray->arr->op = op;
(arg1 == NULL)?(quadArray->arr->arg1 = NULL):(quadArray->arr->arg1 = strdup(arg1));
(arg2 == NULL)?(quadArray->arr->arg2 = NULL):(quadArray->arr->arg2 = strdup(arg2));
(result == NULL)?(quadArray->arr->result = NULL):(quadArray->arr->result = strdup(result));
quadArray->nextQuad = NULL;
return;
}
// if the quadArray is not empty, then add the quad to the end of the linked list
qArray* curr = quadArray;
while(curr->nextQuad != NULL){
curr = curr->nextQuad;
}
curr->nextQuad = (qArray*)malloc(sizeof(qArray));
curr->nextQuad->arr = (quad*)malloc(sizeof(quad));
curr->nextQuad->arr->op = op;
(arg1 == NULL)?(curr->nextQuad->arr->arg1 = NULL):(curr->nextQuad->arr->arg1 = strdup(arg1));
(arg2 == NULL)?(curr->nextQuad->arr->arg2 = NULL):(curr->nextQuad->arr->arg2 = strdup(arg2));
(result == NULL)?(curr->nextQuad->arr->result = NULL):(curr->nextQuad->arr->result = strdup(result));
curr->nextQuad->count = curr->count + 1;
curr->nextQuad->nextQuad = NULL;
return;
}
// Get the next instruction number. Quad Starts at 1. Next instruction is the count of the last quad + 1
int nextInstr(){
qArray* curr = quadArray;
while(curr->nextQuad != NULL){
curr = curr->nextQuad;
}
return curr->count+1;
}
int main(){
printf("Initializing Symbol Tables\n");
globalST = create_symboltable("Global", NULL);
currST = globalST;
stack_intialize(&var_type);
string_head = string_list_initialize();
quadArray = quadArray_initialize(quadArray);
// gentemp test
// symboltableentry* temp = gentemp(create_symboltype(TYPE_INT, 1, NULL), "69");
// gentemp update test
printf("Starting Parser\n");
yyparse();
printf("Global Symbol Table:\n");
print_ST(globalST);
printf("\n\n\n");
print_quadArray(quadArray);
return 0;
}