2 * Copyright 2001-2007 Adrian Thurston <thurston@cs.queensu.ca>
5 /* This file is part of Ragel.
7 * Ragel 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 of the License, or
10 * (at your option) any later version.
12 * Ragel 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.
17 * You should have received a copy of the GNU General Public License
18 * along with Ragel; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30 #include "rlgen-dot.h"
47 extern istream *inStream;
48 extern ostream *outStream;
49 extern output_filter *outFilter;
50 extern const char *outputFileName;
52 /* Graphviz dot file generation. */
53 extern bool graphvizDone;
54 extern bool displayPrintables;
56 extern int numSplitPartitions;
59 * Callbacks invoked by the XML data parser.
62 /* Invoked by the parser when the root element is opened. */
63 ostream *dotOpenOutput( char *inputFile )
65 /* Make sure we are not writing to the same file as the input file. */
66 if ( outputFileName != 0 && strcmp( inputFile, outputFileName ) == 0 ) {
67 error() << "output file \"" << outputFileName <<
68 "\" is the same as the input file" << endl;
71 if ( outputFileName != 0 ) {
72 /* Create the filter on the output and open it. */
73 outFilter = new output_filter( outputFileName );
74 outFilter->open( outputFileName, ios::out|ios::trunc );
75 if ( !outFilter->is_open() ) {
76 error() << "error opening " << outputFileName << " for writing" << endl;
80 /* Open the output stream, attaching it to the filter. */
81 outStream = new ostream( outFilter );
84 /* Writing out ot std out. */
90 /* Invoked by the parser when a ragel definition is opened. */
91 CodeGenData *dotMakeCodeGen( char *sourceFileName, char *fsmName,
92 ostream &out, bool wantComplete )
94 CodeGenData *codeGen = new GraphvizDotGen(out);
96 codeGen->sourceFileName = sourceFileName;
97 codeGen->fsmName = fsmName;
98 codeGen->wantComplete = wantComplete;