preprocessor: provide more info in error message
parent
781039752a
commit
6905456cb3
File diff suppressed because it is too large
Load Diff
|
@ -76,18 +76,27 @@ InitParamStatement::fillEvalContext(eval_context_t &eval_context) const
|
||||||
Statement *
|
Statement *
|
||||||
InitParamStatement::cloneAndReindexSymbIds(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table)
|
InitParamStatement::cloneAndReindexSymbIds(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table)
|
||||||
{
|
{
|
||||||
|
string error;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return new InitParamStatement(symbol_table.getID(orig_symbol_table.getName(symb_id)),
|
return new InitParamStatement(symbol_table.getID(orig_symbol_table.getName(symb_id)),
|
||||||
param_value->cloneDynamicReindex(dynamic_datatree, orig_symbol_table),
|
param_value->cloneDynamicReindex(dynamic_datatree, orig_symbol_table),
|
||||||
symbol_table);
|
symbol_table);
|
||||||
}
|
}
|
||||||
catch (...)
|
catch (SymbolTable::UnknownSymbolIDException &e)
|
||||||
{
|
{
|
||||||
cerr << "ERROR: A variable in the init_param statement was not found in the symbol table" << endl
|
error = orig_symbol_table.getName(e.id);
|
||||||
<< " This likely means that you have declared a varexo that is not used in the model" << endl;
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
}
|
||||||
|
catch (SymbolTable::UnknownSymbolNameException &e)
|
||||||
|
{
|
||||||
|
error = e.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
cerr << endl
|
||||||
|
<< "ERROR: The following vars were used in the init param statement(s) but were not declared." << endl
|
||||||
|
<< " This likely means that you declared them as varexo and that they're not in the model" << endl
|
||||||
|
<< error << endl;
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
InitOrEndValStatement::InitOrEndValStatement(const init_values_t &init_values_arg,
|
InitOrEndValStatement::InitOrEndValStatement(const init_values_t &init_values_arg,
|
||||||
|
@ -228,18 +237,27 @@ InitValStatement::writeOutputPostInit(ostream &output) const
|
||||||
Statement *
|
Statement *
|
||||||
InitValStatement::cloneAndReindexSymbIds(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table)
|
InitValStatement::cloneAndReindexSymbIds(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table)
|
||||||
{
|
{
|
||||||
|
vector<string> errors;
|
||||||
init_values_t new_init_values;
|
init_values_t new_init_values;
|
||||||
try
|
|
||||||
{
|
|
||||||
for (init_values_t::const_iterator it=init_values.begin();
|
for (init_values_t::const_iterator it=init_values.begin();
|
||||||
it != init_values.end(); it++)
|
it != init_values.end(); it++)
|
||||||
|
try
|
||||||
|
{
|
||||||
new_init_values.push_back(make_pair(symbol_table.getID(orig_symbol_table.getName(it->first)),
|
new_init_values.push_back(make_pair(symbol_table.getID(orig_symbol_table.getName(it->first)),
|
||||||
it->second->cloneDynamicReindex(dynamic_datatree, orig_symbol_table)));
|
it->second->cloneDynamicReindex(dynamic_datatree, orig_symbol_table)));
|
||||||
}
|
}
|
||||||
catch (...)
|
catch (SymbolTable::UnknownSymbolNameException &e)
|
||||||
{
|
{
|
||||||
cerr << "ERROR: A variable in the initval statement was not found in the symbol table" << endl
|
errors.push_back(e.name);
|
||||||
<< " This likely means that you have declared a varexo that is not used in the model" << endl;
|
}
|
||||||
|
|
||||||
|
if (!errors.empty())
|
||||||
|
{
|
||||||
|
cerr << endl
|
||||||
|
<< "ERROR: The following vars were used in the initval statement(s) but were not declared." << endl
|
||||||
|
<< " This likely means that you declared them as varexo and that they're not in the model" << endl;
|
||||||
|
for (vector<string>::const_iterator it = errors.begin(); it != errors.end(); it++)
|
||||||
|
cerr << *it << endl;
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
return new InitValStatement(new_init_values, symbol_table, all_values_required);
|
return new InitValStatement(new_init_values, symbol_table, all_values_required);
|
||||||
|
@ -294,18 +312,28 @@ EndValStatement::writeOutput(ostream &output, const string &basename) const
|
||||||
Statement *
|
Statement *
|
||||||
EndValStatement::cloneAndReindexSymbIds(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table)
|
EndValStatement::cloneAndReindexSymbIds(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table)
|
||||||
{
|
{
|
||||||
|
vector<string> errors;
|
||||||
init_values_t new_init_values;
|
init_values_t new_init_values;
|
||||||
try
|
|
||||||
{
|
|
||||||
for (init_values_t::const_iterator it=init_values.begin();
|
for (init_values_t::const_iterator it=init_values.begin();
|
||||||
it != init_values.end(); it++)
|
it != init_values.end(); it++)
|
||||||
|
try
|
||||||
|
{
|
||||||
new_init_values.push_back(make_pair(symbol_table.getID(orig_symbol_table.getName(it->first)),
|
new_init_values.push_back(make_pair(symbol_table.getID(orig_symbol_table.getName(it->first)),
|
||||||
it->second->cloneDynamicReindex(dynamic_datatree, orig_symbol_table)));
|
it->second->cloneDynamicReindex(dynamic_datatree, orig_symbol_table)));
|
||||||
}
|
}
|
||||||
catch (...)
|
catch (SymbolTable::UnknownSymbolNameException &e)
|
||||||
{
|
{
|
||||||
cerr << "ERROR: A variable in the endval statement was not found in the symbol table" << endl
|
errors.push_back(e.name);
|
||||||
<< " This likely means that you have declared a varexo that is not used in the model" << endl;
|
}
|
||||||
|
|
||||||
|
if (!errors.empty())
|
||||||
|
{
|
||||||
|
cerr << endl
|
||||||
|
<< "ERROR: The following vars were used in the endval statement(s) but were not declared." << endl
|
||||||
|
<< " This likely means that you declared them as varexo and that they're not in the model" << endl;
|
||||||
|
for (vector<string>::const_iterator it = errors.begin(); it != errors.end(); it++)
|
||||||
|
cerr << *it << endl;
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
return new EndValStatement(new_init_values, symbol_table, all_values_required);
|
return new EndValStatement(new_init_values, symbol_table, all_values_required);
|
||||||
|
@ -380,19 +408,28 @@ HistValStatement::writeOutput(ostream &output, const string &basename) const
|
||||||
Statement *
|
Statement *
|
||||||
HistValStatement::cloneAndReindexSymbIds(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table)
|
HistValStatement::cloneAndReindexSymbIds(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table)
|
||||||
{
|
{
|
||||||
|
vector<string> errors;
|
||||||
hist_values_t new_hist_values;
|
hist_values_t new_hist_values;
|
||||||
try
|
|
||||||
{
|
|
||||||
for (hist_values_t::const_iterator it=hist_values.begin();
|
for (hist_values_t::const_iterator it=hist_values.begin();
|
||||||
it != hist_values.end(); it++)
|
it != hist_values.end(); it++)
|
||||||
|
try
|
||||||
|
{
|
||||||
new_hist_values[make_pair(symbol_table.getID(orig_symbol_table.getName(it->first.first)),
|
new_hist_values[make_pair(symbol_table.getID(orig_symbol_table.getName(it->first.first)),
|
||||||
it->first.second)] =
|
it->first.second)] =
|
||||||
it->second->cloneDynamicReindex(dynamic_datatree, orig_symbol_table);
|
it->second->cloneDynamicReindex(dynamic_datatree, orig_symbol_table);
|
||||||
}
|
}
|
||||||
catch (...)
|
catch (SymbolTable::UnknownSymbolNameException &e)
|
||||||
{
|
{
|
||||||
cerr << "ERROR: A variable in the hist_val statement was not found in the symbol table" << endl
|
errors.push_back(e.name);
|
||||||
<< " This likely means that you have declared a varexo that is not used in the model" << endl;
|
}
|
||||||
|
|
||||||
|
if (!errors.empty())
|
||||||
|
{
|
||||||
|
cerr << endl
|
||||||
|
<< "ERROR: The following vars were used in the histval statement(s) but were not declared." << endl
|
||||||
|
<< " This likely means that you declared them as varexo and that they're not in the model" << endl;
|
||||||
|
for (vector<string>::const_iterator it = errors.begin(); it != errors.end(); it++)
|
||||||
|
cerr << *it << endl;
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
return new HistValStatement(new_hist_values, symbol_table);
|
return new HistValStatement(new_hist_values, symbol_table);
|
||||||
|
|
Loading…
Reference in New Issue