示例#1
0
void print_actions(int stateno)
{
    register action *p;
    register shifts *sp;
    register int as;

    if (stateno == final_state)
        BtYacc_puts("\t$end  accept\n", verbose_file);

    p = parser[stateno];
    if (p)
    {
        print_shifts(p);
        print_reductions(p, defred[stateno]);
    }

    sp = shift_table[stateno];
    if (sp && sp->nshifts > 0)
    {
        as = accessing_symbol[sp->shift[sp->nshifts - 1]];
        if (ISVAR(as))
            print_gotos(stateno);
    }

    if (tflag > 1)
    {
        BtYacc_puts("\n\n------------ action dump ---------------\n", verbose_file);
        for (p = parser[stateno]; p; p = p->next)
        {
            BtYacc_printf(verbose_file, "\t%-30s  %6s %5d ~ prec %3d, assoc: %3d (%%%-10s), suppress: %d\n",
                        symbol_name[p->symbol],
                        (p->action_code == SHIFT ? "shift" : "reduce"),
                        (p->action_code == SHIFT ? p->number : p->number - 2),
                        p->prec,
                        p->assoc, get_symbol_assoc_str(p->assoc),
                        p->suppressed);
        }
        BtYacc_puts("----------------------------------------\n\n", verbose_file);
    }
}
示例#2
0
void
print_actions(int stateno)
{
	action *p;
	shifts *sp;
	int as;

	if (stateno == final_state)
		fprintf(verbose_file, "\t$end  accept\n");

	p = parser[stateno];
	if (p) {
		print_shifts(p);
		print_reductions(p, defred[stateno]);
	}
	sp = shift_table[stateno];
	if (sp && sp->nshifts > 0) {
		as = accessing_symbol[sp->shift[sp->nshifts - 1]];
		if (ISVAR(as))
			print_gotos(stateno);
	}
}