From f7db920d14756df3bbdc3d529485438d26fd74c9 Mon Sep 17 00:00:00 2001 From: thurston Date: Sat, 15 Nov 2008 00:25:15 +0000 Subject: [PATCH] Removed the now missing makefiles from the list of files to generate in the configure script. Changed the csharp- prefix to cs-. Remove the cs-rlgen-csharp.h and cs-main.cpp files. git-svn-id: http://svn.complang.org/ragel/trunk@566 052ea7fc-9027-0410-9066-f65837a77df0 --- configure | 9 +- configure.in | 2 +- ragel/Makefile.in | 7 +- ...csharp-fflatcodegen.cpp => cs-fflatcodegen.cpp} | 4 +- ragel/{csharp-fflatcodegen.h => cs-fflatcodegen.h} | 2 +- ...csharp-fgotocodegen.cpp => cs-fgotocodegen.cpp} | 4 +- ragel/{csharp-fgotocodegen.h => cs-fgotocodegen.h} | 2 +- .../{csharp-flatcodegen.cpp => cs-flatcodegen.cpp} | 4 +- ragel/{csharp-flatcodegen.h => cs-flatcodegen.h} | 2 +- ragel/{csharp-fsmcodegen.cpp => cs-fsmcodegen.cpp} | 105 +++++++++++++- ragel/{csharp-fsmcodegen.h => cs-fsmcodegen.h} | 0 .../{csharp-ftabcodegen.cpp => cs-ftabcodegen.cpp} | 4 +- ragel/{csharp-ftabcodegen.h => cs-ftabcodegen.h} | 2 +- .../{csharp-gotocodegen.cpp => cs-gotocodegen.cpp} | 4 +- ragel/{csharp-gotocodegen.h => cs-gotocodegen.h} | 2 +- ...harp-ipgotocodegen.cpp => cs-ipgotocodegen.cpp} | 4 +- .../{csharp-ipgotocodegen.h => cs-ipgotocodegen.h} | 2 +- ragel/{csharp-rlgen-csharp.h => cs-main.cpp} | 34 ++--- ...csharp-splitcodegen.cpp => cs-splitcodegen.cpp} | 4 +- ragel/{csharp-splitcodegen.h => cs-splitcodegen.h} | 2 +- ragel/{csharp-tabcodegen.cpp => cs-tabcodegen.cpp} | 4 +- ragel/{csharp-tabcodegen.h => cs-tabcodegen.h} | 2 +- ragel/csharp-main.cpp | 155 --------------------- ragel/ragel.h | 27 ++++ 24 files changed, 170 insertions(+), 217 deletions(-) rename ragel/{csharp-fflatcodegen.cpp => cs-fflatcodegen.cpp} (99%) rename ragel/{csharp-fflatcodegen.h => cs-fflatcodegen.h} (98%) rename ragel/{csharp-fgotocodegen.cpp => cs-fgotocodegen.cpp} (99%) rename ragel/{csharp-fgotocodegen.h => cs-fgotocodegen.h} (98%) rename ragel/{csharp-flatcodegen.cpp => cs-flatcodegen.cpp} (99%) rename ragel/{csharp-flatcodegen.h => cs-flatcodegen.h} (98%) rename ragel/{csharp-fsmcodegen.cpp => cs-fsmcodegen.cpp} (86%) rename ragel/{csharp-fsmcodegen.h => cs-fsmcodegen.h} (100%) rename ragel/{csharp-ftabcodegen.cpp => cs-ftabcodegen.cpp} (99%) rename ragel/{csharp-ftabcodegen.h => cs-ftabcodegen.h} (98%) rename ragel/{csharp-gotocodegen.cpp => cs-gotocodegen.cpp} (99%) rename ragel/{csharp-gotocodegen.h => cs-gotocodegen.h} (99%) rename ragel/{csharp-ipgotocodegen.cpp => cs-ipgotocodegen.cpp} (99%) rename ragel/{csharp-ipgotocodegen.h => cs-ipgotocodegen.h} (98%) rename ragel/{csharp-rlgen-csharp.h => cs-main.cpp} (66%) rename ragel/{csharp-splitcodegen.cpp => cs-splitcodegen.cpp} (99%) rename ragel/{csharp-splitcodegen.h => cs-splitcodegen.h} (98%) rename ragel/{csharp-tabcodegen.cpp => cs-tabcodegen.cpp} (99%) rename ragel/{csharp-tabcodegen.h => cs-tabcodegen.h} (99%) delete mode 100644 ragel/csharp-main.cpp diff --git a/configure b/configure index d899390..e38dc5a 100755 --- a/configure +++ b/configure @@ -3561,7 +3561,7 @@ _ACEOF fi -ac_config_files="$ac_config_files Makefile common/Makefile ragel/Makefile redfsm/Makefile rlgen-cd/Makefile rlgen-java/Makefile rlgen-ruby/Makefile rlgen-dot/Makefile rlgen-csharp/Makefile doc/Makefile test/Makefile" +ac_config_files="$ac_config_files Makefile ragel/Makefile doc/Makefile test/Makefile" cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure @@ -4117,14 +4117,7 @@ do case $ac_config_target in "ragel/config.h") CONFIG_HEADERS="$CONFIG_HEADERS ragel/config.h" ;; "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; - "common/Makefile") CONFIG_FILES="$CONFIG_FILES common/Makefile" ;; "ragel/Makefile") CONFIG_FILES="$CONFIG_FILES ragel/Makefile" ;; - "redfsm/Makefile") CONFIG_FILES="$CONFIG_FILES redfsm/Makefile" ;; - "rlgen-cd/Makefile") CONFIG_FILES="$CONFIG_FILES rlgen-cd/Makefile" ;; - "rlgen-java/Makefile") CONFIG_FILES="$CONFIG_FILES rlgen-java/Makefile" ;; - "rlgen-ruby/Makefile") CONFIG_FILES="$CONFIG_FILES rlgen-ruby/Makefile" ;; - "rlgen-dot/Makefile") CONFIG_FILES="$CONFIG_FILES rlgen-dot/Makefile" ;; - "rlgen-csharp/Makefile") CONFIG_FILES="$CONFIG_FILES rlgen-csharp/Makefile" ;; "doc/Makefile") CONFIG_FILES="$CONFIG_FILES doc/Makefile" ;; "test/Makefile") CONFIG_FILES="$CONFIG_FILES test/Makefile" ;; diff --git a/configure.in b/configure.in index 7bc0195..2fb505e 100644 --- a/configure.in +++ b/configure.in @@ -119,6 +119,6 @@ if test -n "$GMCS"; then fi dnl write output files -AC_OUTPUT(Makefile common/Makefile ragel/Makefile redfsm/Makefile rlgen-cd/Makefile rlgen-java/Makefile rlgen-ruby/Makefile rlgen-dot/Makefile rlgen-csharp/Makefile doc/Makefile test/Makefile) +AC_OUTPUT(Makefile ragel/Makefile doc/Makefile test/Makefile) echo "configuration of ragel complete" diff --git a/ragel/Makefile.in b/ragel/Makefile.in index 02f2b7c..970cb4e 100644 --- a/ragel/Makefile.in +++ b/ragel/Makefile.in @@ -36,10 +36,9 @@ CC_SRCS = \ java-main.cpp java-javacodegen.cpp \ ruby-main.cpp ruby-codegen.cpp ruby-tabcodegen.cpp ruby-ftabcodegen.cpp \ ruby-flatcodegen.cpp ruby-fflatcodegen.cpp ruby-rbx-gotocodegen.cpp \ - csharp-main.cpp csharp-fsmcodegen.cpp \ - csharp-tabcodegen.cpp csharp-ftabcodegen.cpp csharp-flatcodegen.cpp \ - csharp-fflatcodegen.cpp csharp-gotocodegen.cpp csharp-fgotocodegen.cpp \ - csharp-ipgotocodegen.cpp csharp-splitcodegen.cpp \ + 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 GEN_SRC = version.h rlscan.cpp rlparse.h rlparse.cpp \ diff --git a/ragel/csharp-fflatcodegen.cpp b/ragel/cs-fflatcodegen.cpp similarity index 99% rename from ragel/csharp-fflatcodegen.cpp rename to ragel/cs-fflatcodegen.cpp index a307159..10b50d5 100644 --- a/ragel/csharp-fflatcodegen.cpp +++ b/ragel/cs-fflatcodegen.cpp @@ -21,8 +21,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "csharp-rlgen-csharp.h" -#include "csharp-fflatcodegen.h" +#include "ragel.h" +#include "cs-fflatcodegen.h" #include "redfsm.h" #include "gendata.h" diff --git a/ragel/csharp-fflatcodegen.h b/ragel/cs-fflatcodegen.h similarity index 98% rename from ragel/csharp-fflatcodegen.h rename to ragel/cs-fflatcodegen.h index a5007b9..03f7bcd 100644 --- a/ragel/csharp-fflatcodegen.h +++ b/ragel/cs-fflatcodegen.h @@ -25,7 +25,7 @@ #define _FFLATCODEGEN_H #include -#include "csharp-flatcodegen.h" +#include "cs-flatcodegen.h" /* Forwards. */ struct CodeGenData; diff --git a/ragel/csharp-fgotocodegen.cpp b/ragel/cs-fgotocodegen.cpp similarity index 99% rename from ragel/csharp-fgotocodegen.cpp rename to ragel/cs-fgotocodegen.cpp index 906419c..266d902 100644 --- a/ragel/csharp-fgotocodegen.cpp +++ b/ragel/cs-fgotocodegen.cpp @@ -21,8 +21,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "csharp-rlgen-csharp.h" -#include "csharp-fgotocodegen.h" +#include "ragel.h" +#include "cs-fgotocodegen.h" #include "redfsm.h" #include "gendata.h" #include "bstmap.h" diff --git a/ragel/csharp-fgotocodegen.h b/ragel/cs-fgotocodegen.h similarity index 98% rename from ragel/csharp-fgotocodegen.h rename to ragel/cs-fgotocodegen.h index 283b827..2d300b4 100644 --- a/ragel/csharp-fgotocodegen.h +++ b/ragel/cs-fgotocodegen.h @@ -25,7 +25,7 @@ #define _FGOTOCODEGEN_H #include -#include "csharp-gotocodegen.h" +#include "cs-gotocodegen.h" /* Forwards. */ struct CodeGenData; diff --git a/ragel/csharp-flatcodegen.cpp b/ragel/cs-flatcodegen.cpp similarity index 99% rename from ragel/csharp-flatcodegen.cpp rename to ragel/cs-flatcodegen.cpp index c59bfb4..0dc3fa4 100644 --- a/ragel/csharp-flatcodegen.cpp +++ b/ragel/cs-flatcodegen.cpp @@ -21,8 +21,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "csharp-rlgen-csharp.h" -#include "csharp-flatcodegen.h" +#include "ragel.h" +#include "cs-flatcodegen.h" #include "redfsm.h" #include "gendata.h" diff --git a/ragel/csharp-flatcodegen.h b/ragel/cs-flatcodegen.h similarity index 98% rename from ragel/csharp-flatcodegen.h rename to ragel/cs-flatcodegen.h index ae3eadf..6efbff5 100644 --- a/ragel/csharp-flatcodegen.h +++ b/ragel/cs-flatcodegen.h @@ -25,7 +25,7 @@ #define _FLATCODEGEN_H #include -#include "csharp-fsmcodegen.h" +#include "cs-fsmcodegen.h" /* Forwards. */ struct CodeGenData; diff --git a/ragel/csharp-fsmcodegen.cpp b/ragel/cs-fsmcodegen.cpp similarity index 86% rename from ragel/csharp-fsmcodegen.cpp rename to ragel/cs-fsmcodegen.cpp index 35319a0..939e6a7 100644 --- a/ragel/csharp-fsmcodegen.cpp +++ b/ragel/cs-fsmcodegen.cpp @@ -21,8 +21,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "csharp-rlgen-csharp.h" -#include "csharp-fsmcodegen.h" +#include "ragel.h" +#include "cs-fsmcodegen.h" #include "redfsm.h" #include "gendata.h" #include @@ -30,6 +30,15 @@ #include #include +/* Code generators. */ +#include "cs-tabcodegen.h" +#include "cs-ftabcodegen.h" +#include "cs-flatcodegen.h" +#include "cs-fflatcodegen.h" +#include "cs-gotocodegen.h" +#include "cs-fgotocodegen.h" +#include "cs-ipgotocodegen.h" +#include "cs-splitcodegen.h" using std::ostream; using std::ostringstream; @@ -37,6 +46,98 @@ using std::string; using std::cerr; using std::endl; +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 *csharpOpenOutput( const char *inputFile ) +{ + if ( hostLang->lang != HostLang::CSharp ) { + error() << "this code generator is for C# only" << endl; + exit(1); + } + + /* If the output format is code and no output file name is given, then + * make a default. */ + if ( outputFileName == 0 ) { + const char *ext = findFileExtension( inputFile ); + if ( ext != 0 && strcmp( ext, ".rh" ) == 0 ) + outputFileName = fileNameFromStem( inputFile, ".h" ); + else + outputFileName = fileNameFromStem( inputFile, ".cs" ); + } + + /* 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 *csharpMakeCodeGen( const char *sourceFileName, const char *fsmName, + ostream &out, bool wantComplete ) +{ + CodeGenData *codeGen = 0; + + switch ( codeStyle ) { + case GenTables: + codeGen = new CSharpTabCodeGen(out); + break; + case GenFTables: + codeGen = new CSharpFTabCodeGen(out); + break; + case GenFlat: + codeGen = new CSharpFlatCodeGen(out); + break; + case GenFFlat: + codeGen = new CSharpFFlatCodeGen(out); + break; + case GenGoto: + codeGen = new CSharpGotoCodeGen(out); + break; + case GenFGoto: + codeGen = new CSharpFGotoCodeGen(out); + break; + case GenIpGoto: + codeGen = new CSharpIpGotoCodeGen(out); + break; + case GenSplit: + codeGen = new CSharpSplitCodeGen(out); + break; + } + + codeGen->sourceFileName = sourceFileName; + codeGen->fsmName = fsmName; + codeGen->wantComplete = wantComplete; + + return codeGen; +} + void csharpLineDirective( ostream &out, const char *fileName, int line ) { if ( noLineDirectives ) diff --git a/ragel/csharp-fsmcodegen.h b/ragel/cs-fsmcodegen.h similarity index 100% rename from ragel/csharp-fsmcodegen.h rename to ragel/cs-fsmcodegen.h diff --git a/ragel/csharp-ftabcodegen.cpp b/ragel/cs-ftabcodegen.cpp similarity index 99% rename from ragel/csharp-ftabcodegen.cpp rename to ragel/cs-ftabcodegen.cpp index 7a5ae6b..39800f9 100644 --- a/ragel/csharp-ftabcodegen.cpp +++ b/ragel/cs-ftabcodegen.cpp @@ -21,8 +21,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "csharp-rlgen-csharp.h" -#include "csharp-ftabcodegen.h" +#include "ragel.h" +#include "cs-ftabcodegen.h" #include "redfsm.h" #include "gendata.h" diff --git a/ragel/csharp-ftabcodegen.h b/ragel/cs-ftabcodegen.h similarity index 98% rename from ragel/csharp-ftabcodegen.h rename to ragel/cs-ftabcodegen.h index 00ed579..31ec65e 100644 --- a/ragel/csharp-ftabcodegen.h +++ b/ragel/cs-ftabcodegen.h @@ -25,7 +25,7 @@ #define _FTABCODEGEN_H #include -#include "csharp-tabcodegen.h" +#include "cs-tabcodegen.h" /* Forwards. */ struct CodeGenData; diff --git a/ragel/csharp-gotocodegen.cpp b/ragel/cs-gotocodegen.cpp similarity index 99% rename from ragel/csharp-gotocodegen.cpp rename to ragel/cs-gotocodegen.cpp index 508e558..14ba07d 100644 --- a/ragel/csharp-gotocodegen.cpp +++ b/ragel/cs-gotocodegen.cpp @@ -21,8 +21,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "csharp-rlgen-csharp.h" -#include "csharp-gotocodegen.h" +#include "ragel.h" +#include "cs-gotocodegen.h" #include "redfsm.h" #include "bstmap.h" #include "gendata.h" diff --git a/ragel/csharp-gotocodegen.h b/ragel/cs-gotocodegen.h similarity index 99% rename from ragel/csharp-gotocodegen.h rename to ragel/cs-gotocodegen.h index fab1428..cf08534 100644 --- a/ragel/csharp-gotocodegen.h +++ b/ragel/cs-gotocodegen.h @@ -25,7 +25,7 @@ #define _GOTOCODEGEN_H #include -#include "csharp-fsmcodegen.h" +#include "cs-fsmcodegen.h" /* Forwards. */ struct CodeGenData; diff --git a/ragel/csharp-ipgotocodegen.cpp b/ragel/cs-ipgotocodegen.cpp similarity index 99% rename from ragel/csharp-ipgotocodegen.cpp rename to ragel/cs-ipgotocodegen.cpp index c0c5cc2..5efa04d 100644 --- a/ragel/csharp-ipgotocodegen.cpp +++ b/ragel/cs-ipgotocodegen.cpp @@ -21,8 +21,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "csharp-rlgen-csharp.h" -#include "csharp-ipgotocodegen.h" +#include "ragel.h" +#include "cs-ipgotocodegen.h" #include "redfsm.h" #include "gendata.h" #include "bstmap.h" diff --git a/ragel/csharp-ipgotocodegen.h b/ragel/cs-ipgotocodegen.h similarity index 98% rename from ragel/csharp-ipgotocodegen.h rename to ragel/cs-ipgotocodegen.h index c04d04f..7a743ae 100644 --- a/ragel/csharp-ipgotocodegen.h +++ b/ragel/cs-ipgotocodegen.h @@ -25,7 +25,7 @@ #define _IPGCODEGEN_H #include -#include "csharp-gotocodegen.h" +#include "cs-gotocodegen.h" /* Forwards. */ struct CodeGenData; diff --git a/ragel/csharp-rlgen-csharp.h b/ragel/cs-main.cpp similarity index 66% rename from ragel/csharp-rlgen-csharp.h rename to ragel/cs-main.cpp index a586d16..201281d 100644 --- a/ragel/csharp-rlgen-csharp.h +++ b/ragel/cs-main.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2001-2006 Adrian Thurston + * Copyright 2001-2007 Adrian Thurston */ /* This file is part of Ragel. @@ -19,29 +19,17 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef _RLCODEGEN_H -#define _RLCODEGEN_H - +#include +#include #include #include -#include "config.h" -#include "avltree.h" -#include "vector.h" -#include "config.h" -#include "common.h" - -extern CodeStyleEnum codeStyle; - +#include +#include -/* IO filenames and stream. */ -extern bool graphvizDone; - -extern int gblErrorCount; - -/* Options. */ -extern int numSplitPartitions; -extern bool noLineDirectives; - -std::ostream &error(); +#include "common.h" +#include "ragel.h" +#include "xmlparse.h" +#include "pcheck.h" +#include "vector.h" +#include "version.h" -#endif /* _RLCODEGEN_H */ diff --git a/ragel/csharp-splitcodegen.cpp b/ragel/cs-splitcodegen.cpp similarity index 99% rename from ragel/csharp-splitcodegen.cpp rename to ragel/cs-splitcodegen.cpp index cdcba8d..b64f415 100644 --- a/ragel/csharp-splitcodegen.cpp +++ b/ragel/cs-splitcodegen.cpp @@ -20,8 +20,8 @@ */ -#include "csharp-rlgen-csharp.h" -#include "csharp-splitcodegen.h" +#include "ragel.h" +#include "cs-splitcodegen.h" #include "gendata.h" #include diff --git a/ragel/csharp-splitcodegen.h b/ragel/cs-splitcodegen.h similarity index 98% rename from ragel/csharp-splitcodegen.h rename to ragel/cs-splitcodegen.h index 53fe118..1cfc857 100644 --- a/ragel/csharp-splitcodegen.h +++ b/ragel/cs-splitcodegen.h @@ -22,7 +22,7 @@ #ifndef _SPLITCODEGEN_H #define _SPLITCODEGEN_H -#include "csharp-ipgotocodegen.h" +#include "cs-ipgotocodegen.h" class CSharpSplitCodeGen : public CSharpIpGotoCodeGen { diff --git a/ragel/csharp-tabcodegen.cpp b/ragel/cs-tabcodegen.cpp similarity index 99% rename from ragel/csharp-tabcodegen.cpp rename to ragel/cs-tabcodegen.cpp index 711f72b..bbcab61 100644 --- a/ragel/csharp-tabcodegen.cpp +++ b/ragel/cs-tabcodegen.cpp @@ -21,8 +21,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "csharp-rlgen-csharp.h" -#include "csharp-tabcodegen.h" +#include "ragel.h" +#include "cs-tabcodegen.h" #include "redfsm.h" #include "gendata.h" diff --git a/ragel/csharp-tabcodegen.h b/ragel/cs-tabcodegen.h similarity index 99% rename from ragel/csharp-tabcodegen.h rename to ragel/cs-tabcodegen.h index 19ca444..ee17ede 100644 --- a/ragel/csharp-tabcodegen.h +++ b/ragel/cs-tabcodegen.h @@ -25,7 +25,7 @@ #define _TABCODEGEN_H #include -#include "csharp-fsmcodegen.h" +#include "cs-fsmcodegen.h" /* Forwards. */ struct CodeGenData; diff --git a/ragel/csharp-main.cpp b/ragel/csharp-main.cpp deleted file mode 100644 index d246b54..0000000 --- a/ragel/csharp-main.cpp +++ /dev/null @@ -1,155 +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 "csharp-rlgen-csharp.h" -#include "xmlparse.h" -#include "pcheck.h" -#include "vector.h" -#include "version.h" - -/* Code generators. */ -#include "csharp-tabcodegen.h" -#include "csharp-ftabcodegen.h" -#include "csharp-flatcodegen.h" -#include "csharp-fflatcodegen.h" -#include "csharp-gotocodegen.h" -#include "csharp-fgotocodegen.h" -#include "csharp-ipgotocodegen.h" -#include "csharp-splitcodegen.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; - -/* Target language and output style. */ -extern CodeStyleEnum codeStyle; - -/* Io globals. */ -extern istream *inStream; -extern ostream *outStream; -extern output_filter *outFilter; -extern const char *outputFileName; - -/* Graphviz dot file generation. */ -extern bool graphvizDone; - -extern int numSplitPartitions; -extern bool noLineDirectives; - -/* - * Callbacks invoked by the XML data parser. - */ - -/* Invoked by the parser when the root element is opened. */ -ostream *csharpOpenOutput( const char *inputFile ) -{ - if ( hostLang->lang != HostLang::CSharp ) { - error() << "this code generator is for C# only" << endl; - exit(1); - } - - /* If the output format is code and no output file name is given, then - * make a default. */ - if ( outputFileName == 0 ) { - const char *ext = findFileExtension( inputFile ); - if ( ext != 0 && strcmp( ext, ".rh" ) == 0 ) - outputFileName = fileNameFromStem( inputFile, ".h" ); - else - outputFileName = fileNameFromStem( inputFile, ".cs" ); - } - - /* 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 *csharpMakeCodeGen( const char *sourceFileName, const char *fsmName, - ostream &out, bool wantComplete ) -{ - CodeGenData *codeGen = 0; - - switch ( codeStyle ) { - case GenTables: - codeGen = new CSharpTabCodeGen(out); - break; - case GenFTables: - codeGen = new CSharpFTabCodeGen(out); - break; - case GenFlat: - codeGen = new CSharpFlatCodeGen(out); - break; - case GenFFlat: - codeGen = new CSharpFFlatCodeGen(out); - break; - case GenGoto: - codeGen = new CSharpGotoCodeGen(out); - break; - case GenFGoto: - codeGen = new CSharpFGotoCodeGen(out); - break; - case GenIpGoto: - codeGen = new CSharpIpGotoCodeGen(out); - break; - case GenSplit: - codeGen = new CSharpSplitCodeGen(out); - break; - } - - codeGen->sourceFileName = sourceFileName; - codeGen->fsmName = fsmName; - codeGen->wantComplete = wantComplete; - - return codeGen; -} diff --git a/ragel/ragel.h b/ragel/ragel.h index 8a0542c..dbbb5de 100644 --- a/ragel/ragel.h +++ b/ragel/ragel.h @@ -81,4 +81,31 @@ void xmlEscapeHost( std::ostream &out, char *data, long len ); typedef Vector ArgsVector; extern ArgsVector includePaths; +extern CodeStyleEnum codeStyle; + +/* IO filenames and stream. */ +extern bool graphvizDone; + +/* Options. */ +extern int numSplitPartitions; +extern bool noLineDirectives; + +std::ostream &error(); + +/* Target language and output style. */ +extern CodeStyleEnum codeStyle; + +/* Io globals. */ +extern std::istream *inStream; +extern std::ostream *outStream; +extern output_filter *outFilter; +extern const char *outputFileName; + +/* Graphviz dot file generation. */ +extern bool graphvizDone; + +extern int numSplitPartitions; +extern bool noLineDirectives; + + #endif /* _RAGEL_H */ -- 2.7.4