add first_simulation_period to the lexer
(cherry picked from commit c8575e11d2f81ad606ab50849c52127653699a93)issue#70
parent
ba214a100d
commit
ed4c36a267
|
@ -146,7 +146,9 @@ SimulStatement::writeOutput(ostream &output, const string &basename, bool minima
|
|||
it != options_list_new.string_options.end())
|
||||
{
|
||||
output << "options_.initval_file = true;" << endl
|
||||
<< "initvalf('" << it->second << "');" << endl;
|
||||
<< "options_initvalf = struct();" << endl
|
||||
<< "options_initvalf.datafile = '" << it->second << "';" << endl
|
||||
<< "oo_.initval_series = histvalf_initvalf('INITVALF', M_, options_initvalf);" << endl;
|
||||
options_list_new.string_options.erase(it);
|
||||
}
|
||||
options_list_new.writeOutput(output);
|
||||
|
@ -179,7 +181,9 @@ PerfectForesightSetupStatement::writeOutput(ostream &output, const string &basen
|
|||
it != options_list_new.string_options.end())
|
||||
{
|
||||
output << "options_.initval_file = true;" << endl
|
||||
<< "initvalf('" << it->second << "');" << endl;
|
||||
<< "options_initvalf = struct();" << endl
|
||||
<< "options_initvalf.datafile = '" << it->second << "';" << endl
|
||||
<< "oo_.initval_series = histvalf_initvalf('INITVALF', M_, options_initvalf);" << endl;
|
||||
options_list_new.string_options.erase(it);
|
||||
}
|
||||
options_list_new.writeOutput(output);
|
||||
|
|
|
@ -82,7 +82,8 @@ class ParsingDriver;
|
|||
%token COMMA CONSIDER_ALL_ENDOGENOUS CONSIDER_ONLY_OBSERVED INITIAL_CONDITION_DECOMPOSITION
|
||||
%token DATAFILE FILE SERIES DET_COND_FORECAST DOUBLING DR_CYCLE_REDUCTION_TOL DR_LOGARITHMIC_REDUCTION_TOL DR_LOGARITHMIC_REDUCTION_MAXITER DR_ALGO DROP DSAMPLE DYNASAVE DYNATYPE CALIBRATION DIFFERENTIATE_FORWARD_VARS
|
||||
%token END ENDVAL EQUAL ESTIMATION ESTIMATED_PARAMS ESTIMATED_PARAMS_BOUNDS ESTIMATED_PARAMS_INIT EXTENDED_PATH ENDOGENOUS_PRIOR EXPRESSION
|
||||
%token FILENAME DIRNAME FILTER_STEP_AHEAD FILTERED_VARS FIRST_OBS LAST_OBS SET_TIME OSR_PARAMS_BOUNDS KEEP_KALMAN_ALGO_IF_SINGULARITY_IS_DETECTED
|
||||
%token FILENAME DIRNAME FILTER_STEP_AHEAD FILTERED_VARS FIRST_OBS FIRST_SIMULATION_PERIOD LAST_OBS
|
||||
%token SET_TIME OSR_PARAMS_BOUNDS KEEP_KALMAN_ALGO_IF_SINGULARITY_IS_DETECTED
|
||||
%token <string> FLOAT_NUMBER DATES
|
||||
%token DEFAULT FIXED_POINT FLIP OPT_ALGO COMPILATION_SETUP COMPILER ADD_FLAGS SUBSTITUTE_FLAGS ADD_LIBS SUBSTITUTE_LIBS
|
||||
%token FORECAST K_ORDER_SOLVER INSTRUMENTS SHIFT MEAN STDEV VARIANCE MODE INTERVAL SHAPE DOMAINN
|
||||
|
@ -851,9 +852,27 @@ initval : INITVAL ';' initval_list END ';'
|
|||
{ driver.end_initval(true); }
|
||||
;
|
||||
|
||||
initval_file : INITVAL_FILE '(' FILENAME EQUAL filename ')' ';'
|
||||
{ driver.initval_file($5); }
|
||||
;
|
||||
histval_file : HISTVAL_FILE '(' h_options_list ')' ';'
|
||||
{ driver.histval_file();};
|
||||
|
||||
initval_file : INITVAL_FILE '(' h_options_list ')' ';'
|
||||
{ driver.initval_file();};
|
||||
|
||||
h_options_list: h_options_list COMMA h_options
|
||||
| h_options
|
||||
;
|
||||
|
||||
h_options: o_filename
|
||||
| o_datafile
|
||||
| o_first_obs
|
||||
| o_data_first_obs
|
||||
| o_first_simulation_period
|
||||
| o_date_first_simulation_period
|
||||
| o_last_obs
|
||||
| o_data_last_obs
|
||||
| o_nobs
|
||||
| o_series2
|
||||
;
|
||||
|
||||
endval : ENDVAL ';' initval_list END ';'
|
||||
{ driver.end_endval(false); }
|
||||
|
@ -879,10 +898,6 @@ histval_list : histval_list histval_elem
|
|||
|
||||
histval_elem : symbol '(' signed_integer ')' EQUAL expression ';' { driver.hist_val($1, $3, $6); };
|
||||
|
||||
histval_file : HISTVAL_FILE '(' FILENAME EQUAL filename ')' ';'
|
||||
{ driver.histval_file($5); }
|
||||
;
|
||||
|
||||
epilogue : EPILOGUE ';' { driver.begin_epilogue(); }
|
||||
epilogue_equation_list END ';' { driver.end_epilogue(); }
|
||||
;
|
||||
|
@ -3227,7 +3242,9 @@ o_pac_steady_state_growth : STEADY_STATE_GROWTH EQUAL signed_number { driver.set
|
|||
o_var_name : MODEL_NAME EQUAL symbol { driver.option_str("var.model_name", $3); };
|
||||
o_var_order : ORDER EQUAL INT_NUMBER { driver.option_num("var.order", $3); };
|
||||
o_series : SERIES EQUAL symbol { driver.option_str("series", $3); };
|
||||
o_series2 : SERIES EQUAL symbol { driver.option_num("series", $3); };
|
||||
o_datafile : DATAFILE EQUAL filename { driver.option_str("datafile", $3); };
|
||||
o_filename : FILENAME EQUAL filename { driver.option_str("filename", $3); };
|
||||
o_var_datafile : DATAFILE EQUAL filename { driver.option_str("var_estimation.datafile", $3); };
|
||||
o_var_model_name : symbol { driver.option_str("var_estimation.model_name", $1); };
|
||||
o_var_eq_tags : EQTAGS EQUAL vec_str { driver.option_vec_str("var.eqtags", $3); }
|
||||
|
@ -3255,6 +3272,9 @@ o_posterior_sampling_method : POSTERIOR_SAMPLING_METHOD EQUAL QUOTED_STRING
|
|||
{ driver.option_str("posterior_sampler_options.posterior_sampling_method", $3); } ;
|
||||
o_first_obs : FIRST_OBS EQUAL INT_NUMBER { driver.option_num("first_obs", $3); };
|
||||
o_data_first_obs : FIRST_OBS EQUAL date_expr { driver.option_date("firstobs", $3); } ;
|
||||
o_first_simulation_period : FIRST_SIMULATION_PERIOD EQUAL INT_NUMBER { driver.option_num("first_simulation_period", $3); };
|
||||
o_date_first_simulation_period : FIRST_SIMULATION_PERIOD EQUAL date_expr { driver.option_date("firstsimulationperiod", $3); } ;
|
||||
o_last_obs : LAST_OBS EQUAL INT_NUMBER { driver.option_num("last_obs", $3); };
|
||||
o_data_last_obs : LAST_OBS EQUAL date_expr { driver.option_date("lastobs", $3); } ;
|
||||
o_keep_kalman_algo_if_singularity_is_detected : KEEP_KALMAN_ALGO_IF_SINGULARITY_IS_DETECTED { driver.option_num("kalman.keep_kalman_algo_if_singularity_is_detected", "true"); } ;
|
||||
o_data_nobs : NOBS EQUAL INT_NUMBER { driver.option_num("nobs", $3); };
|
||||
|
|
|
@ -437,6 +437,7 @@ DATE -?[0-9]+([ya]|m([1-9]|1[0-2])|q[1-4])
|
|||
<DYNARE_STATEMENT>expression {return token::EXPRESSION;}
|
||||
<DYNARE_STATEMENT>occbin_likelihood {return token::OCCBIN_LIKELIHOOD;}
|
||||
<DYNARE_STATEMENT>occbin_smoother {return token::OCCBIN_SMOOTHER;}
|
||||
<DYNARE_STATEMENT>first_simulation_period {return token::FIRST_SIMULATION_PERIOD;}
|
||||
|
||||
<DYNARE_STATEMENT>alpha {
|
||||
yylval->build<string>(yytext);
|
||||
|
|
|
@ -411,8 +411,8 @@ HistValStatement::writeJsonOutput(ostream &output) const
|
|||
output << "]}";
|
||||
}
|
||||
|
||||
InitvalFileStatement::InitvalFileStatement(string filename_arg) :
|
||||
filename{move(filename_arg)}
|
||||
InitvalFileStatement::InitvalFileStatement(OptionsList options_list_arg) :
|
||||
options_list{move(options_list_arg)}
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -422,35 +422,49 @@ InitvalFileStatement::writeOutput(ostream &output, const string &basename, bool
|
|||
output << "%" << endl
|
||||
<< "% INITVAL_FILE statement" << endl
|
||||
<< "%" << endl
|
||||
<< "options_.initval_file = true;" << endl
|
||||
<< "initvalf('" << filename << "');" << endl;
|
||||
<< "options_.initval_file = true;" << endl;
|
||||
options_list.writeOutput(output, "options_initvalf");
|
||||
output << "oo_.initval_series = initvalf(M_, options_initvalf);" << endl;
|
||||
}
|
||||
|
||||
void
|
||||
InitvalFileStatement::writeJsonOutput(ostream &output) const
|
||||
{
|
||||
output << R"({"statementName": "init_val_file")"
|
||||
<< R"(, "filename": ")" << filename << R"(")"
|
||||
<< "}";
|
||||
output << R"({"statementName": "initval_file")";
|
||||
if (options_list.getNumberOfOptions())
|
||||
{
|
||||
output << ", ";
|
||||
options_list.writeJsonOutput(output);
|
||||
}
|
||||
output << "}";
|
||||
}
|
||||
|
||||
HistvalFileStatement::HistvalFileStatement(string filename_arg) :
|
||||
filename{move(filename_arg)}
|
||||
HistvalFileStatement::HistvalFileStatement(OptionsList options_list_arg) :
|
||||
options_list{move(options_list_arg)}
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
HistvalFileStatement::writeOutput(ostream &output, const string &basename, bool minimal_workspace) const
|
||||
{
|
||||
output << "histvalf('" << filename << "');" << endl;
|
||||
output << "%" << endl
|
||||
<< "% HISTVAL_FILE statement" << endl
|
||||
<< "%" << endl
|
||||
<< "options_.histval_file = true;" << endl;
|
||||
options_list.writeOutput(output, "options_histvalf");
|
||||
output << "[M_.endo_histval, M_.exo_histval, M_.exo_det_histval] = histvalf(M_, options_histvalf);" << endl;
|
||||
}
|
||||
|
||||
void
|
||||
HistvalFileStatement::writeJsonOutput(ostream &output) const
|
||||
{
|
||||
output << R"({"statementName": "hist_val_file")"
|
||||
<< R"(, "filename": ")" << filename << R"(")"
|
||||
<< "}";
|
||||
output << R"({"statementName": "histval_file")";
|
||||
if (options_list.getNumberOfOptions())
|
||||
{
|
||||
output << ", ";
|
||||
options_list.writeJsonOutput(output);
|
||||
}
|
||||
output << "}";
|
||||
}
|
||||
|
||||
HomotopyStatement::HomotopyStatement(homotopy_values_t homotopy_values_arg,
|
||||
|
|
|
@ -123,9 +123,9 @@ public:
|
|||
class InitvalFileStatement : public Statement
|
||||
{
|
||||
private:
|
||||
const string filename;
|
||||
const OptionsList options_list;
|
||||
public:
|
||||
explicit InitvalFileStatement(string filename_arg);
|
||||
explicit InitvalFileStatement(OptionsList options_list_arg);
|
||||
void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const override;
|
||||
void writeJsonOutput(ostream &output) const override;
|
||||
};
|
||||
|
@ -133,9 +133,9 @@ public:
|
|||
class HistvalFileStatement : public Statement
|
||||
{
|
||||
private:
|
||||
const string filename;
|
||||
const OptionsList options_list;
|
||||
public:
|
||||
explicit HistvalFileStatement(string filename_arg);
|
||||
explicit HistvalFileStatement(OptionsList options_list_arg);
|
||||
void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const override;
|
||||
void writeJsonOutput(ostream &output) const override;
|
||||
};
|
||||
|
|
|
@ -647,9 +647,10 @@ ParsingDriver::init_val(const string &name, expr_t rhs)
|
|||
}
|
||||
|
||||
void
|
||||
ParsingDriver::initval_file(const string &filename)
|
||||
ParsingDriver::initval_file()
|
||||
{
|
||||
mod_file->addStatement(make_unique<InitvalFileStatement>(filename));
|
||||
mod_file->addStatement(make_unique<InitvalFileStatement>(options_list));
|
||||
options_list.clear();
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -3345,9 +3346,10 @@ ParsingDriver::smoother2histval()
|
|||
}
|
||||
|
||||
void
|
||||
ParsingDriver::histval_file(const string &filename)
|
||||
ParsingDriver::histval_file()
|
||||
{
|
||||
mod_file->addStatement(make_unique<HistvalFileStatement>(filename));
|
||||
mod_file->addStatement(make_unique<HistvalFileStatement>(options_list));
|
||||
options_list.clear();
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -375,7 +375,7 @@ public:
|
|||
//! balanced_growth_test_tol option of model block
|
||||
void balanced_growth_test_tol(const string &value);
|
||||
//! Sets the FILENAME for the initial value in initval
|
||||
void initval_file(const string &filename);
|
||||
void initval_file();
|
||||
//! Declares an endogenous variable
|
||||
void declare_endogenous(const string &name, const string &tex_name = "", const vector<pair<string, string>> &partition_value = {});
|
||||
//! Declares an exogenous variable
|
||||
|
@ -889,7 +889,7 @@ public:
|
|||
//! End init2shocks declaration
|
||||
void end_init2shocks(const string &name);
|
||||
void smoother2histval();
|
||||
void histval_file(const string &filename);
|
||||
void histval_file();
|
||||
void perfect_foresight_setup();
|
||||
void perfect_foresight_solver();
|
||||
void prior_posterior_function(bool prior_func);
|
||||
|
|
Loading…
Reference in New Issue