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
|
#include "div.h"
#include "gl.h"
#include "im.h"
#include "lk.h"
#include "pr.h"
#include "td.h"
#include "ws.h"
static const struct seq linkage =
{(struct step[]){{ID, "linkage"}, {0}}, .fn = lk},
types = {(struct step[]){{ID, "types"}, {0}}, .fn = td},
imports =
{(struct step[]){{ID, "imports"}, {LIT, NULL, 1}, {0}}, .fn = im},
procedure = {(struct step[]){{ID, "procedure"}, {0}}, .fn = pr};
static const struct seq fnseq[] =
{
linkage,
types,
imports,
procedure,
{(struct step[]){{ID, "storage"}, {0}}, .fn = ws},
{(struct step[]){{ID, "globals"}, {0}}, .fn = gl},
{0}
};
static const struct seq imseq[] =
{
linkage,
types,
imports,
{0}
};
static const struct seq pseq[] =
{
linkage,
procedure,
{0}
};
int div_fn(const struct lex *l, struct prv *p)
{
struct pos init =
{
.seq = fnseq,
.stseq = fnseq,
.step = fnseq->steps
};
if (push(&init, p))
return -1;
p->stk = p->tk;
return 0;
}
int div_im(const struct lex *l, struct prv *p)
{
struct pos init =
{
.seq = imseq,
.stseq = imseq,
.step = imseq->steps
};
if (lex_eof(l, p->stk))
return 0;
else if (push(&init, p))
return -1;
p->stk = p->tk;
return 1;
}
int div_p(const struct lex *l, struct prv *p)
{
struct pos init =
{
.seq = pseq,
.stseq = pseq,
.step = pseq->steps
};
if (push(&init, p))
return -1;
p->stk = p->tk;
return 1;
}
|