From aee8202a20c31ed828baa584391844c864e66c1e Mon Sep 17 00:00:00 2001 From: Houtan Bastani Date: Fri, 11 Oct 2013 16:28:14 +0200 Subject: [PATCH] preprocessor: only accept dates of the form: dates('date') in mod file --- ComputingTasks.cc | 8 ++++---- DynareBison.yy | 14 +++++--------- DynareFlex.ll | 2 +- ParsingDriver.cc | 5 +---- Statement.cc | 4 ++-- 5 files changed, 13 insertions(+), 20 deletions(-) diff --git a/ComputingTasks.cc b/ComputingTasks.cc index 458a1db2..70d20bf5 100644 --- a/ComputingTasks.cc +++ b/ComputingTasks.cc @@ -1767,10 +1767,10 @@ SubsamplesStatement::writeOutput(ostream &output, const string &basename) const it != subsample_declaration_map.end(); it++, map_indx++) output << "estimation_info.subsamples(subsamples_indx).range_index(" << map_indx << ") = {'" << it->first << "'};" << endl - << "estimation_info.subsamples(subsamples_indx).range(" << map_indx << ").date1 = dynDate('" - << it->second.first << "');" << endl - << "estimation_info.subsamples(subsamples_indx).range(" << map_indx << ").date2 = dynDate('" - << it->second.second << "');" << endl; + << "estimation_info.subsamples(subsamples_indx).range(" << map_indx << ").date1 = " + << it->second.first << endl + << "estimation_info.subsamples(subsamples_indx).range(" << map_indx << ").date2 = " + << it->second.second << endl; // Initialize associated subsample substructures in estimation_info const SymbolType symb_type = symbol_table.getType(name1); diff --git a/DynareBison.yy b/DynareBison.yy index 85663273..a53fa0d3 100644 --- a/DynareBison.yy +++ b/DynareBison.yy @@ -178,7 +178,7 @@ class ParsingDriver; %type expression expression_or_empty %type equation hand_side -%type non_negative_number signed_number signed_integer date_number +%type non_negative_number signed_number signed_integer %type filename symbol vec_of_vec_value vec_value_list %type vec_value_1 vec_value signed_inf signed_number_w_inf %type range vec_value_w_inf vec_value_1_w_inf @@ -1024,10 +1024,6 @@ non_negative_number : INT_NUMBER | FLOAT_NUMBER ; -date_number : DATE_NUMBER - | INT_NUMBER - ; - signed_number : PLUS non_negative_number { $$ = $2; } | MINUS non_negative_number @@ -1243,7 +1239,7 @@ prior_pdf : BETA_PDF { $$ = eInvGamma2; } ; -set_time : SET_TIME '(' date_number ')' ';' +set_time : SET_TIME '(' DATE_NUMBER ')' ';' { driver.set_time($3); } ; @@ -2295,10 +2291,10 @@ o_conditional_variance_decomposition : CONDITIONAL_VARIANCE_DECOMPOSITION EQUAL { driver.option_vec_int("conditional_variance_decomposition", $3); } ; o_first_obs : FIRST_OBS EQUAL INT_NUMBER { driver.option_num("first_obs", $3); }; -o_new_estimation_data_first_obs : FIRST_OBS EQUAL date_number +o_new_estimation_data_first_obs : FIRST_OBS EQUAL DATE_NUMBER { driver.option_date("first_obs", $3); } ; -o_last_obs : LAST_OBS EQUAL date_number +o_last_obs : LAST_OBS EQUAL DATE_NUMBER { driver.option_date("last_obs", $3); } ; o_shift : SHIFT EQUAL signed_number { driver.option_num("shift", $3); }; @@ -2342,7 +2338,7 @@ list_allowed_graph_formats : allowed_graph_formats | list_allowed_graph_formats COMMA allowed_graph_formats ; -o_subsample_name : symbol EQUAL date_number ':' date_number +o_subsample_name : symbol EQUAL DATE_NUMBER ':' DATE_NUMBER { driver.set_subsample_name_equal_to_date_range($1, $3, $5); } ; o_conf_sig : CONF_SIG EQUAL non_negative_number { driver.option_num("conf_sig", $3); }; diff --git a/DynareFlex.ll b/DynareFlex.ll index ad894a6e..c836be7f 100644 --- a/DynareFlex.ll +++ b/DynareFlex.ll @@ -690,7 +690,7 @@ string eofbuff; return token::INT_NUMBER; } --?[0-9]+([YyAa]|[Mm]([1-9]|1[0-2])|[Qq][1-4]|[Ww]([1-9]{1}|[1-4][0-9]|5[0-2])) { +dates[[:space:]]*\([[:space:]]*\'[[:space:]]*-?[0-9]+([YyAa]|[Mm]([1-9]|1[0-2])|[Qq][1-4]|[Ww]([1-9]{1}|[1-4][0-9]|5[0-2]))[[:space:]]*\'[[:space:]]*\) { yylval->string_val = new string(yytext); return token::DATE_NUMBER; } diff --git a/ParsingDriver.cc b/ParsingDriver.cc index 38bf5a78..31d5fbfa 100644 --- a/ParsingDriver.cc +++ b/ParsingDriver.cc @@ -1226,10 +1226,7 @@ ParsingDriver::set_unit_root_vars() void ParsingDriver::set_time(string *arg) { - string arg1 = *arg; - for (size_t i=0; iaddStatement(new SetTimeStatement(options_list)); options_list.clear(); } diff --git a/Statement.cc b/Statement.cc index 59021287..76b600b7 100644 --- a/Statement.cc +++ b/Statement.cc @@ -94,7 +94,7 @@ OptionsList::writeOutput(ostream &output) const for (date_options_t::const_iterator it = date_options.begin(); it != date_options.end(); it++) - output << "options_." << it->first << " = dynDate('" << it->second << "');" << endl; + output << "options_." << it->first << " = " << it->second << ";" << endl; for (symbol_list_options_t::const_iterator it = symbol_list_options.begin(); it != symbol_list_options.end(); it++) @@ -137,7 +137,7 @@ OptionsList::writeOutput(ostream &output, const string &option_group) const for (date_options_t::const_iterator it = date_options.begin(); it != date_options.end(); it++) - output << option_group << "." << it->first << " = dynDate('" << it->second << "');" << endl; + output << option_group << "." << it->first << " = " << it->second << ";" << endl; for (symbol_list_options_t::const_iterator it = symbol_list_options.begin(); it != symbol_list_options.end(); it++)