preprocessor: only accept dates of the form: dates('date') in mod file

issue#70
Houtan Bastani 2013-10-11 16:28:14 +02:00
parent c2a3d342d8
commit aee8202a20
5 changed files with 13 additions and 20 deletions

View File

@ -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);

View File

@ -178,7 +178,7 @@ class ParsingDriver;
%type <node_val> expression expression_or_empty
%type <node_val> equation hand_side
%type <string_val> non_negative_number signed_number signed_integer date_number
%type <string_val> non_negative_number signed_number signed_integer
%type <string_val> filename symbol vec_of_vec_value vec_value_list
%type <string_val> vec_value_1 vec_value signed_inf signed_number_w_inf
%type <string_val> 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); };

View File

@ -690,7 +690,7 @@ string eofbuff;
return token::INT_NUMBER;
}
<DYNARE_STATEMENT,DYNARE_BLOCK>-?[0-9]+([YyAa]|[Mm]([1-9]|1[0-2])|[Qq][1-4]|[Ww]([1-9]{1}|[1-4][0-9]|5[0-2])) {
<DYNARE_STATEMENT,DYNARE_BLOCK>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;
}

View File

@ -1226,10 +1226,7 @@ ParsingDriver::set_unit_root_vars()
void
ParsingDriver::set_time(string *arg)
{
string arg1 = *arg;
for (size_t i=0; i<arg1.length(); i++)
arg1[i]= toupper(arg1[i]);
option_date("initial_period", arg1);
option_date("initial_period", arg);
mod_file->addStatement(new SetTimeStatement(options_list));
options_list.clear();
}

View File

@ -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++)