From: thurston Date: Sat, 15 Nov 2008 03:19:05 +0000 (+0000) Subject: Cleanup of dot code generation. X-Git-Tag: 2.0_alpha~77 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d7b9eaa791cb08a23bad569ace5c14a492c08f80;p=external%2Fragel.git Cleanup of dot code generation. git-svn-id: http://svn.complang.org/ragel/trunk@569 052ea7fc-9027-0410-9066-f65837a77df0 --- diff --git a/ragel/Makefile.in b/ragel/Makefile.in index b9a538c..9a19a3a 100644 --- a/ragel/Makefile.in +++ b/ragel/Makefile.in @@ -39,7 +39,7 @@ CC_SRCS = \ cs-fsmcodegen.cpp cs-tabcodegen.cpp cs-ftabcodegen.cpp cs-flatcodegen.cpp \ cs-fflatcodegen.cpp cs-gotocodegen.cpp cs-fgotocodegen.cpp \ cs-ipgotocodegen.cpp cs-splitcodegen.cpp \ - dot-main.cpp dot-gvdotgen.cpp + dot-gvdotgen.cpp GEN_SRC = version.h rlscan.cpp rlparse.h rlparse.cpp \ xmltags.cpp xmlscan.cpp xmlparse.cpp xmlparse.h diff --git a/ragel/dot-gvdotgen.cpp b/ragel/dot-gvdotgen.cpp index d80f6b7..f6a86c5 100644 --- a/ragel/dot-gvdotgen.cpp +++ b/ragel/dot-gvdotgen.cpp @@ -19,11 +19,59 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "dot-rlgen-dot.h" +#include "ragel.h" #include "dot-gvdotgen.h" #include "gendata.h" -using namespace std; +using std::istream; +using std::ifstream; +using std::ostream; +using std::ios; +using std::cin; +using std::cout; +using std::cerr; +using std::endl; + +/* Invoked by the parser when the root element is opened. */ +ostream *dotOpenOutput( const char *inputFile ) +{ + /* Make sure we are not writing to the same file as the input file. */ + if ( outputFileName != 0 && strcmp( inputFile, outputFileName ) == 0 ) { + error() << "output file \"" << outputFileName << + "\" is the same as the input file" << endl; + } + + if ( outputFileName != 0 ) { + /* Create the filter on the output and open it. */ + outFilter = new output_filter( outputFileName ); + outFilter->open( outputFileName, ios::out|ios::trunc ); + if ( !outFilter->is_open() ) { + error() << "error opening " << outputFileName << " for writing" << endl; + exit(1); + } + + /* Open the output stream, attaching it to the filter. */ + outStream = new ostream( outFilter ); + } + else { + /* Writing out ot std out. */ + outStream = &cout; + } + return outStream; +} + +/* Invoked by the parser when a ragel definition is opened. */ +CodeGenData *dotMakeCodeGen( const char *sourceFileName, const char *fsmName, + ostream &out, bool wantComplete ) +{ + CodeGenData *codeGen = new GraphvizDotGen(out); + + codeGen->sourceFileName = sourceFileName; + codeGen->fsmName = fsmName; + codeGen->wantComplete = wantComplete; + + return codeGen; +} /* Override this so that write statement processing is ignored */ void GraphvizDotGen::writeStatement( InputLoc &, int, char ** ) diff --git a/ragel/dot-main.cpp b/ragel/dot-main.cpp deleted file mode 100644 index 263aa4a..0000000 --- a/ragel/dot-main.cpp +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright 2001-2007 Adrian Thurston - */ - -/* This file is part of Ragel. - * - * Ragel is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * Ragel is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Ragel; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include -#include -#include -#include -#include -#include - -#include "common.h" -#include "dot-rlgen-dot.h" -#include "xmlparse.h" -#include "pcheck.h" -#include "vector.h" -#include "version.h" -#include "dot-gvdotgen.h" - -using std::istream; -using std::ifstream; -using std::ostream; -using std::ios; -using std::cin; -using std::cout; -using std::cerr; -using std::endl; - -/* Io globals. */ -extern istream *inStream; -extern ostream *outStream; -extern output_filter *outFilter; -extern const char *outputFileName; - -/* Graphviz dot file generation. */ -extern bool graphvizDone; -extern bool displayPrintables; - -extern int numSplitPartitions; - -/* - * Callbacks invoked by the XML data parser. - */ - -/* Invoked by the parser when the root element is opened. */ -ostream *dotOpenOutput( const char *inputFile ) -{ - /* Make sure we are not writing to the same file as the input file. */ - if ( outputFileName != 0 && strcmp( inputFile, outputFileName ) == 0 ) { - error() << "output file \"" << outputFileName << - "\" is the same as the input file" << endl; - } - - if ( outputFileName != 0 ) { - /* Create the filter on the output and open it. */ - outFilter = new output_filter( outputFileName ); - outFilter->open( outputFileName, ios::out|ios::trunc ); - if ( !outFilter->is_open() ) { - error() << "error opening " << outputFileName << " for writing" << endl; - exit(1); - } - - /* Open the output stream, attaching it to the filter. */ - outStream = new ostream( outFilter ); - } - else { - /* Writing out ot std out. */ - outStream = &cout; - } - return outStream; -} - -/* Invoked by the parser when a ragel definition is opened. */ -CodeGenData *dotMakeCodeGen( const char *sourceFileName, const char *fsmName, - ostream &out, bool wantComplete ) -{ - CodeGenData *codeGen = new GraphvizDotGen(out); - - codeGen->sourceFileName = sourceFileName; - codeGen->fsmName = fsmName; - codeGen->wantComplete = wantComplete; - - return codeGen; -} diff --git a/ragel/dot-rlgen-dot.h b/ragel/dot-rlgen-dot.h deleted file mode 100644 index 709c4e3..0000000 --- a/ragel/dot-rlgen-dot.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2001-2006 Adrian Thurston - */ - -/* This file is part of Ragel. - * - * Ragel is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * Ragel is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Ragel; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef _RLGENDOT -#define _RLGENDOT - -#include -#include -#include "config.h" -#include "avltree.h" -#include "vector.h" -#include "config.h" - -/* IO filenames and stream. */ -extern bool displayPrintables; -extern bool graphvizDone; -extern int gblErrorCount; - -std::ostream &error(); - -#endif /* _RLGENDOT */ diff --git a/ragel/ragel.h b/ragel/ragel.h index dbbb5de..9b2d8d5 100644 --- a/ragel/ragel.h +++ b/ragel/ragel.h @@ -84,7 +84,10 @@ extern ArgsVector includePaths; extern CodeStyleEnum codeStyle; /* IO filenames and stream. */ +extern bool displayPrintables; extern bool graphvizDone; +extern int gblErrorCount; + /* Options. */ extern int numSplitPartitions; @@ -107,5 +110,4 @@ extern bool graphvizDone; extern int numSplitPartitions; extern bool noLineDirectives; - #endif /* _RAGEL_H */