Commit 38ef4c23 authored by Houtan Bastani's avatar Houtan Bastani
Browse files

preprocessor: support long name for parameters, #478

parent ac2cd6f3
...@@ -1108,7 +1108,7 @@ varexo_det tau; ...@@ -1108,7 +1108,7 @@ varexo_det tau;
@end deffn @end deffn
@deffn Command parameters @var{PARAMETER_NAME} [$@var{LATEX_NAME}$]@dots{}; @deffn Command parameters @var{PARAMETER_NAME} [$@var{LATEX_NAME}$ [(long_name=@var{QUOTED_STRING})]]@dots{};
@descriptionhead @descriptionhead
...@@ -1123,6 +1123,12 @@ initialization}). ...@@ -1123,6 +1123,12 @@ initialization}).
@code{parameters} commands can appear several times in the file and @code{parameters} commands can appear several times in the file and
Dynare will concatenate them. Dynare will concatenate them.
@optionshead
@table @code
@item long_name = @var{QUOTED_STRING}
Like @ref{long_name} but value stored in @code{M_.param_names_long}.
@end table
@examplehead @examplehead
@example @example
......
...@@ -430,6 +430,12 @@ parameter_list : parameter_list symbol ...@@ -430,6 +430,12 @@ parameter_list : parameter_list symbol
{ driver.declare_parameter($3, $4); } { driver.declare_parameter($3, $4); }
| symbol TEX_NAME | symbol TEX_NAME
{ driver.declare_parameter($1, $2); } { driver.declare_parameter($1, $2); }
| parameter_list symbol TEX_NAME named_var
{ driver.declare_parameter($2, $3, $4); }
| parameter_list COMMA symbol TEX_NAME named_var
{ driver.declare_parameter($3, $4, $5); }
| symbol TEX_NAME named_var
{ driver.declare_parameter($1, $2, $3); }
; ;
predetermined_variables_list : predetermined_variables_list symbol predetermined_variables_list : predetermined_variables_list symbol
......
...@@ -186,12 +186,14 @@ ParsingDriver::declare_exogenous_det(string *name, string *tex_name, string *lon ...@@ -186,12 +186,14 @@ ParsingDriver::declare_exogenous_det(string *name, string *tex_name, string *lon
} }
void void
ParsingDriver::declare_parameter(string *name, string *tex_name) ParsingDriver::declare_parameter(string *name, string *tex_name, string *long_name)
{ {
declare_symbol(name, eParameter, tex_name, NULL); declare_symbol(name, eParameter, tex_name, long_name);
delete name; delete name;
if (tex_name != NULL) if (tex_name != NULL)
delete tex_name; delete tex_name;
if (long_name != NULL)
delete long_name;
} }
void void
......
...@@ -264,7 +264,7 @@ public: ...@@ -264,7 +264,7 @@ public:
//! Declares an exogenous deterministic variable //! Declares an exogenous deterministic variable
void declare_exogenous_det(string *name, string *tex_name = NULL, string *long_name = NULL); void declare_exogenous_det(string *name, string *tex_name = NULL, string *long_name = NULL);
//! Declares a parameter //! Declares a parameter
void declare_parameter(string *name, string *tex_name = NULL); void declare_parameter(string *name, string *tex_name = NULL, string *long_name = NULL);
//! Declares a statement local variable //! Declares a statement local variable
void declare_statement_local_variable(string *name); void declare_statement_local_variable(string *name);
//! Completes a subsample statement //! Completes a subsample statement
......
...@@ -211,10 +211,12 @@ SymbolTable::writeOutput(ostream &output) const throw (NotYetFrozenException) ...@@ -211,10 +211,12 @@ SymbolTable::writeOutput(ostream &output) const throw (NotYetFrozenException)
{ {
output << "M_.param_names = '" << getName(param_ids[0]) << "';" << endl; output << "M_.param_names = '" << getName(param_ids[0]) << "';" << endl;
output << "M_.param_names_tex = '" << getTeXName(param_ids[0]) << "';" << endl; output << "M_.param_names_tex = '" << getTeXName(param_ids[0]) << "';" << endl;
output << "M_.param_names_long = '" << getLongName(param_ids[0]) << "';" << endl;
for (int id = 1; id < param_nbr(); id++) for (int id = 1; id < param_nbr(); id++)
{ {
output << "M_.param_names = char(M_.param_names, '" << getName(param_ids[id]) << "');" << endl output << "M_.param_names = char(M_.param_names, '" << getName(param_ids[id]) << "');" << endl
<< "M_.param_names_tex = char(M_.param_names_tex, '" << getTeXName(param_ids[id]) << "');" << endl; << "M_.param_names_tex = char(M_.param_names_tex, '" << getTeXName(param_ids[id]) << "');" << endl
<< "M_.param_names_long = char(M_.param_names_long, '" << getLongName(param_ids[id]) << "');" << endl;
if (getName(param_ids[id]) == "dsge_prior_weight") if (getName(param_ids[id]) == "dsge_prior_weight")
output << "options_.dsge_var = 1;" << endl; output << "options_.dsge_var = 1;" << endl;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment