diff --git a/preprocessor/DynareMain.cc b/preprocessor/DynareMain.cc index 1f99d8746d24de499aacde42c174050366b51826..016488682a936d55d2b132c90acde5d9a07c9467 100644 --- a/preprocessor/DynareMain.cc +++ b/preprocessor/DynareMain.cc @@ -29,7 +29,7 @@ #include "macro/MacroDriver.hh" #include <unistd.h> -#include "FileOutputType.hh" +#include "ExtendedPreprocessorTypes.hh" /* Prototype for second part of main function Splitting main() in two parts was necessary because ParsingDriver.h and MacroDriver.h can't be @@ -37,7 +37,7 @@ */ void main2(stringstream &in, string &basename, bool debug, bool clear_all, bool no_tmp_terms, bool no_log, bool no_warn, bool warn_uninit, bool console, bool nograph, bool nointeractive, bool parallel, const string ¶llel_config_file, const string &cluster_name, bool parallel_slave_open_mode, - bool parallel_test, bool nostrict, FileOutputType output_mode, bool cuda + bool parallel_test, bool nostrict, FileOutputType output_mode, LanguageOutputType lang #if defined(_WIN32) || defined(__CYGWIN32__) , bool cygwin, bool msvc #endif @@ -48,7 +48,7 @@ usage() { cerr << "Dynare usage: dynare mod_file [debug] [noclearall] [savemacro[=macro_file]] [onlymacro] [nolinemacro] [notmpterms] [nolog] [warn_uninit]" << " [console] [nograph] [nointeractive] [parallel[=cluster_name]] [conffile=parallel_config_path_and_filename] [parallel_slave_open_mode] [parallel_test] " - << " [-D<variable>[=<value>]] [nostrict] [-double=dynamic|first|second|third] [cuda]" + << " [-D<variable>[=<value>]] [nostrict] [output=dynamic|first|second|third] [language=C|C++]" #if defined(_WIN32) || defined(__CYGWIN32__) << " [cygwin] [msvc]" #endif @@ -97,7 +97,7 @@ main(int argc, char **argv) bool nostrict = false; map<string, string> defines; FileOutputType output_mode = none; - bool cuda = false; + LanguageOutputType language = matlab; // Parse options for (int arg = 2; arg < argc; arg++) @@ -199,8 +199,6 @@ main(int argc, char **argv) cerr << "Incorrect syntax for ouput option" << endl; usage(); } - // we don't want temp terms in CC functions - no_tmp_terms = true; if (strlen(argv[arg]) == 14 && !strncmp(argv[arg] + 7, "dynamic", 7)) output_mode = dynamic; else if (strlen(argv[arg]) == 12 && !strncmp(argv[arg] + 7, "first", 5)) @@ -215,8 +213,31 @@ main(int argc, char **argv) usage(); } } - else if (!strcmp(argv[arg], "cuda")) - cuda = true; + else if (strlen(argv[arg]) >= 8 && !strncmp(argv[arg], "language", 8)) + { + if (strlen(argv[arg]) <= 9 || argv[arg][6] != '=') + { + cerr << "Incorrect syntax for language option" << endl; + usage(); + } + // we don't want temp terms in external functions + no_tmp_terms = true; + if (strlen(argv[arg]) == 10 && !strncmp(argv[arg] + 9, "C", 1)) + language = c; + else if (strlen(argv[arg]) == 12 && !strncmp(argv[arg] + 9, "C++", 3)) + language = cpp; + else if (strlen(argv[arg]) == 13 && !strncmp(argv[arg] + 9, "cuda", 4)) + language = cuda; + else if (strlen(argv[arg]) == 14 && !strncmp(argv[arg] + 9, "julia", 5)) + language = julia; + else if (strlen(argv[arg]) == 15 && !strncmp(argv[arg] + 9, "python", 6)) + language = python; + else + { + cerr << "Incorrect syntax for ouput option" << endl; + usage(); + } + } else { cerr << "Unknown option: " << argv[arg] << endl; @@ -257,7 +278,7 @@ main(int argc, char **argv) // Do the rest main2(macro_output, basename, debug, clear_all, no_tmp_terms, no_log, no_warn, warn_uninit, console, nograph, nointeractive, - parallel, parallel_config_file, cluster_name, parallel_slave_open_mode, parallel_test, nostrict, output_mode, cuda + parallel, parallel_config_file, cluster_name, parallel_slave_open_mode, parallel_test, nostrict, output_mode, language #if defined(_WIN32) || defined(__CYGWIN32__) , cygwin, msvc #endif diff --git a/preprocessor/DynareMain2.cc b/preprocessor/DynareMain2.cc index 2f0f30a3c3261d99caad60047188732f65b5f9a1..60a06064ae113ddc2839bd6932124f1c1299b972 100644 --- a/preprocessor/DynareMain2.cc +++ b/preprocessor/DynareMain2.cc @@ -22,12 +22,12 @@ #include "ParsingDriver.hh" #include "ModFile.hh" #include "ConfigFile.hh" -#include "FileOutputType.hh" +#include "ExtendedPreprocessorTypes.hh" void main2(stringstream &in, string &basename, bool debug, bool clear_all, bool no_tmp_terms, bool no_log, bool no_warn, bool warn_uninit, bool console, bool nograph, bool nointeractive, bool parallel, const string ¶llel_config_file, const string &cluster_name, bool parallel_slave_open_mode, - bool parallel_test, bool nostrict, FileOutputType output_mode, bool cuda + bool parallel_test, bool nostrict, FileOutputType output_mode, LanguageOutputType lang #if defined(_WIN32) || defined(__CYGWIN32__) , bool cygwin, bool msvc #endif diff --git a/preprocessor/FileOutputType.hh b/preprocessor/ExtendedPreprocessorTypes.hh similarity index 57% rename from preprocessor/FileOutputType.hh rename to preprocessor/ExtendedPreprocessorTypes.hh index 8f4e681f394d77a6bf9acf35a5b39c7297a0022b..d9a210e7706492cfc6bae18c6880b90bfd0453b4 100644 --- a/preprocessor/FileOutputType.hh +++ b/preprocessor/ExtendedPreprocessorTypes.hh @@ -17,15 +17,25 @@ * along with Dynare. If not, see <http://www.gnu.org/licenses/>. */ -#ifndef _FILE_OUTPUT_TYPE_HH -#define _FILE_OUTPUT_TYPE_HH +#ifndef _EXTENDED_PREPROCESSOR_TYPES_HH +#define _EXTENDED_PREPROCESSOR_TYPES_HH enum FileOutputType { none, // outputs files for Matlab/Octave processing - dynamic, // outputs <fname>_dynamic.cc and related files - first, // outputs <fname>_first_derivatives and related files - second, // outputs <fname>_first_derivatives, <fname>_second_derivatives.cc and related files - third, // outputs <fname>_first_derivatives, <fname>_second_derivatives.cc, <fname>_third_derivatives.cc and related files + dynamic, // outputs <fname>_dynamic.* and related files + first, // outputs <fname>_first_derivatives.* and related files + second, // outputs <fname>_first_derivatives.*, <fname>_second_derivatives.* and related files + third, // outputs <fname>_first_derivatives.*, <fname>_second_derivatives.*, <fname>_third_derivatives.* and related files + }; + +enum LanguageOutputType + { + matlab, // outputs files for Matlab/Octave processing + c, // outputs files for C + cpp, // outputs files for C++ + cuda, // outputs files for CUDA (not yet implemented) + julia, // outputs files for Julia (not yet implemented) + python, // outputs files for Python (not yet implemented) (not yet implemented) }; #endif diff --git a/preprocessor/Makefile.am b/preprocessor/Makefile.am index 91112aefe0a8b9471d9a62d529c5580ec844f696..fc33ec33ffddfef4ad11f4ba7f7e547566645d47 100644 --- a/preprocessor/Makefile.am +++ b/preprocessor/Makefile.am @@ -53,7 +53,7 @@ dynare_m_SOURCES = \ SteadyStateModel.cc \ WarningConsolidation.hh \ WarningConsolidation.cc \ - FileOutputType.hh + ExtendedPreprocessorTypes.hh # The -I. is for <FlexLexer.h> dynare_m_CPPFLAGS = $(BOOST_CPPFLAGS) -I. diff --git a/preprocessor/ModFile.hh b/preprocessor/ModFile.hh index f6809361979946a26dc84e093dee94b4b36d10c7..8b22f2db6c87e2ad2b1076806b178ab569587f5a 100644 --- a/preprocessor/ModFile.hh +++ b/preprocessor/ModFile.hh @@ -35,7 +35,7 @@ using namespace std; #include "ExternalFunctionsTable.hh" #include "ConfigFile.hh" #include "WarningConsolidation.hh" -#include "FileOutputType.hh" +#include "ExtendedPreprocessorTypes.hh" //! The abstract representation of a "mod" file class ModFile