1 /* $Id: graph.c,v 1.8 2014/02/19 00:46:57 Tom.Shields Exp $ */
5 static void graph_state(int stateno);
6 static void graph_LA(int ruleno);
8 static unsigned int larno;
22 for (i = 0; i < nstates; ++i)
24 closure(state_table[i]->items, state_table[i]->nitems);
28 fprintf(graph_file, "\n\n");
29 for (i = 0; i < nstates; ++i)
34 for (j = 0; j < sp->nshifts; ++j)
37 as = accessing_symbol[sn];
39 "\tq%d -> q%d [label=\"%s\"];\n",
40 i, sn, symbol_pname[as]);
44 fprintf(graph_file, "}\n");
46 for (i = 0; i < nsyms; ++i)
47 FREE(symbol_pname[i]);
52 graph_state(int stateno)
59 larno = (unsigned)lookaheads[stateno];
60 fprintf(graph_file, "\n\tq%d [label=\"%d:\\l", stateno, stateno);
62 for (isp = itemset; isp < itemsetend; isp++)
64 sp1 = sp = ritem + *isp;
69 fprintf(graph_file, " %s -> ", symbol_pname[rlhs[rule]]);
71 for (sp = ritem + rrhs[rule]; sp < sp1; sp++)
72 fprintf(graph_file, "%s ", symbol_pname[*sp]);
74 putc('.', graph_file);
78 fprintf(graph_file, " %s", symbol_pname[*sp]);
85 fprintf(graph_file, "\\l");
87 fprintf(graph_file, "\"];");
94 unsigned tokensetsize;
97 tokensetsize = (unsigned)WORDSIZE(ntokens);
99 if (ruleno == LAruleno[larno])
101 rowp = LA + larno * tokensetsize;
103 fprintf(graph_file, " { ");
104 for (i = ntokens - 1; i >= 0; i--)
107 fprintf(graph_file, "%s ", symbol_pname[i]);
109 fprintf(graph_file, "}");