DynareMain2.cc 3.38 KB
Newer Older
1
/*
2
 * Copyright (C) 2008-2017 Dynare Team
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
 *
 * This file is part of Dynare.
 *
 * Dynare 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 3 of the License, or
 * (at your option) any later version.
 *
 * Dynare 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 Dynare.  If not, see <http://www.gnu.org/licenses/>.
 */

#include <iostream>

#include "ParsingDriver.hh"
#include "ModFile.hh"
24
#include "ConfigFile.hh"
25
#include "ExtendedPreprocessorTypes.hh"
26 27

void
28 29 30
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,
31
      WarningConsolidation &warnings, bool nostrict, bool stochastic, bool check_model_changes,
32
      bool minimal_workspace, bool compute_xrefs, FileOutputType output_mode,
33
      LanguageOutputType language, int params_derivs_order
34 35
#if defined(_WIN32) || defined(__CYGWIN32__) || defined(__MINGW32__)
      , bool cygwin, bool msvc, bool mingw
36
#endif
37
      , JsonOutputPointType json, JsonFileOutputType json_output_mode, bool onlyjson, bool jsonderivsimple
38
      , bool nopreprocessoroutput
39
      )
40
{
41
  ParsingDriver p(warnings, nostrict);
sebastien's avatar
sebastien committed
42

43
  // Do parsing and construct internal representation of mod file
44
  ModFile *mod_file = p.parse(in, debug);
45
  if (json == parsing)
46
    mod_file->writeJsonOutput(basename, json, json_output_mode, onlyjson, nopreprocessoroutput);
sebastien's avatar
sebastien committed
47

48
  // Run checking pass
49
  mod_file->checkPass(nostrict, stochastic);
50
  if (json == checkpass)
51
    mod_file->writeJsonOutput(basename, json, json_output_mode, onlyjson, nopreprocessoroutput);
52

sebastien's avatar
sebastien committed
53
  // Perform transformations on the model (creation of auxiliary vars and equations)
54
  mod_file->transformPass(nostrict, stochastic, compute_xrefs || json == transformpass, nopreprocessoroutput);
55
  if (json == transformpass)
56
    mod_file->writeJsonOutput(basename, json, json_output_mode, onlyjson, nopreprocessoroutput);
sebastien's avatar
sebastien committed
57

58
  // Evaluate parameters initialization, initval, endval and pounds
59
  mod_file->evalAllExpressions(warn_uninit, nopreprocessoroutput);
60

61
  // Do computations
62
  mod_file->computingPass(no_tmp_terms, output_mode, params_derivs_order, nopreprocessoroutput);
63
  if (json == computingpass)
64
    mod_file->writeJsonOutput(basename, json, json_output_mode, onlyjson, nopreprocessoroutput, jsonderivsimple);
65 66

  // Write outputs
67
  if (output_mode != none)
68
    mod_file->writeExternalFiles(basename, output_mode, language, nopreprocessoroutput);
69
  else
70
    mod_file->writeOutputFiles(basename, clear_all, clear_global, no_log, no_warn, console, nograph,
71
                               nointeractive, config_file, check_model_changes, minimal_workspace, compute_xrefs
72
#if defined(_WIN32) || defined(__CYGWIN32__) || defined(__MINGW32__)
73
                               , cygwin, msvc, mingw
74
#endif
75
                               , nopreprocessoroutput
76
                               );
77 78 79

  delete mod_file;

80 81
  if (!nopreprocessoroutput)
    cout << "Preprocessing completed." << endl;
82
}