-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparser.h
More file actions
71 lines (62 loc) · 1.23 KB
/
parser.h
File metadata and controls
71 lines (62 loc) · 1.23 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
#pragma once
typedef struct _prog Prog;
typedef struct _command command;
Prog* read_file(char* name);
void debug_print (Prog* prog);
typedef enum {
VECTOR = 1,
MAP = 2
} struct_type;
typedef enum {
AVL = 1,
RRB = 2,
FINGER = 4
} implem_type;
typedef enum {
INT = 1,
STRING = 2
} data_type;
typedef enum {
CREATE, UNREF, UPDATE, PUSH, POP, REMOVE, LOOKUP, MERGE, SPLIT, SIZE, DUMP
} cmd_type;
/* note: some fields can be empty */
/* examples:
- obj_out = create()
- obj_out = update(obj_in, index, data)
- obj_out = push(obj_in, data)
- obj_out = pop(obj_in)
- obj_out = remove(obj_in)
- obj_out = merge(obj_in, obj_aux)
- unref(obj_in)
- lookup(obj_in, index)
- size(obj_in)
- dump(obj_in)
- split(obj_in, index, obj_out, obj_aux) */
struct _command {
char is_assign;
char is_mutable;
cmd_type type;
int obj_in;
int obj_out;
int obj_aux;
int index;
union { /* type should be deduced from prog->data_type */
int as_int;
char* as_string;
} data;
union {
int as_int;
char* as_string;
} key;
};
struct _prog {
int nb_var;
struct_type struc;
int implem;
data_type data_type;
data_type key_type;
int init_size;
command** init;
int bench_size;
command** bench;
};