v4 preprocessor:
* renamed TmpSymbolTable to SymbolList (with some clean up by the way) * removed unused mechanism of alternative variable names in tmp_var_list * OptionsList: fixed memory leak and bug in clear() git-svn-id: https://www.dynare.org/svn/dynare/dynare_v4@1785 ac1d8469-bf42-47a9-8791-bf33cf982152issue#70
parent
f63c2c091b
commit
6a9f2c4798
|
@ -138,9 +138,9 @@ SimulSparseStatement::writeOutput(ostream &output, const string &basename) const
|
|||
}
|
||||
}
|
||||
|
||||
StochSimulStatement::StochSimulStatement(const TmpSymbolTable &tmp_symbol_table_arg,
|
||||
StochSimulStatement::StochSimulStatement(const SymbolList &symbol_list_arg,
|
||||
const OptionsList &options_list_arg) :
|
||||
tmp_symbol_table(tmp_symbol_table_arg),
|
||||
symbol_list(symbol_list_arg),
|
||||
options_list(options_list_arg)
|
||||
{
|
||||
}
|
||||
|
@ -160,13 +160,13 @@ void
|
|||
StochSimulStatement::writeOutput(ostream &output, const string &basename) const
|
||||
{
|
||||
options_list.writeOutput(output);
|
||||
tmp_symbol_table.writeOutput("var_list_", output);
|
||||
symbol_list.writeOutput("var_list_", output);
|
||||
output << "info = stoch_simul(var_list_);\n";
|
||||
}
|
||||
|
||||
RamseyPolicyStatement::RamseyPolicyStatement(const TmpSymbolTable &tmp_symbol_table_arg,
|
||||
RamseyPolicyStatement::RamseyPolicyStatement(const SymbolList &symbol_list_arg,
|
||||
const OptionsList &options_list_arg) :
|
||||
tmp_symbol_table(tmp_symbol_table_arg),
|
||||
symbol_list(symbol_list_arg),
|
||||
options_list(options_list_arg)
|
||||
{
|
||||
}
|
||||
|
@ -188,13 +188,13 @@ void
|
|||
RamseyPolicyStatement::writeOutput(ostream &output, const string &basename) const
|
||||
{
|
||||
options_list.writeOutput(output);
|
||||
tmp_symbol_table.writeOutput("var_list_", output);
|
||||
symbol_list.writeOutput("var_list_", output);
|
||||
output << "ramsey_policy(var_list_);\n";
|
||||
}
|
||||
|
||||
EstimationStatement::EstimationStatement(const TmpSymbolTable &tmp_symbol_table_arg,
|
||||
EstimationStatement::EstimationStatement(const SymbolList &symbol_list_arg,
|
||||
const OptionsList &options_list_arg) :
|
||||
tmp_symbol_table(tmp_symbol_table_arg),
|
||||
symbol_list(symbol_list_arg),
|
||||
options_list(options_list_arg)
|
||||
{
|
||||
}
|
||||
|
@ -214,13 +214,13 @@ void
|
|||
EstimationStatement::writeOutput(ostream &output, const string &basename) const
|
||||
{
|
||||
options_list.writeOutput(output);
|
||||
tmp_symbol_table.writeOutput("var_list_", output);
|
||||
symbol_list.writeOutput("var_list_", output);
|
||||
output << "dynare_estimation(var_list_);\n";
|
||||
}
|
||||
|
||||
PriorAnalysisStatement::PriorAnalysisStatement(const TmpSymbolTable &tmp_symbol_table_arg,
|
||||
PriorAnalysisStatement::PriorAnalysisStatement(const SymbolList &symbol_list_arg,
|
||||
const OptionsList &options_list_arg) :
|
||||
tmp_symbol_table(tmp_symbol_table_arg),
|
||||
symbol_list(symbol_list_arg),
|
||||
options_list(options_list_arg)
|
||||
{
|
||||
}
|
||||
|
@ -229,13 +229,13 @@ void
|
|||
PriorAnalysisStatement::writeOutput(ostream &output, const string &basename) const
|
||||
{
|
||||
options_list.writeOutput(output);
|
||||
tmp_symbol_table.writeOutput("var_list_", output);
|
||||
symbol_list.writeOutput("var_list_", output);
|
||||
output << "prior_analysis(var_list_);\n";
|
||||
}
|
||||
|
||||
PosteriorAnalysisStatement::PosteriorAnalysisStatement(const TmpSymbolTable &tmp_symbol_table_arg,
|
||||
PosteriorAnalysisStatement::PosteriorAnalysisStatement(const SymbolList &symbol_list_arg,
|
||||
const OptionsList &options_list_arg) :
|
||||
tmp_symbol_table(tmp_symbol_table_arg),
|
||||
symbol_list(symbol_list_arg),
|
||||
options_list(options_list_arg)
|
||||
{
|
||||
}
|
||||
|
@ -244,7 +244,7 @@ void
|
|||
PosteriorAnalysisStatement::writeOutput(ostream &output, const string &basename) const
|
||||
{
|
||||
options_list.writeOutput(output);
|
||||
tmp_symbol_table.writeOutput("var_list_", output);
|
||||
symbol_list.writeOutput("var_list_", output);
|
||||
output << "posterior_analysis(var_list_);\n";
|
||||
}
|
||||
|
||||
|
@ -260,9 +260,9 @@ DynareSensitivityStatement::writeOutput(ostream &output, const string &basename)
|
|||
output << "dynare_sensitivity(options_gsa);" << endl;
|
||||
}
|
||||
|
||||
RplotStatement::RplotStatement(const TmpSymbolTable &tmp_symbol_table_arg,
|
||||
RplotStatement::RplotStatement(const SymbolList &symbol_list_arg,
|
||||
const OptionsList &options_list_arg) :
|
||||
tmp_symbol_table(tmp_symbol_table_arg),
|
||||
symbol_list(symbol_list_arg),
|
||||
options_list(options_list_arg)
|
||||
{
|
||||
}
|
||||
|
@ -271,19 +271,19 @@ void
|
|||
RplotStatement::writeOutput(ostream &output, const string &basename) const
|
||||
{
|
||||
options_list.writeOutput(output);
|
||||
tmp_symbol_table.writeOutput("var_list_", output);
|
||||
symbol_list.writeOutput("var_list_", output);
|
||||
output << "rplot(var_list_);\n";
|
||||
}
|
||||
|
||||
UnitRootVarsStatement::UnitRootVarsStatement(const TmpSymbolTable &tmp_symbol_table_arg) :
|
||||
tmp_symbol_table(tmp_symbol_table_arg)
|
||||
UnitRootVarsStatement::UnitRootVarsStatement(const SymbolList &symbol_list_arg) :
|
||||
symbol_list(symbol_list_arg)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
UnitRootVarsStatement::writeOutput(ostream &output, const string &basename) const
|
||||
{
|
||||
tmp_symbol_table.writeOutput("options_.unit_root_vars", output);
|
||||
symbol_list.writeOutput("options_.unit_root_vars", output);
|
||||
}
|
||||
|
||||
PeriodsStatement::PeriodsStatement(int periods_arg) : periods(periods_arg)
|
||||
|
@ -334,15 +334,15 @@ DsampleStatement::writeOutput(ostream &output, const string &basename) const
|
|||
output << "options_.dsample = [" << val1 << "; " << val2 << "];" << endl;
|
||||
}
|
||||
|
||||
VarobsStatement::VarobsStatement(const TmpSymbolTable &tmp_symbol_table_arg) :
|
||||
tmp_symbol_table(tmp_symbol_table_arg)
|
||||
VarobsStatement::VarobsStatement(const SymbolList &symbol_list_arg) :
|
||||
symbol_list(symbol_list_arg)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
VarobsStatement::writeOutput(ostream &output, const string &basename) const
|
||||
{
|
||||
tmp_symbol_table.writeOutput("options_.varobs", output);
|
||||
symbol_list.writeOutput("options_.varobs", output);
|
||||
}
|
||||
|
||||
EstimatedParamsStatement::EstimatedParamsStatement(const vector<EstimationParams> &estim_params_list_arg,
|
||||
|
@ -653,20 +653,20 @@ CalibStatement::writeOutput(ostream &output, const string &basename) const
|
|||
output << "M_.Sigma_e=calib(calib_var_index,calib_targets,calib_weights," << covar << ",Sigma_e_);\n";
|
||||
}
|
||||
|
||||
OsrParamsStatement::OsrParamsStatement(const TmpSymbolTable &tmp_symbol_table_arg) :
|
||||
tmp_symbol_table(tmp_symbol_table_arg)
|
||||
OsrParamsStatement::OsrParamsStatement(const SymbolList &symbol_list_arg) :
|
||||
symbol_list(symbol_list_arg)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
OsrParamsStatement::writeOutput(ostream &output, const string &basename) const
|
||||
{
|
||||
tmp_symbol_table.writeOutput("osr_params_", output);
|
||||
symbol_list.writeOutput("osr_params_", output);
|
||||
}
|
||||
|
||||
OsrStatement::OsrStatement(const TmpSymbolTable &tmp_symbol_table_arg,
|
||||
OsrStatement::OsrStatement(const SymbolList &symbol_list_arg,
|
||||
const OptionsList &options_list_arg) :
|
||||
tmp_symbol_table(tmp_symbol_table_arg),
|
||||
symbol_list(symbol_list_arg),
|
||||
options_list(options_list_arg)
|
||||
{
|
||||
}
|
||||
|
@ -686,7 +686,7 @@ void
|
|||
OsrStatement::writeOutput(ostream &output, const string &basename) const
|
||||
{
|
||||
options_list.writeOutput(output);
|
||||
tmp_symbol_table.writeOutput("var_list_", output);
|
||||
symbol_list.writeOutput("var_list_", output);
|
||||
output << "osr(var_list_,osr_params_,obj_var_,optim_weights_);\n";
|
||||
}
|
||||
|
||||
|
@ -733,9 +733,9 @@ OptimWeightsStatement::writeOutput(ostream &output, const string &basename) cons
|
|||
}
|
||||
}
|
||||
|
||||
DynaSaveStatement::DynaSaveStatement(const TmpSymbolTable &tmp_symbol_table_arg,
|
||||
DynaSaveStatement::DynaSaveStatement(const SymbolList &symbol_list_arg,
|
||||
const string &filename_arg, const string &ext_arg) :
|
||||
tmp_symbol_table(tmp_symbol_table_arg),
|
||||
symbol_list(symbol_list_arg),
|
||||
filename(filename_arg),
|
||||
ext(ext_arg)
|
||||
{
|
||||
|
@ -744,16 +744,16 @@ DynaSaveStatement::DynaSaveStatement(const TmpSymbolTable &tmp_symbol_table_arg,
|
|||
void
|
||||
DynaSaveStatement::writeOutput(ostream &output, const string &basename) const
|
||||
{
|
||||
tmp_symbol_table.writeOutput("var_list_", output);
|
||||
symbol_list.writeOutput("var_list_", output);
|
||||
output << "dynasave(" << filename;
|
||||
if (ext.size() > 0)
|
||||
output << "," << ext;
|
||||
output << ",var_list_);\n";
|
||||
}
|
||||
|
||||
DynaTypeStatement::DynaTypeStatement(const TmpSymbolTable &tmp_symbol_table_arg,
|
||||
DynaTypeStatement::DynaTypeStatement(const SymbolList &symbol_list_arg,
|
||||
const string &filename_arg, const string &ext_arg) :
|
||||
tmp_symbol_table(tmp_symbol_table_arg),
|
||||
symbol_list(symbol_list_arg),
|
||||
filename(filename_arg),
|
||||
ext(ext_arg)
|
||||
{
|
||||
|
@ -762,7 +762,7 @@ DynaTypeStatement::DynaTypeStatement(const TmpSymbolTable &tmp_symbol_table_arg,
|
|||
void
|
||||
DynaTypeStatement::writeOutput(ostream &output, const string &basename) const
|
||||
{
|
||||
tmp_symbol_table.writeOutput("var_list_", output);
|
||||
symbol_list.writeOutput("var_list_", output);
|
||||
output << "dynatype(" << filename;
|
||||
if (ext.size() > 0)
|
||||
output << "," << ext;
|
||||
|
|
|
@ -665,17 +665,11 @@ stoch_simul_options : o_dr_algo
|
|||
;
|
||||
|
||||
tmp_var_list : tmp_var_list NAME
|
||||
{ driver.add_tmp_var($2); }
|
||||
| tmp_var_list NAME EQUAL NAME
|
||||
{ driver.add_tmp_var($2, $4); }
|
||||
{ driver.add_in_symbol_list($2); }
|
||||
| tmp_var_list COMMA NAME
|
||||
{ driver.add_tmp_var($3); }
|
||||
| tmp_var_list COMMA NAME EQUAL NAME
|
||||
{ driver.add_tmp_var($3, $5); }
|
||||
{ driver.add_in_symbol_list($3); }
|
||||
| NAME
|
||||
{ driver.add_tmp_var($1); }
|
||||
| NAME EQUAL NAME
|
||||
{ driver.add_tmp_var($1, $3); }
|
||||
{ driver.add_in_symbol_list($1); }
|
||||
;
|
||||
|
||||
signed_integer : PLUS INT_NUMBER
|
||||
|
@ -1375,12 +1369,12 @@ o_gsa_threshold_redform : THRESHOLD_REDFORM EQUAL vec_int { driver.option_num("t
|
|||
|
||||
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_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_namendo : NAMENDO EQUAL '(' tmp_var_list ')' { driver.option_symbol_list("namendo"); };
|
||||
o_gsa_namlagendo : NAMLAGENDO EQUAL '(' tmp_var_list ')' { driver.option_symbol_list("namlagendo"); };
|
||||
o_gsa_namexo : NAMEXO EQUAL '(' tmp_var_list ')' { driver.option_symbol_list("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 EQUAL '(' tmp_var_list ')' { driver.option_str_lst("var_rmse"); };
|
||||
o_gsa_var_rmse : VAR_RMSE EQUAL '(' tmp_var_list ')' { driver.option_symbol_list("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); };
|
||||
|
|
2
Makefile
2
Makefile
|
@ -23,7 +23,7 @@ COMMON_OBJ = \
|
|||
Shocks.o \
|
||||
SigmaeInitialization.o \
|
||||
SymbolTable.o \
|
||||
TmpSymbolTable.o \
|
||||
SymbolList.o \
|
||||
VariableTable.o \
|
||||
ParsingDriver.o \
|
||||
DataTree.o \
|
||||
|
|
|
@ -65,7 +65,7 @@ ParsingDriver::parse(istream &in, bool debug)
|
|||
{
|
||||
mod_file = new ModFile();
|
||||
|
||||
tmp_symbol_table = new TmpSymbolTable(mod_file->symbol_table);
|
||||
symbol_list.clear();
|
||||
|
||||
reset_data_tree();
|
||||
|
||||
|
@ -77,7 +77,6 @@ ParsingDriver::parse(istream &in, bool debug)
|
|||
parser.parse();
|
||||
|
||||
delete lexer;
|
||||
delete tmp_symbol_table;
|
||||
|
||||
return mod_file;
|
||||
}
|
||||
|
@ -655,19 +654,16 @@ ParsingDriver::option_str(const string &name_option, const string &opt)
|
|||
}
|
||||
|
||||
void
|
||||
ParsingDriver::option_str_lst(const string &name_option)
|
||||
ParsingDriver::option_symbol_list(const string &name_option)
|
||||
{
|
||||
if (options_list.string_list_options.find(name_option)
|
||||
!= options_list.string_list_options.end())
|
||||
if (options_list.symbol_list_options.find(name_option)
|
||||
!= options_list.symbol_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();
|
||||
options_list.symbol_list_options[name_option] = symbol_list;
|
||||
symbol_list.clear();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void
|
||||
ParsingDriver::linear()
|
||||
{
|
||||
|
@ -675,34 +671,24 @@ ParsingDriver::linear()
|
|||
}
|
||||
|
||||
void
|
||||
ParsingDriver::add_tmp_var(string *tmp_var1, string *tmp_var2)
|
||||
{
|
||||
check_symbol_existence(*tmp_var1);
|
||||
check_symbol_existence(*tmp_var2);
|
||||
tmp_symbol_table->AddTempSymbol(*tmp_var1, *tmp_var2);
|
||||
delete tmp_var1;
|
||||
delete tmp_var2;
|
||||
}
|
||||
|
||||
void
|
||||
ParsingDriver::add_tmp_var(string *tmp_var)
|
||||
ParsingDriver::add_in_symbol_list(string *tmp_var)
|
||||
{
|
||||
check_symbol_existence(*tmp_var);
|
||||
tmp_symbol_table->AddTempSymbol(*tmp_var);
|
||||
symbol_list.addSymbol(*tmp_var);
|
||||
delete tmp_var;
|
||||
}
|
||||
|
||||
void ParsingDriver::rplot()
|
||||
{
|
||||
mod_file->addStatement(new RplotStatement(*tmp_symbol_table, options_list));
|
||||
mod_file->addStatement(new RplotStatement(symbol_list, options_list));
|
||||
options_list.clear();
|
||||
tmp_symbol_table->clear();
|
||||
symbol_list.clear();
|
||||
}
|
||||
|
||||
void ParsingDriver::stoch_simul()
|
||||
{
|
||||
mod_file->addStatement(new StochSimulStatement(*tmp_symbol_table, options_list));
|
||||
tmp_symbol_table->clear();
|
||||
mod_file->addStatement(new StochSimulStatement(symbol_list, options_list));
|
||||
symbol_list.clear();
|
||||
options_list.clear();
|
||||
}
|
||||
|
||||
|
@ -776,31 +762,31 @@ ParsingDriver::estimated_params_bounds()
|
|||
void
|
||||
ParsingDriver::set_unit_root_vars()
|
||||
{
|
||||
mod_file->addStatement(new UnitRootVarsStatement(*tmp_symbol_table));
|
||||
tmp_symbol_table->clear();
|
||||
mod_file->addStatement(new UnitRootVarsStatement(symbol_list));
|
||||
symbol_list.clear();
|
||||
}
|
||||
|
||||
void
|
||||
ParsingDriver::run_estimation()
|
||||
{
|
||||
mod_file->addStatement(new EstimationStatement(*tmp_symbol_table, options_list));
|
||||
tmp_symbol_table->clear();
|
||||
mod_file->addStatement(new EstimationStatement(symbol_list, options_list));
|
||||
symbol_list.clear();
|
||||
options_list.clear();
|
||||
}
|
||||
|
||||
void
|
||||
ParsingDriver::run_prior_analysis()
|
||||
{
|
||||
mod_file->addStatement(new PriorAnalysisStatement(*tmp_symbol_table, options_list));
|
||||
tmp_symbol_table->clear();
|
||||
mod_file->addStatement(new PriorAnalysisStatement(symbol_list, options_list));
|
||||
symbol_list.clear();
|
||||
options_list.clear();
|
||||
}
|
||||
|
||||
void
|
||||
ParsingDriver::run_posterior_analysis()
|
||||
{
|
||||
mod_file->addStatement(new PosteriorAnalysisStatement(*tmp_symbol_table, options_list));
|
||||
tmp_symbol_table->clear();
|
||||
mod_file->addStatement(new PosteriorAnalysisStatement(symbol_list, options_list));
|
||||
symbol_list.clear();
|
||||
options_list.clear();
|
||||
}
|
||||
|
||||
|
@ -842,8 +828,8 @@ ParsingDriver::optim_options_num(string *name, string *value)
|
|||
void
|
||||
ParsingDriver::set_varobs()
|
||||
{
|
||||
mod_file->addStatement(new VarobsStatement(*tmp_symbol_table));
|
||||
tmp_symbol_table->clear();
|
||||
mod_file->addStatement(new VarobsStatement(symbol_list));
|
||||
symbol_list.clear();
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -908,15 +894,15 @@ ParsingDriver::optim_weights()
|
|||
void
|
||||
ParsingDriver::set_osr_params()
|
||||
{
|
||||
mod_file->addStatement(new OsrParamsStatement(*tmp_symbol_table));
|
||||
tmp_symbol_table->clear();
|
||||
mod_file->addStatement(new OsrParamsStatement(symbol_list));
|
||||
symbol_list.clear();
|
||||
}
|
||||
|
||||
void
|
||||
ParsingDriver::run_osr()
|
||||
{
|
||||
mod_file->addStatement(new OsrStatement(*tmp_symbol_table, options_list));
|
||||
tmp_symbol_table->clear();
|
||||
mod_file->addStatement(new OsrStatement(symbol_list, options_list));
|
||||
symbol_list.clear();
|
||||
options_list.clear();
|
||||
}
|
||||
|
||||
|
@ -1002,8 +988,8 @@ ParsingDriver::run_calib(int covar)
|
|||
void
|
||||
ParsingDriver::run_dynatype(string *filename, string *ext)
|
||||
{
|
||||
mod_file->addStatement(new DynaTypeStatement(*tmp_symbol_table, *filename, *ext));
|
||||
tmp_symbol_table->clear();
|
||||
mod_file->addStatement(new DynaTypeStatement(symbol_list, *filename, *ext));
|
||||
symbol_list.clear();
|
||||
delete filename;
|
||||
delete ext;
|
||||
}
|
||||
|
@ -1011,8 +997,8 @@ ParsingDriver::run_dynatype(string *filename, string *ext)
|
|||
void
|
||||
ParsingDriver::run_dynasave(string *filename, string *ext)
|
||||
{
|
||||
mod_file->addStatement(new DynaSaveStatement(*tmp_symbol_table, *filename, *ext));
|
||||
tmp_symbol_table->clear();
|
||||
mod_file->addStatement(new DynaSaveStatement(symbol_list, *filename, *ext));
|
||||
symbol_list.clear();
|
||||
delete filename;
|
||||
delete ext;
|
||||
}
|
||||
|
@ -1056,8 +1042,8 @@ ParsingDriver::end_planner_objective(NodeID expr)
|
|||
void
|
||||
ParsingDriver::ramsey_policy()
|
||||
{
|
||||
mod_file->addStatement(new RamseyPolicyStatement(*tmp_symbol_table, options_list));
|
||||
tmp_symbol_table->clear();
|
||||
mod_file->addStatement(new RamseyPolicyStatement(symbol_list, options_list));
|
||||
symbol_list.clear();
|
||||
options_list.clear();
|
||||
}
|
||||
|
||||
|
|
13
Statement.cc
13
Statement.cc
|
@ -68,9 +68,9 @@ OptionsList::writeOutput(ostream &output) const
|
|||
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);
|
||||
for(symbol_list_options_type::const_iterator it = symbol_list_options.begin();
|
||||
it != symbol_list_options.end(); it++)
|
||||
it->second.writeOutput("options_." + it->first, output);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -91,9 +91,9 @@ OptionsList::writeOutput(ostream &output, const string &option_group) const
|
|||
it != string_options.end(); it++)
|
||||
output << option_group << "." << 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(option_group+"."+it->first,output);
|
||||
for(symbol_list_options_type::const_iterator it = symbol_list_options.begin();
|
||||
it != symbol_list_options.end(); it++)
|
||||
it->second.writeOutput(option_group + "." + it->first, output);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -102,4 +102,5 @@ OptionsList::clear()
|
|||
num_options.clear();
|
||||
paired_num_options.clear();
|
||||
string_options.clear();
|
||||
symbol_list_options.clear();
|
||||
}
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* Copyright (C) 2003-2008 Dynare Team
|
||||
*
|
||||
* This file is part of Dynare.
|
||||
*
|
||||
* Dynare is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Dynare is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "SymbolList.hh"
|
||||
#include "Interface.hh"
|
||||
|
||||
void
|
||||
SymbolList::addSymbol(const string &symbol)
|
||||
{
|
||||
symbols.push_back(symbol);
|
||||
}
|
||||
|
||||
void
|
||||
SymbolList::writeOutput(const string &varname, ostream &output) const
|
||||
{
|
||||
output << varname << "=[];" << endl;
|
||||
for (vector<string>::const_iterator it = symbols.begin();
|
||||
it != symbols.end(); it++)
|
||||
{
|
||||
output << varname << " = "
|
||||
<< interfaces::strvcat(varname, "'" + *it + "'") << ";" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
SymbolList::clear()
|
||||
{
|
||||
symbols.clear();
|
||||
}
|
|
@ -1,69 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2003-2008 Dynare Team
|
||||
*
|
||||
* This file is part of Dynare.
|
||||
*
|
||||
* Dynare is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Dynare is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
using namespace std;
|
||||
|
||||
#include "SymbolTable.hh"
|
||||
#include "TmpSymbolTable.hh"
|
||||
#include "Interface.hh"
|
||||
|
||||
TmpSymbolTable::TmpSymbolTable(const SymbolTable &symbol_table_arg) :
|
||||
symbol_table(symbol_table_arg)
|
||||
{
|
||||
}
|
||||
|
||||
TmpSymbolTable::~TmpSymbolTable()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
TmpSymbolTable::AddTempSymbol(const string &symbol)
|
||||
{
|
||||
// FIXME: add check to verify that symbol exists in symbol_table
|
||||
// FIXME: add check to verify that symbol doesn't yet exist in the present table
|
||||
tmpsymboltable.push_back(symbol);
|
||||
}
|
||||
|
||||
void
|
||||
TmpSymbolTable::AddTempSymbol(const string &symbol1, const string &symbol2)
|
||||
{
|
||||
// FIXME: add checks to verify that symbol1 and symbol2 exist in symbol_table
|
||||
// FIXME: add check to verify that symbol1 doesn't yet exist in the present table
|
||||
tmpsymboltable.push_back(symbol1);
|
||||
nameTable.push_back(symbol2);
|
||||
}
|
||||
|
||||
void
|
||||
TmpSymbolTable::writeOutput(const string &varname, ostream &output) const
|
||||
{
|
||||
output << varname << "=[];" << endl;
|
||||
for (vector<string>::const_iterator it = tmpsymboltable.begin();
|
||||
it != tmpsymboltable.end(); it++)
|
||||
{
|
||||
output << varname << " = ";
|
||||
output << interfaces::strvcat(varname, "'" + *it + "'") << ";" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
TmpSymbolTable::clear()
|
||||
{
|
||||
tmpsymboltable.clear();
|
||||
nameTable.clear();
|
||||
}
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
#include <ostream>
|
||||
|
||||
#include "TmpSymbolTable.hh"
|
||||
#include "SymbolList.hh"
|
||||
#include "SymbolTable.hh"
|
||||
#include "Statement.hh"
|
||||
#include "ModelTree.hh"
|
||||
|
@ -79,10 +79,10 @@ public:
|
|||
class StochSimulStatement : public Statement
|
||||
{
|
||||
private:
|
||||
const TmpSymbolTable tmp_symbol_table;
|
||||
const SymbolList symbol_list;
|
||||
const OptionsList options_list;
|
||||
public:
|
||||
StochSimulStatement(const TmpSymbolTable &tmp_symbol_table_arg,
|
||||
StochSimulStatement(const SymbolList &symbol_list_arg,
|
||||
const OptionsList &options_list_arg);
|
||||
virtual void checkPass(ModFileStructure &mod_file_struct);
|
||||
virtual void writeOutput(ostream &output, const string &basename) const;
|
||||
|
@ -91,10 +91,10 @@ public:
|
|||
class RamseyPolicyStatement : public Statement
|
||||
{
|
||||
private:
|
||||
const TmpSymbolTable tmp_symbol_table;
|
||||
const SymbolList symbol_list;
|
||||
const OptionsList options_list;
|
||||
public:
|
||||
RamseyPolicyStatement(const TmpSymbolTable &tmp_symbol_table_arg,
|
||||
RamseyPolicyStatement(const SymbolList &symbol_list_arg,
|
||||
const OptionsList &options_list_arg);
|
||||
virtual void checkPass(ModFileStructure &mod_file_struct);
|
||||
virtual void writeOutput(ostream &output, const string &basename) const;
|
||||
|
@ -103,10 +103,10 @@ public:
|
|||
class RplotStatement : public Statement
|
||||
{
|
||||
private:
|
||||
const TmpSymbolTable tmp_symbol_table;
|
||||
const SymbolList symbol_list;
|
||||
const OptionsList options_list;
|
||||
public:
|
||||
RplotStatement(const TmpSymbolTable &tmp_symbol_table_arg,
|
||||
RplotStatement(const SymbolList &symbol_list_arg,
|
||||
const OptionsList &options_list_arg);
|
||||
virtual void writeOutput(ostream &output, const string &basename) const;
|
||||
};
|
||||
|
@ -114,9 +114,9 @@ public:
|
|||
class UnitRootVarsStatement : public Statement
|
||||
{
|
||||
private:
|
||||
const TmpSymbolTable tmp_symbol_table;
|
||||
const SymbolList symbol_list;
|
||||
public:
|
||||
UnitRootVarsStatement(const TmpSymbolTable &tmp_symbol_table_arg);
|
||||
UnitRootVarsStatement(const SymbolList &symbol_list_arg);
|
||||
virtual void writeOutput(ostream &output, const string &basename) const;
|
||||
};
|
||||
|
||||
|
@ -160,10 +160,10 @@ public:
|
|||
class EstimationStatement : public Statement
|
||||
{
|
||||
private:
|
||||
const TmpSymbolTable tmp_symbol_table;
|
||||
const SymbolList symbol_list;
|
||||
const OptionsList options_list;
|
||||
public:
|
||||
EstimationStatement(const TmpSymbolTable &tmp_symbol_table_arg,
|
||||
EstimationStatement(const SymbolList &symbol_list_arg,
|
||||
const OptionsList &options_list_arg);
|
||||
virtual void checkPass(ModFileStructure &mod_file_struct);
|
||||
virtual void writeOutput(ostream &output, const string &basename) const;
|
||||
|
@ -172,10 +172,10 @@ public:
|
|||
class PriorAnalysisStatement : public Statement
|
||||
{
|
||||
private:
|
||||
const TmpSymbolTable tmp_symbol_table;
|
||||
const SymbolList symbol_list;
|
||||
const OptionsList options_list;
|
||||
public:
|
||||
PriorAnalysisStatement(const TmpSymbolTable &tmp_symbol_table_arg,
|
||||
PriorAnalysisStatement(const SymbolList &symbol_list_arg,
|
||||
const OptionsList &options_list_arg);
|
||||
virtual void writeOutput(ostream &output, const string &basename) const;
|
||||
};
|
||||
|
@ -183,10 +183,10 @@ public:
|
|||
class PosteriorAnalysisStatement : public Statement
|
||||
{
|
||||
private:
|
||||
const TmpSymbolTable tmp_symbol_table;
|
||||
const SymbolList symbol_list;
|
||||
const OptionsList options_list;
|
||||
public:
|
||||
PosteriorAnalysisStatement(const TmpSymbolTable &tmp_symbol_table_arg,
|
||||
PosteriorAnalysisStatement(const SymbolList &symbol_list_arg,
|
||||
const OptionsList &options_list_arg);
|
||||
virtual void writeOutput(ostream &output, const string &basename) const;
|
||||
};
|
||||
|
@ -203,9 +203,9 @@ public:
|
|||
class VarobsStatement : public Statement
|
||||
{
|
||||
private:
|
||||
const TmpSymbolTable tmp_symbol_table;
|
||||
const SymbolList symbol_list;
|
||||
public:
|
||||
VarobsStatement(const TmpSymbolTable &tmp_symbol_table_arg);
|
||||
VarobsStatement(const SymbolList &symbol_list_arg);
|
||||
virtual void writeOutput(ostream &output, const string &basename) const;
|
||||
};
|
||||
|
||||
|
@ -225,19 +225,19 @@ public:
|
|||
class OsrParamsStatement : public Statement
|
||||
{
|
||||
private:
|
||||
const TmpSymbolTable tmp_symbol_table;
|
||||
const SymbolList symbol_list;
|
||||
public:
|
||||
OsrParamsStatement(const TmpSymbolTable &tmp_symbol_table_arg);
|
||||
OsrParamsStatement(const SymbolList &symbol_list_arg);
|
||||
virtual void writeOutput(ostream &output, const string &basename) const;
|
||||
};
|
||||
|
||||
class OsrStatement : public Statement
|
||||
{
|
||||
private:
|
||||
const TmpSymbolTable tmp_symbol_table;
|
||||
const SymbolList symbol_list;
|
||||
const OptionsList options_list;
|
||||
public:
|
||||
OsrStatement(const TmpSymbolTable &tmp_symbol_table_arg,
|
||||
OsrStatement(const SymbolList &symbol_list_arg,
|
||||
const OptionsList &options_list_arg);
|
||||
virtual void checkPass(ModFileStructure &mod_file_struct);
|
||||
virtual void writeOutput(ostream &output, const string &basename) const;
|
||||
|
@ -246,11 +246,11 @@ public:
|
|||
class DynaTypeStatement : public Statement
|
||||
{
|
||||
private:
|
||||
const TmpSymbolTable tmp_symbol_table;
|
||||
const SymbolList symbol_list;
|
||||
const string filename;
|
||||
const string ext;
|
||||
public:
|
||||
DynaTypeStatement(const TmpSymbolTable &tmp_symbol_table_arg,
|
||||
DynaTypeStatement(const SymbolList &symbol_list_arg,
|
||||
const string &filename_arg, const string &ext_arg);
|
||||
virtual void writeOutput(ostream &output, const string &basename) const;
|
||||
};
|
||||
|
@ -258,11 +258,11 @@ public:
|
|||
class DynaSaveStatement : public Statement
|
||||
{
|
||||
private:
|
||||
const TmpSymbolTable tmp_symbol_table;
|
||||
const SymbolList symbol_list;
|
||||
const string filename;
|
||||
const string ext;
|
||||
public:
|
||||
DynaSaveStatement(const TmpSymbolTable &tmp_symbol_table_arg,
|
||||
DynaSaveStatement(const SymbolList &symbol_list_arg,
|
||||
const string &filename_arg, const string &ext_arg);
|
||||
virtual void writeOutput(ostream &output, const string &basename) const;
|
||||
};
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
#include <istream>
|
||||
|
||||
#include "ModFile.hh"
|
||||
#include "TmpSymbolTable.hh"
|
||||
#include "SymbolList.hh"
|
||||
#include "DynareBison.hh"
|
||||
#include "ComputingTasks.hh"
|
||||
#include "Shocks.hh"
|
||||
|
@ -76,7 +76,7 @@ private:
|
|||
void optim_options_helper(const string &name);
|
||||
|
||||
//! Stores temporary symbol table
|
||||
TmpSymbolTable *tmp_symbol_table;
|
||||
SymbolList symbol_list;
|
||||
|
||||
//! The data tree in which to add expressions currently parsed
|
||||
DataTree *data_tree;
|
||||
|
@ -264,14 +264,12 @@ 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);
|
||||
//! Sets an option to a list of symbols (used in conjunction with add_in_symbol_list())
|
||||
void option_symbol_list(const string &name_option);
|
||||
//! Indicates that the model is linear
|
||||
void linear();
|
||||
//! Adds a variable to temp symbol table and sets its value
|
||||
void add_tmp_var(string *tmp_var1, string *tmp_var2);
|
||||
//! Adds a variable to temp symbol table
|
||||
void add_tmp_var(string *tmp_var);
|
||||
//! Adds a variable to temporary symbol list
|
||||
void add_in_symbol_list(string *tmp_var);
|
||||
//! Writes a rplot() command
|
||||
void rplot();
|
||||
//! Writes a stock_simul command
|
||||
|
|
|
@ -26,7 +26,8 @@ using namespace std;
|
|||
#include <string>
|
||||
#include <map>
|
||||
|
||||
#include "TmpSymbolTable.hh"
|
||||
#include "SymbolList.hh"
|
||||
|
||||
class ModFileStructure
|
||||
{
|
||||
public:
|
||||
|
@ -72,11 +73,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;
|
||||
typedef map<string, SymbolList> symbol_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;
|
||||
symbol_list_options_type symbol_list_options;
|
||||
void writeOutput(ostream &output) const;
|
||||
void writeOutput(ostream &output, const string &option_group) const;
|
||||
void clear();
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
/*
|
||||
* Copyright (C) 2003-2008 Dynare Team
|
||||
*
|
||||
* This file is part of Dynare.
|
||||
*
|
||||
* Dynare is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Dynare is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef _SYMBOL_LIST_HH
|
||||
#define _SYMBOL_LIST_HH
|
||||
|
||||
using namespace std;
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <ostream>
|
||||
|
||||
//! Used to store a list of symbols
|
||||
/*! This class is no more than a vector<string>, with a pretty-printer for Matlab */
|
||||
class SymbolList
|
||||
{
|
||||
private:
|
||||
//! Internal container for symbol list
|
||||
vector<string> symbols;
|
||||
public:
|
||||
//! Adds a symbol to the list
|
||||
void addSymbol(const string &symbol);
|
||||
//! Output content in Matlab format
|
||||
/*! Creates a string array for Matlab, stored in variable "varname" */
|
||||
void writeOutput(const string &varname, ostream &output) const;
|
||||
//! Clears all content
|
||||
void clear();
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,57 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2003-2008 Dynare Team
|
||||
*
|
||||
* This file is part of Dynare.
|
||||
*
|
||||
* Dynare is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Dynare is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef _TMPSYMBOLTABLE_HH
|
||||
#define _TMPSYMBOLTABLE_HH
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <ostream>
|
||||
|
||||
#include "SymbolTable.hh"
|
||||
|
||||
/*!
|
||||
\class TmpSymbolTable
|
||||
\brief Defines temparary symbol table used with computing tasks
|
||||
*/
|
||||
class TmpSymbolTable
|
||||
{
|
||||
private :
|
||||
/*! list of string TempSymbolTable */
|
||||
std::vector<std::string> tmpsymboltable;
|
||||
/*! List of symbol Values */
|
||||
std::vector<std::string> nameTable;
|
||||
//! A reference to enclosing symbol table
|
||||
const SymbolTable &symbol_table;
|
||||
public :
|
||||
/*! Constrcutor */
|
||||
TmpSymbolTable(const SymbolTable &symbol_table_arg);
|
||||
/*! Destructor*/
|
||||
~TmpSymbolTable();
|
||||
/*! Adds a temp symbol */
|
||||
void AddTempSymbol(const std::string &symbol);
|
||||
/*! Adds a temp symbol and its value */
|
||||
void AddTempSymbol(const std::string &symbol1, const std::string &symbol2);
|
||||
/*! Write TempSymbolTable to output string */
|
||||
void writeOutput(const std::string &varname, std::ostream &output) const;
|
||||
//! Clears all content
|
||||
void clear();
|
||||
};
|
||||
//------------------------------------------------------------------------------
|
||||
#endif
|
Loading…
Reference in New Issue