Example #1
0
void cook(struct s_node *g) {
    char *newname;
    int l;

    dexpr(g, 0, 0);
    cook0(g);
    l = strlen(g->text) + strlen("_feed") + 1;
    newname = realloc(0, l);
    if (!newname) nomem();
    strcpy(newname, g->text);
    strcat(newname, "_feed");
    g->text = newname;
    check_recursion(g);
}
Example #2
0
File: cook.c Project: 8l/pacc
/* make all rules void, and remove all expr nodes */
static void dexpr(struct s_node *n, struct s_node *par, struct s_node *sib) {
    struct s_node *p, *q;
    if (n->type == expr) {
	assert(par || sib);
	if (sib)
            sib->next = n->next;
        else
            par->first = 0;
	free(n); /* XXX and its children */
    }

    /* XXX in principle, we could remove all bindings *except* those
     * used in guards. */

    if (s_has_children(n->type))
	for (p = 0, q = n->first; q; p = q, q = q->next)
	    dexpr(q, n, p);
}