1 /* $Id: graph.c,v 1.9 2020/09/10 17:22:51 tom 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)
57 larno = (unsigned)lookaheads[stateno];
58 fprintf(graph_file, "\n\tq%d [label=\"%d:\\l", stateno, stateno);
60 for (isp = itemset; isp < itemsetend; isp++)
65 sp1 = sp = ritem + *isp;
70 fprintf(graph_file, " %s -> ", symbol_pname[rlhs[rule]]);
72 for (sp = ritem + rrhs[rule]; sp < sp1; sp++)
73 fprintf(graph_file, "%s ", symbol_pname[*sp]);
75 putc('.', graph_file);
79 fprintf(graph_file, " %s", symbol_pname[*sp]);
86 fprintf(graph_file, "\\l");
88 fprintf(graph_file, "\"];");
94 unsigned tokensetsize;
96 tokensetsize = (unsigned)WORDSIZE(ntokens);
98 if (ruleno == LAruleno[larno])
101 unsigned *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, "}");