preprocessor: allow symbol.subsample=symbol.subsample

issue#70
Houtan Bastani 2011-12-15 11:49:04 +01:00
parent 1d68887387
commit 6ea0dd59e4
3 changed files with 22 additions and 0 deletions

View File

@ -218,6 +218,7 @@ statement : parameters
| data
| prior
| subsamples
| subsamples_eq
| varobs
| observation_trends
| unit_root_vars
@ -1202,6 +1203,10 @@ subsamples : symbol '.' SUBSAMPLES '(' subsamples_name_list ')' ';'
{ driver.set_subsamples($1); }
;
subsamples_eq : symbol '.' SUBSAMPLES EQUAL symbol '.' SUBSAMPLES ';'
{ driver.copy_subsamples($1, $5); }
;
subsamples_name_list : subsamples_name_list COMMA o_subsample_name
| o_subsample_name
;

View File

@ -1234,6 +1234,21 @@ ParsingDriver::estimation_data()
options_list.clear();
}
void
ParsingDriver::copy_subsamples(string *to_parameter, string *from_parameter)
{
check_symbol_is_parameter(to_parameter);
check_symbol_is_parameter(from_parameter);
if (subsample_declarations.find(*to_parameter) != subsample_declarations.end())
error("Parameter " + *to_parameter + " has more than one subsample statement." +
"You may only have one subsample statement per parameter.");
if (subsample_declarations.find(*from_parameter) == subsample_declarations.end())
error("Parameter " + *from_parameter + " does not have an associated subsample statement.");
subsample_declarations[*to_parameter] = subsample_declarations[*from_parameter];
delete to_parameter;
delete from_parameter;
}
void
ParsingDriver::set_subsamples(string *name)
{

View File

@ -256,6 +256,8 @@ public:
void set_subsample_name_equal_to_date_range(string *name, string *date1, string *date2);
//! Adds a subsample range to the list of options for the prior statement
void add_subsample_range(string *parameter, string *subsample_name);
//! Copies the set of subsamples from_parameter to_parameter
void copy_subsamples(string *to_parameter, string *from_parameter);
//! Declares declare_optimal_policy_discount_factor as a parameter and initializes it to exprnode
void declare_optimal_policy_discount_factor_parameter(expr_t exprnode);
//! Adds a predetermined_variable