-
Notifications
You must be signed in to change notification settings - Fork 0
/
driver.c
62 lines (53 loc) · 1.09 KB
/
driver.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
#include <stdio.h>
#include <stdlib.h>
#include "node.h"
#include "scope.h"
main()
{
int choice;
char buffer[32];
scope_t *top_scope = NULL;
node_t *tmp = NULL;
fprintf(stderr, "0.search 1.search_all 2.insert 3.new_scope 4.del_scope \n");
while (1) {
scanf("%d", &choice);
switch(choice) {
case 0:
scanf("%s", buffer);
tmp = scope_search(top_scope, buffer);
if (tmp != NULL) {
fprintf(stderr, "Found[%s]\n", tmp->name);
}
else {
fprintf(stderr, "Not found[%s]\n", buffer);
}
break;
case 1:
scanf("%s", buffer);
tmp = scope_search_all(top_scope, buffer);
if (tmp != NULL) {
fprintf(stderr, "Found[%s]\n", tmp->name);
}
else {
fprintf(stderr, "Not found[%s]\n", buffer);
}
break;
case 2:
scanf("%s", buffer);
tmp = scope_insert(top_scope, buffer);
if (tmp != NULL) {
fprintf(stderr, "Insert[%s]\n", tmp->name);
}
else {
fprintf(stderr, "Cannot Insert[%s]\n", buffer);
}
break;
case 3:
top_scope = scope_push(top_scope);
break;
case 4:
top_scope = scope_pop(top_scope);
break;
}
}
}