Commit c1debb1a authored by Houtan Bastani's avatar Houtan Bastani

preprocessor: don’t allow write_latex_steady_state_model without steady_state_model block. #1496

parent d23a684b
...@@ -2382,6 +2382,12 @@ WriteLatexSteadyStateModelStatement::WriteLatexSteadyStateModelStatement(const S ...@@ -2382,6 +2382,12 @@ WriteLatexSteadyStateModelStatement::WriteLatexSteadyStateModelStatement(const S
{ {
} }
void
WriteLatexSteadyStateModelStatement::checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings)
{
mod_file_struct.write_latex_steady_state_model_present = true;
}
void void
WriteLatexSteadyStateModelStatement::writeOutput(ostream &output, const string &basename, bool minimal_workspace) const WriteLatexSteadyStateModelStatement::writeOutput(ostream &output, const string &basename, bool minimal_workspace) const
{ {
......
...@@ -632,6 +632,7 @@ private: ...@@ -632,6 +632,7 @@ private:
const SteadyStateModel &steady_state_model; const SteadyStateModel &steady_state_model;
public: public:
WriteLatexSteadyStateModelStatement(const SteadyStateModel &steady_state_model_arg); WriteLatexSteadyStateModelStatement(const SteadyStateModel &steady_state_model_arg);
virtual void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings);
virtual void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const; virtual void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const;
virtual void writeJsonOutput(ostream &output) const; virtual void writeJsonOutput(ostream &output) const;
}; };
......
...@@ -114,7 +114,14 @@ ModFile::checkPass(bool nostrict) ...@@ -114,7 +114,14 @@ ModFile::checkPass(bool nostrict)
(*it)->checkPass(mod_file_struct, warnings); (*it)->checkPass(mod_file_struct, warnings);
// Check the steady state block // Check the steady state block
steady_state_model.checkPass(mod_file_struct.ramsey_model_present, warnings); steady_state_model.checkPass(mod_file_struct, warnings);
if (mod_file_struct.write_latex_steady_state_model_present &&
!mod_file_struct.steady_state_model_present)
{
cerr << "ERROR: You cannot have a write_latex_steady_state_model statement without a steady_state_model block." << endl;
exit(EXIT_FAILURE);
}
// If order option has not been set, default to 2 // If order option has not been set, default to 2
if (!mod_file_struct.order_option) if (!mod_file_struct.order_option)
......
...@@ -59,7 +59,9 @@ ModFileStructure::ModFileStructure() : ...@@ -59,7 +59,9 @@ ModFileStructure::ModFileStructure() :
ms_dsge_present(false), ms_dsge_present(false),
occbin_option(false), occbin_option(false),
orig_eq_nbr(0), orig_eq_nbr(0),
ramsey_eq_nbr(0) ramsey_eq_nbr(0),
steady_state_model_present(false),
write_latex_steady_state_model_present(false)
{ {
} }
......
...@@ -119,7 +119,10 @@ public: ...@@ -119,7 +119,10 @@ public:
int orig_eq_nbr; int orig_eq_nbr;
//! Stores the number of equations added to the Ramsey model //! Stores the number of equations added to the Ramsey model
int ramsey_eq_nbr; int ramsey_eq_nbr;
//! Whether there was a steady_state_model block
bool steady_state_model_present;
//! Whether there is a write_latex_steady_state_model statement present
bool write_latex_steady_state_model_present;
}; };
class Statement class Statement
......
...@@ -56,11 +56,12 @@ SteadyStateModel::addMultipleDefinitions(const vector<int> &symb_ids, expr_t exp ...@@ -56,11 +56,12 @@ SteadyStateModel::addMultipleDefinitions(const vector<int> &symb_ids, expr_t exp
} }
void void
SteadyStateModel::checkPass(bool ramsey_model, WarningConsolidation &warnings) const SteadyStateModel::checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings) const
{ {
if (def_table.size() == 0) if (def_table.size() == 0)
return; return;
mod_file_struct.steady_state_model_present = true;
vector<int> so_far_defined; vector<int> so_far_defined;
for (size_t i = 0; i < def_table.size(); i++) for (size_t i = 0; i < def_table.size(); i++)
...@@ -74,7 +75,7 @@ SteadyStateModel::checkPass(bool ramsey_model, WarningConsolidation &warnings) c ...@@ -74,7 +75,7 @@ SteadyStateModel::checkPass(bool ramsey_model, WarningConsolidation &warnings) c
warnings << "WARNING: in the 'steady_state_model' block, variable '" << symbol_table.getName(symb_ids[j]) << "' is declared twice" << endl; warnings << "WARNING: in the 'steady_state_model' block, variable '" << symbol_table.getName(symb_ids[j]) << "' is declared twice" << endl;
// Check that expression has no undefined symbol // Check that expression has no undefined symbol
if (!ramsey_model) if (!mod_file_struct.ramsey_model_present)
{ {
set<int> used_symbols; set<int> used_symbols;
const expr_t &expr = def_table[i].second; const expr_t &expr = def_table[i].second;
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#define _STEADY_STATE_MODEL_HH #define _STEADY_STATE_MODEL_HH
#include "DataTree.hh" #include "DataTree.hh"
#include "Statement.hh"
#include "StaticModel.hh" #include "StaticModel.hh"
#include "WarningConsolidation.hh" #include "WarningConsolidation.hh"
...@@ -43,7 +44,7 @@ public: ...@@ -43,7 +44,7 @@ public:
/*! /*!
\param[in] ramsey_model Is there a Ramsey model in the MOD file? If yes, then disable the check on the recursivity of the declarations \param[in] ramsey_model Is there a Ramsey model in the MOD file? If yes, then disable the check on the recursivity of the declarations
*/ */
void checkPass(bool ramsey_model, WarningConsolidation &warnings) const; void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings) const;
//! Write the steady state file //! Write the steady state file
/*! /*!
\param[in] ramsey_model Is there a Ramsey model in the MOD file? If yes, then use the "ys" in argument of the steady state file as initial values \param[in] ramsey_model Is there a Ramsey model in the MOD file? If yes, then use the "ys" in argument of the steady state file as initial values
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment