]> git.saurik.com Git - bison.git/blame - src/graphviz.c
Get rid of broken %no-parser, -n, and --no-parser implementation and
[bison.git] / src / graphviz.c
CommitLineData
35fe0834
PE
1/* Output Graphviz specification of a state machine generated by Bison.
2
3 Copyright (C) 2006 Free Software Foundation, Inc.
4
5 This file is part of Bison, the GNU Compiler Compiler.
6
7 Bison is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
10 any later version.
11
12 Bison is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with Bison; see the file COPYING. If not, write to
19 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 Boston, MA 02110-1301, USA. */
21
22/* Written by Paul Eggert and Satya Kiran Popuri. */
23
24#include <config.h>
25#include "system.h"
26
27#include <quotearg.h>
28
29#include "graphviz.h"
30
31/* Return an unambiguous printable representation for NAME, suitable
32 for C strings. Use slot 2 since the user may use slots 0 and 1. */
33
34static char const *
35quote (char const *name)
36{
37 return quotearg_n_style (2, c_quoting_style, name);
38}
39
40void
41start_graph (FILE *fout)
42{
43 fputs ("digraph Automaton{\n", fout);
44}
45
46void
47output_node (int id, char const *label, FILE *fout)
48{
49 fprintf (fout, "%d[label=%s]\n", id, quote (label));
50}
51
52void
53output_edge (int source, int destination, char const *label,
54 char const *style, FILE *fout)
55{
56 fprintf (fout, "%d->%d[style=%s", source, destination, style);
57 if (label)
58 fprintf (fout, " label=%s", quote (label));
59 fputs ("]\n", fout);
60}
61
62void
63finish_graph (FILE *fout)
64{
65 fputs ("}\n", fout);
66}