Listing 6: Recursive search function.

struct Symbol
{   char *id;
    struct Symbol *left;
    struct Symbol *right;
};
struct Paramblock
{   char *id;
    struct Symbol *sm;
};
static void membersearchx(struct Paramblock *p, struct Symbol *s)
{
    while (s)
    {
    if (strcmp(p->id,s->id) == 0)
    {
        if (p->sm)
        error("ambiguous member %s\n",p->id);
        p->sm = s;
    }
    if (s->left)
        membersearchx(p,s->left);
    s = s->right;
    }
}
struct Symbol *symbol_membersearch(Symbol *table[], int tablemax, char *id)
{
    struct Paramblock pb;
    int i;

    pb.id = id;
    pb.sm = NULL;
    for (i = 0; i < tablemax; i++)
    {
    membersearchx(pb, table[i]);
    }
    return pb.sm;
}