preprocessor: read config file before macroprocessor run. #1039

time-shift
Houtan Bastani 2015-08-28 16:09:43 +02:00
parent 2518f6c83c
commit f143b54142
2 changed files with 22 additions and 15 deletions

View File

@ -30,15 +30,17 @@
#include <unistd.h>
#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 &parallel_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

View File

@ -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 &parallel_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);