From 6876b0a7c93137ddf05b09612587526f2f891f7d Mon Sep 17 00:00:00 2001 From: Johannes Pfeifer Date: Wed, 22 Nov 2017 18:57:26 +0100 Subject: [PATCH 1/9] Add preprocessor interface for fast_realtime option of --- DynareBison.yy | 4 +++- DynareFlex.ll | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/DynareBison.yy b/DynareBison.yy index 801aa600..97c45514 100644 --- a/DynareBison.yy +++ b/DynareBison.yy @@ -113,7 +113,7 @@ class ParsingDriver; %token CPF_WEIGHTS AMISANOTRISTANI MURRAYJONESPARSLOW WRITE_EQUATION_TAGS %token NONLINEAR_FILTER_INITIALIZATION FILTER_ALGORITHM PROPOSAL_APPROXIMATION CUBATURE UNSCENTED MONTECARLO DISTRIBUTION_APPROXIMATION %token NAME -%token USE_PENALIZED_OBJECTIVE_FOR_HESSIAN INIT_STATE RESCALE_PREDICTION_ERROR_COVARIANCE GENERATE_IRFS +%token USE_PENALIZED_OBJECTIVE_FOR_HESSIAN INIT_STATE FAST_REALTIME RESCALE_PREDICTION_ERROR_COVARIANCE GENERATE_IRFS %token NAN_CONSTANT NO_STATIC NOBS NOCONSTANT NODISPLAY NOCORR NODIAGNOSTIC NOFUNCTIONS NO_HOMOTOPY %token NOGRAPH POSTERIOR_NOGRAPH POSTERIOR_GRAPH NOMOMENTS NOPRINT NORMAL_PDF SAVE_DRAWS STDERR_MULTIPLES DIAGONAL_ONLY %token OBSERVATION_TRENDS OPTIM OPTIM_WEIGHTS ORDER OSR OSR_PARAMS MAX_DIM_COVA_GROUP ADVANCED OUTFILE OUTVARS OVERWRITE @@ -2687,6 +2687,7 @@ realtime_shock_decomposition_option : o_parameter_set | o_shock_decomposition_presample | o_shock_decomposition_forecast | o_save_realtime + | o_fast_realtime ; plot_shock_decomposition_options_list : plot_shock_decomposition_option COMMA plot_shock_decomposition_options_list @@ -3095,6 +3096,7 @@ o_init_state : INIT_STATE EQUAL INT_NUMBER { driver.option_num("shock_decomp.ini o_shock_decomposition_presample : PRESAMPLE EQUAL INT_NUMBER { driver.option_num("shock_decomp.presample", $3); }; o_shock_decomposition_forecast : FORECAST EQUAL INT_NUMBER { driver.option_num("shock_decomp.forecast", $3); }; o_save_realtime : SAVE_REALTIME EQUAL vec_int { driver.option_vec_int("shock_decomp.save_realtime", $3); }; +o_fast_realtime : FAST_REALTIME { driver.option_num("shock_decomp.fast_realtime", "1"); }; o_nodisplay : NODISPLAY { driver.option_num("nodisplay","1"); }; o_psd_nodisplay : NODISPLAY { driver.option_num("plot_shock_decomp.nodisplay","1"); }; o_graph_format : GRAPH_FORMAT EQUAL allowed_graph_formats diff --git a/DynareFlex.ll b/DynareFlex.ll index c35b8a01..db43397d 100644 --- a/DynareFlex.ll +++ b/DynareFlex.ll @@ -584,6 +584,7 @@ DATE -?[0-9]+([YyAa]|[Mm]([1-9]|1[0-2])|[Qq][1-4]|[Ww]([1-9]{1}|[1-4][0-9]|5[0-2 controlled_varexo {return token::CONTROLLED_VAREXO; } parameter_set {return token::PARAMETER_SET; } init_state {return token::INIT_STATE; } +fast_realtime {return token::FAST_REALTIME; } save_realtime {return token::SAVE_REALTIME;} detail_plot {return token::DETAIL_PLOT;} interactive {return token::INTERACTIVE;} From 7ffbe32445d2537d5f2db564d9661ebc78f140bc Mon Sep 17 00:00:00 2001 From: Houtan Bastani Date: Tue, 23 Jan 2018 16:31:33 +0100 Subject: [PATCH 2/9] macroprocessor: interpret arrays passed on the command line as arrays instead of strings. closes #1578 --- macro/MacroDriver.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/macro/MacroDriver.cc b/macro/MacroDriver.cc index bd15152b..446a9a9e 100644 --- a/macro/MacroDriver.cc +++ b/macro/MacroDriver.cc @@ -1,5 +1,5 @@ /* - * Copyright (C) 2008-2017 Dynare Team + * Copyright (C) 2008-2018 Dynare Team * * This file is part of Dynare. * @@ -60,7 +60,11 @@ MacroDriver::parse(const string &f, const string &fb, const string &modfiletxt, } catch (boost::bad_lexical_cast &) { - file_with_endl << "@#define " << it->first << " = \"" << it->second << "\"" << endl; + if (it->second.front() == '[' && it->second.back() == ']') + // If the input is an array. Issue #1578 + file_with_endl << "@#define " << it->first << " = " << it->second << endl; + else + file_with_endl << "@#define " << it->first << " = \"" << it->second << "\"" << endl; } file_with_endl << modfiletxt << endl; From 17dd443341b55374feb011c161c21296ff0bd80b Mon Sep 17 00:00:00 2001 From: Houtan Bastani Date: Tue, 23 Jan 2018 17:13:46 +0100 Subject: [PATCH 3/9] macroprocessor: allow inline comments. closes #1550 --- macro/MacroFlex.ll | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/macro/MacroFlex.ll b/macro/MacroFlex.ll index 5125ffa7..57776709 100644 --- a/macro/MacroFlex.ll +++ b/macro/MacroFlex.ll @@ -1,5 +1,5 @@ /* - * Copyright (C) 2008-2017 Dynare Team + * Copyright (C) 2008-2018 Dynare Team * * This file is part of Dynare. * @@ -71,6 +71,8 @@ CONT \\\\ yylloc->step(); %} +["/"]["/"].* + ^{SPC}*@#{SPC}*includepath{SPC}+\"([^\"\r\n:;|<>]*){1}(:[^\"\r\n:;|<>]*)*\"{SPC}*{EOL} { yylloc->lines(1); yylloc->step(); From 8bae11e85a4129990723d91488ccb74d3970c8a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Adjemian=20=28Charybdis=29?= Date: Wed, 24 Jan 2018 22:15:57 +0100 Subject: [PATCH 4/9] Revert "macroprocessor: interpret arrays passed on the command line as arrays instead of strings. closes #1578" Commit 204d9cd05fef9ac6fda8530536578c05fab66366 fails with gcc 4.9 (I checked that it works flawlessly with 6.x). The error message is: MacroDriver.cc:63:24: error: 'class std::basic_string' has no member named 'front' if (it->second.front() == '[' && it->second.back() == ']') ^ MacroDriver.cc:63:53: error: 'class std::basic_string' has no member named 'back' if (it->second.front() == '[' && it->second.back() == ']') Ideally we should bump the version of gcc used in the build system, but I will not do that before the next bug fix release. I suppose it is easier to replace the front() and back() methods. --- macro/MacroDriver.cc | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/macro/MacroDriver.cc b/macro/MacroDriver.cc index 446a9a9e..bd15152b 100644 --- a/macro/MacroDriver.cc +++ b/macro/MacroDriver.cc @@ -1,5 +1,5 @@ /* - * Copyright (C) 2008-2018 Dynare Team + * Copyright (C) 2008-2017 Dynare Team * * This file is part of Dynare. * @@ -60,11 +60,7 @@ MacroDriver::parse(const string &f, const string &fb, const string &modfiletxt, } catch (boost::bad_lexical_cast &) { - if (it->second.front() == '[' && it->second.back() == ']') - // If the input is an array. Issue #1578 - file_with_endl << "@#define " << it->first << " = " << it->second << endl; - else - file_with_endl << "@#define " << it->first << " = \"" << it->second << "\"" << endl; + file_with_endl << "@#define " << it->first << " = \"" << it->second << "\"" << endl; } file_with_endl << modfiletxt << endl; From 46fbd8107c6c9821386d6c17799daff9ce4f0d19 Mon Sep 17 00:00:00 2001 From: Houtan Bastani Date: Thu, 25 Jan 2018 00:47:50 +0100 Subject: [PATCH 5/9] Fix commit reverted in 4d89452e1bb6cc55f0800d6cbf976f2519f822c1. --- macro/MacroDriver.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/macro/MacroDriver.cc b/macro/MacroDriver.cc index bd15152b..b0420b44 100644 --- a/macro/MacroDriver.cc +++ b/macro/MacroDriver.cc @@ -1,5 +1,5 @@ /* - * Copyright (C) 2008-2017 Dynare Team + * Copyright (C) 2008-2018 Dynare Team * * This file is part of Dynare. * @@ -60,7 +60,11 @@ MacroDriver::parse(const string &f, const string &fb, const string &modfiletxt, } catch (boost::bad_lexical_cast &) { - file_with_endl << "@#define " << it->first << " = \"" << it->second << "\"" << endl; + if (!it->second.empty() && it->second.at(0) == '[' && it->second.at(it->second.length()-1) == ']') + // If the input is an array. Issue #1578 + file_with_endl << "@#define " << it->first << " = " << it->second << endl; + else + file_with_endl << "@#define " << it->first << " = \"" << it->second << "\"" << endl; } file_with_endl << modfiletxt << endl; From da76711fd6561830a9fa63d44016f8b4af54760a Mon Sep 17 00:00:00 2001 From: Johannes Pfeifer Date: Thu, 23 Nov 2017 19:29:25 +0100 Subject: [PATCH 6/9] initial_condition_decomposition: return oo_ output argument to base workspace --- ComputingTasks.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ComputingTasks.cc b/ComputingTasks.cc index 9e0b157b..e8372134 100644 --- a/ComputingTasks.cc +++ b/ComputingTasks.cc @@ -2418,7 +2418,7 @@ InitialConditionDecompositionStatement::writeOutput(ostream &output, const strin output << "options_ = set_default_initial_condition_decomposition_options(options_);" << endl; options_list.writeOutput(output); symbol_list.writeOutput("var_list_", output); - output << "initial_condition_decomposition(M_, oo_, options_, var_list_, bayestopt_, estim_params_);" << endl; + output << "oo_ = initial_condition_decomposition(M_, oo_, options_, var_list_, bayestopt_, estim_params_);" << endl; } ConditionalForecastStatement::ConditionalForecastStatement(const OptionsList &options_list_arg) : From a9a882bb3d1a83799e98d0f3a841921cce57115f Mon Sep 17 00:00:00 2001 From: Johannes Pfeifer Date: Thu, 23 Nov 2017 19:32:25 +0100 Subject: [PATCH 7/9] initial_condition_decomposition: Add nodisplay, graph_format, fig_name options --- DynareBison.yy | 3 +++ 1 file changed, 3 insertions(+) diff --git a/DynareBison.yy b/DynareBison.yy index 97c45514..7fbae92a 100644 --- a/DynareBison.yy +++ b/DynareBison.yy @@ -2721,6 +2721,9 @@ initial_condition_decomposition_option : o_icd_type | o_icd_write_xls | o_icd_plot_init_date | o_icd_plot_end_date + | o_nodisplay + | o_graph_format + | o_psd_fig_name ; homotopy_setup: HOMOTOPY_SETUP ';' homotopy_list END ';' From b94ff64cbc579f9f06b6ac462ae6157cc56266d6 Mon Sep 17 00:00:00 2001 From: Johannes Pfeifer Date: Fri, 12 Jan 2018 14:25:26 +0100 Subject: [PATCH 8/9] Make fast_realtime accept observation as input --- DynareBison.yy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DynareBison.yy b/DynareBison.yy index 7fbae92a..64c3a796 100644 --- a/DynareBison.yy +++ b/DynareBison.yy @@ -3099,7 +3099,7 @@ o_init_state : INIT_STATE EQUAL INT_NUMBER { driver.option_num("shock_decomp.ini o_shock_decomposition_presample : PRESAMPLE EQUAL INT_NUMBER { driver.option_num("shock_decomp.presample", $3); }; o_shock_decomposition_forecast : FORECAST EQUAL INT_NUMBER { driver.option_num("shock_decomp.forecast", $3); }; o_save_realtime : SAVE_REALTIME EQUAL vec_int { driver.option_vec_int("shock_decomp.save_realtime", $3); }; -o_fast_realtime : FAST_REALTIME { driver.option_num("shock_decomp.fast_realtime", "1"); }; +o_fast_realtime : FAST_REALTIME EQUAL INT_NUMBER { driver.option_num("shock_decomp.fast_realtime", $3); }; o_nodisplay : NODISPLAY { driver.option_num("nodisplay","1"); }; o_psd_nodisplay : NODISPLAY { driver.option_num("plot_shock_decomp.nodisplay","1"); }; o_graph_format : GRAPH_FORMAT EQUAL allowed_graph_formats From ad1ef0d8562cfb1b85ae90bdb82fc3fab5b71b83 Mon Sep 17 00:00:00 2001 From: Houtan Bastani Date: Mon, 29 Jan 2018 10:56:41 +0100 Subject: [PATCH 9/9] macroprocessor: fix unhandled case of nested ifdef/ifndef statements. closes #1587 --- macro/MacroFlex.ll | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/macro/MacroFlex.ll b/macro/MacroFlex.ll index 57776709..21a35a1c 100644 --- a/macro/MacroFlex.ll +++ b/macro/MacroFlex.ll @@ -305,6 +305,16 @@ CONT \\\\ then_body_tmp.append(yytext); yylloc->step(); } +^{SPC}*@#{SPC}*ifdef({SPC}|{CONT}) { + nested_if_nb++; + then_body_tmp.append(yytext); + yylloc->step(); + } +^{SPC}*@#{SPC}*ifndef({SPC}|{CONT}) { + nested_if_nb++; + then_body_tmp.append(yytext); + yylloc->step(); + } . { then_body_tmp.append(yytext); yylloc->step(); } <> { driver.error(if_stmt_loc_tmp, "@#if/@#ifdef/@#ifndef not matched by an @#endif or file does not end with a new line (unexpected end of file)"); } ^{SPC}*@#{SPC}*else{SPC}*(\/\/.*)?{EOL} {