Commit 1867caa5 authored by michel's avatar michel
Browse files

v4 preprocessor: adding list of strings as option type

                 added some options for GSA

git-svn-id: https://www.dynare.org/svn/dynare/dynare_v4@1781 ac1d8469-bf42-47a9-8791-bf33cf982152
parent 21d00c14
......@@ -1240,6 +1240,10 @@ dynare_sensitivity_option : o_gsa_identification
| o_gsa_alpha_rmse
| o_gsa_alpha2_rmse
| o_gsa_threshold_redform
| o_gsa_namendo
| o_gsa_namexo
| o_gsa_namlagendo
| o_gsa_var_rmse
;
homotopy_setup: HOMOTOPY_SETUP ';' homotopy_list END
......@@ -1364,23 +1368,19 @@ o_gsa_nsam : NSAM EQUAL INT_NUMBER { driver.option_num("identification", $3); };
o_gsa_load_redform : LOAD_REDFORM EQUAL INT_NUMBER { driver.option_num("identification", $3); };
o_gsa_load_rmse : LOAD_RMSE EQUAL INT_NUMBER { driver.option_num("load_rmse", $3); };
o_gsa_load_stab : LOAD_STAB EQUAL INT_NUMBER { driver.option_num("load_stab", $3); };
o_gsa_alpha2_stab : ALPHA2_STAB EQUAL number { driver.option_num("identification", $3); };
o_gsa_alpha2_stab : ALPHA2_STAB EQUAL number { driver.option_num("alpha2_stab", $3); };
o_gsa_ksstat : KSSTAT EQUAL number { driver.option_num("ksstat", $3); };
o_gsa_logtrans_redform : LOGTRANS_REDFORM EQUAL INT_NUMBER { driver.option_num("logtrans_redform", $3); };
o_gsa_threshold_redform : THRESHOLD_REDFORM EQUAL vec_int { driver.option_num("threshold_redfor",$3); };
o_gsa_ksstat_redform : KSSTAT_REDFORM EQUAL number { driver.option_num("ksstat_redfrom", $3); };
o_gsa_alpha2_redform : ALPHA2_REDFORM EQUAL number { driver.option_num("alpha2_redform", $3); };
/*
o_gsa_namendo : NAMENDO EQUAL tmp_var_list { driver.option_list("namendo", $3); };
o_gsa_namlagendo : NAMLAGENDO tmp_var_list { driver.option_list("namlagendo", $3); };
o_gsa_namexo : NAMEXO tmp_var_list { driver.option_list("namexo", $3); };
*/
o_gsa_namendo : NAMENDO EQUAL '(' tmp_var_list ')' { driver.option_str_lst("namendo"); };
o_gsa_namlagendo : NAMLAGENDO EQUAL '(' tmp_var_list ')' { driver.option_str_lst("namlagendo"); };
o_gsa_namexo : NAMEXO EQUAL '(' tmp_var_list ')' { driver.option_str_lst("namexo"); };
o_gsa_rmse : RMSE EQUAL INT_NUMBER { driver.option_num("rmse", $3); };
o_gsa_lik_only : LIK_ONLY EQUAL INT_NUMBER { driver.option_num("lik_only", $3); };
/*
o_gsa_var_rmse : VAR_RMSE tmp_var_list { driver.option_list("var_rmse", $3); };
*/
o_gsa_var_rmse : VAR_RMSE EQUAL '(' tmp_var_list ')' { driver.option_str_lst("var_rmse"); };
o_gsa_pfilt_rmse : PFILT_RMSE EQUAL number { driver.option_num("pfilt_rmse", $3); };
o_gsa_istart_rmse : ISTART_RMSE EQUAL INT_NUMBER { driver.option_num("istart_rmse", $3); };
o_gsa_alpha_rmse : ALPHA_RMSE EQUAL number { driver.option_num("alpha_rmse", $3); };
......
......@@ -654,6 +654,20 @@ ParsingDriver::option_str(const string &name_option, const string &opt)
options_list.string_options[name_option] = opt;
}
void
ParsingDriver::option_str_lst(const string &name_option)
{
if (options_list.string_list_options.find(name_option)
!= options_list.string_list_options.end())
error("option " + name_option + " declared twice");
options_list.string_list_options[name_option] = new TmpSymbolTable::TmpSymbolTable(*tmp_symbol_table);
tmp_symbol_table->clear();
}
void
ParsingDriver::linear()
{
......
......@@ -67,6 +67,10 @@ OptionsList::writeOutput(ostream &output) const
for(string_options_type::const_iterator it = string_options.begin();
it != string_options.end(); it++)
output << "options_." << it->first << " = '" << it->second << "';" << endl;
for(string_list_options_type::const_iterator it = string_list_options.begin();
it != string_list_options.end(); it++)
it->second->writeOutput("options_."+it->first,output);
}
void
......
......@@ -264,6 +264,8 @@ public:
void option_str(const string &name_option, string *opt);
//! Sets an option to a string value
void option_str(const string &name_option, const string &opt);
//! Sets an option to a list of strings
void option_str_lst(const string &name_option);
//! Indicates that the model is linear
void linear();
//! Adds a variable to temp symbol table and sets its value
......
......@@ -26,6 +26,7 @@ using namespace std;
#include <string>
#include <map>
#include "TmpSymbolTable.hh"
class ModFileStructure
{
public:
......@@ -71,9 +72,11 @@ public:
typedef map<string, string> num_options_type;
typedef map<string, pair<string, string> > paired_num_options_type;
typedef map<string, string> string_options_type;
typedef map<string, TmpSymbolTable*> string_list_options_type;
num_options_type num_options;
paired_num_options_type paired_num_options;
string_options_type string_options;
string_list_options_type string_list_options;
void writeOutput(ostream &output) const;
void clear();
};
......
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