1 /* $NetBSD: graph.c,v 1.5 2015/01/03 23:22:52 christos Exp $ */
4 /* Id: graph.c,v 1.8 2014/02/19 00:46:57 Tom.Shields Exp */
7 __RCSID("$NetBSD: graph.c,v 1.5 2015/01/03 23:22:52 christos Exp $");
9 static void graph_state(int stateno
);
10 static void graph_LA(int ruleno
);
12 static unsigned int larno
;
26 for (i
= 0; i
< nstates
; ++i
)
28 closure(state_table
[i
]->items
, state_table
[i
]->nitems
);
32 fprintf(graph_file
, "\n\n");
33 for (i
= 0; i
< nstates
; ++i
)
38 for (j
= 0; j
< sp
->nshifts
; ++j
)
41 as
= accessing_symbol
[sn
];
43 "\tq%d -> q%d [label=\"%s\"];\n",
44 i
, sn
, symbol_pname
[as
]);
48 fprintf(graph_file
, "}\n");
50 for (i
= 0; i
< nsyms
; ++i
)
51 FREE(symbol_pname
[i
]);
56 graph_state(int stateno
)
63 larno
= (unsigned)lookaheads
[stateno
];
64 fprintf(graph_file
, "\n\tq%d [label=\"%d:\\l", stateno
, stateno
);
66 for (isp
= itemset
; isp
< itemsetend
; isp
++)
68 sp1
= sp
= ritem
+ *isp
;
73 fprintf(graph_file
, " %s -> ", symbol_pname
[rlhs
[rule
]]);
75 for (sp
= ritem
+ rrhs
[rule
]; sp
< sp1
; sp
++)
76 fprintf(graph_file
, "%s ", symbol_pname
[*sp
]);
78 putc('.', graph_file
);
82 fprintf(graph_file
, " %s", symbol_pname
[*sp
]);
89 fprintf(graph_file
, "\\l");
91 fprintf(graph_file
, "\"];");
98 unsigned tokensetsize
;
101 tokensetsize
= (unsigned)WORDSIZE(ntokens
);
103 if (ruleno
== LAruleno
[larno
])
105 rowp
= LA
+ larno
* tokensetsize
;
107 fprintf(graph_file
, " { ");
108 for (i
= ntokens
- 1; i
>= 0; i
--)
111 fprintf(graph_file
, "%s ", symbol_pname
[i
]);
113 fprintf(graph_file
, "}");