-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstaticsem.c
More file actions
36 lines (31 loc) · 745 Bytes
/
staticsem.c
File metadata and controls
36 lines (31 loc) · 745 Bytes
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
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "staticsem.h"
#include "tree.h"
#include "node.h"
#include "token.h"
#include "pop.h"
#include "stack.h"
int
staticsem(node_t* root)
{
//traversepreorder(root);
stack_t* stack = (stack_t*) malloc(sizeof(stack_t));
if (stack == (stack_t*)NULL) {
return -1;
}
stack->varstack = (token_t**) malloc(256*sizeof(token_t*));
stack->nvars = 0;
stack->tos = -1;
//buildglobalstack(root, stack);
int stk = buildglobalstack(root, stack);
if (stk > 0)
return stk;
printf("Num Vars = %d \n", stack->nvars);
int i;
for (i = 0; i < stack->nvars; i++) {
displaytoken(stack->varstack[i]);
}
return 0;
}