2016-09-20 22:43:10 +00:00
|
|
|
static void dumpCover(NODEPTR_TYPE p, int goalnt, int indent) {
|
|
|
|
#ifdef TRACE
|
|
|
|
int eruleno = burm_rule(STATE_LABEL(p), goalnt);
|
2016-09-24 14:59:49 +00:00
|
|
|
const short *nts = burm_nts[eruleno];
|
2016-09-20 22:43:10 +00:00
|
|
|
NODEPTR_TYPE kids[10];
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < indent; i++)
|
|
|
|
fprintf(stderr, " ");
|
|
|
|
fprintf(stderr, "%s\n", burm_string[eruleno]);
|
|
|
|
burm_kids(p, eruleno, kids);
|
|
|
|
for (i = 0; nts[i]; i++)
|
2016-09-24 11:08:17 +00:00
|
|
|
{
|
|
|
|
if (kids[i])
|
|
|
|
dumpCover(kids[i], nts[i], indent + 1);
|
|
|
|
else
|
|
|
|
fprintf(stderr, "failed!\n");
|
|
|
|
}
|
2016-09-20 22:43:10 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2016-09-24 20:46:08 +00:00
|
|
|
#if 0
|
2016-09-20 22:43:10 +00:00
|
|
|
static NODEPTR_TYPE tree(int op, NODEPTR_TYPE l, NODEPTR_TYPE r) {
|
|
|
|
NODEPTR_TYPE p = malloc(sizeof *p);
|
|
|
|
|
|
|
|
assert(p);
|
|
|
|
p->op = op;
|
|
|
|
p->kids[0] = l; p->kids[1] = r;
|
|
|
|
return p;
|
|
|
|
}
|
|
|
|
|
|
|
|
int main(void) {
|
|
|
|
NODEPTR_TYPE p;
|
|
|
|
|
2016-09-24 16:31:35 +00:00
|
|
|
p = tree(STORE4,
|
|
|
|
tree(ADD4,
|
|
|
|
tree(LABEL4, 0, 0),
|
|
|
|
tree(CONST4, 0, 0)
|
2016-09-24 11:33:59 +00:00
|
|
|
),
|
2016-09-24 16:31:35 +00:00
|
|
|
tree(ADD4,
|
|
|
|
tree(LOAD4,
|
|
|
|
tree(LABEL4, 0, 0),
|
2016-09-20 22:43:10 +00:00
|
|
|
0
|
|
|
|
),
|
2016-09-24 16:31:35 +00:00
|
|
|
tree(CONST4, 0, 0)
|
2016-09-20 22:43:10 +00:00
|
|
|
)
|
|
|
|
);
|
|
|
|
burm_label(p);
|
|
|
|
dumpCover(p, 1, 0);
|
|
|
|
return 0;
|
|
|
|
}
|
2016-09-24 20:46:08 +00:00
|
|
|
#endif
|
2016-09-20 22:43:10 +00:00
|
|
|
|