From 1e307ca50fba789295087142d7733e30977cb933 Mon Sep 17 00:00:00 2001 From: Houtan Bastani Date: Fri, 28 Aug 2015 16:09:43 +0200 Subject: [PATCH] preprocessor: read config file before macroprocessor run. #1039 --- DynareMain.cc | 23 +++++++++++++++++------ DynareMain2.cc | 14 +++++--------- 2 files changed, 22 insertions(+), 15 deletions(-) diff --git a/DynareMain.cc b/DynareMain.cc index de52a108..666e43e9 100644 --- a/DynareMain.cc +++ b/DynareMain.cc @@ -30,15 +30,17 @@ #include #include "ExtendedPreprocessorTypes.hh" +#include "ConfigFile.hh" /* Prototype for second part of main function Splitting main() in two parts was necessary because ParsingDriver.h and MacroDriver.h can't be included simultaneously (because of Bison limitations). */ -void main2(stringstream &in, string &basename, bool debug, bool clear_all, bool clear_global, 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, bool check_model_changes, bool minimal_workspace, FileOutputType output_mode, LanguageOutputType lang +void main2(stringstream &in, string &basename, bool debug, bool clear_all, bool clear_global, + bool no_tmp_terms, bool no_log, bool no_warn, bool warn_uninit, bool console, + bool nograph, bool nointeractive, bool parallel, ConfigFile &config_file, + WarningConsolidation &warnings_arg, bool nostrict, bool check_model_changes, + bool minimal_workspace, FileOutputType output_mode, LanguageOutputType lang #if defined(_WIN32) || defined(__CYGWIN32__) , bool cygwin, bool msvc #endif @@ -278,6 +280,14 @@ main(int argc, char **argv) if (pos != string::npos) basename.erase(pos); + WarningConsolidation warnings(no_warn); + + // Process config file + ConfigFile config_file(parallel, parallel_test, parallel_slave_open_mode, cluster_name); + config_file.getConfigFileInfo(parallel_config_file); + config_file.checkPass(warnings); + config_file.transformPass(); + // Do macro processing MacroDriver m; @@ -301,8 +311,9 @@ main(int argc, char **argv) return EXIT_SUCCESS; // Do the rest - main2(macro_output, basename, debug, clear_all, clear_global, 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, check_model_changes, minimal_workspace, + main2(macro_output, basename, debug, clear_all, clear_global, + no_tmp_terms, no_log, no_warn, warn_uninit, console, nograph, nointeractive, + parallel, config_file, warnings, nostrict, check_model_changes, minimal_workspace, output_mode, language #if defined(_WIN32) || defined(__CYGWIN32__) , cygwin, msvc diff --git a/DynareMain2.cc b/DynareMain2.cc index 33782aff..0b335b11 100644 --- a/DynareMain2.cc +++ b/DynareMain2.cc @@ -25,30 +25,26 @@ #include "ExtendedPreprocessorTypes.hh" void -main2(stringstream &in, string &basename, bool debug, bool clear_all, bool clear_global, 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, bool check_model_changes, bool minimal_workspace, FileOutputType output_mode, LanguageOutputType language +main2(stringstream &in, string &basename, bool debug, bool clear_all, bool clear_global, + bool no_tmp_terms, bool no_log, bool no_warn, bool warn_uninit, bool console, + bool nograph, bool nointeractive, bool parallel, ConfigFile &config_file, + WarningConsolidation &warnings, bool nostrict, bool check_model_changes, + bool minimal_workspace, FileOutputType output_mode, LanguageOutputType language #if defined(_WIN32) || defined(__CYGWIN32__) , bool cygwin, bool msvc #endif ) { - WarningConsolidation warnings(no_warn); - ParsingDriver p(warnings, nostrict); // Do parsing and construct internal representation of mod file ModFile *mod_file = p.parse(in, debug); - ConfigFile config_file(parallel, parallel_test, parallel_slave_open_mode, cluster_name); - config_file.getConfigFileInfo(parallel_config_file); // Run checking pass mod_file->checkPass(); - config_file.checkPass(warnings); // Perform transformations on the model (creation of auxiliary vars and equations) mod_file->transformPass(nostrict); - config_file.transformPass(); // Evaluate parameters initialization, initval, endval and pounds mod_file->evalAllExpressions(warn_uninit);