-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathdcc.h
92 lines (73 loc) · 1.45 KB
/
dcc.h
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
#ifndef __DCC_H
#define __DCC_H
typedef struct token token;
typedef struct string string;
typedef struct operator operator;
enum { ALLOC_SIZE = 1024, NAME_LEN = 255, STR_LEN = 1024, MAX_NAME = 1024,
MAX_PARAM = 32, MAX_VAL = 2048, MAX_OP = 3072, MAX_TOK = 2048 };
/* string literal */
struct string {
char name[NAME_LEN];
char str[STR_LEN];
};
struct operator {
int prec;
int assoc;
};
struct token {
int type;
int idx; /* index to arrays below */
};
/* shunting yard stack and output */
typedef struct opstack opstack;
typedef struct output output;
typedef struct decass decass;
struct opstack {
unsigned int sp;
token tok[MAX_TOK];
};
struct output {
unsigned int nout;
token tok[MAX_TOK];
};
struct decass {
unsigned int nout;
token tok[3];
};
typedef struct symlist symlist;
struct symlist {
int size;
int nidt;
int ebpx;
int *idt;
union {
int *ebp;
int *type;
};
symlist *prev;
symlist *next;
};
typedef struct call call;
struct call {
int idt;
int nparam;
output *param[MAX_PARAM];
};
/* token type stack for code generation */
typedef struct symst symst;
struct symst {
int n;
int *s;
};
typedef struct loopch loopch;
struct loopch {
int type;
int label;
loopch *next;
};
void block(void);
int declare(int scope);
void undeclare(void);
void eval_expr(output *out);
void shunting_yard(output *out, int condexp, int *param);
#endif