Select Git revision
ConfigFile.hh
SymbolTable.cc 22.67 KiB
/*
* Copyright (C) 2003-2015 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 <algorithm>
#include <sstream>
#include <iostream>
#include <cassert>
#include <list>
#include "SymbolTable.hh"
AuxVarInfo::AuxVarInfo(int symb_id_arg, aux_var_t type_arg, int orig_symb_id_arg, int orig_lead_lag_arg,
int equation_number_for_multiplier_arg) :
symb_id(symb_id_arg),
type(type_arg),
orig_symb_id(orig_symb_id_arg),
orig_lead_lag(orig_lead_lag_arg),
equation_number_for_multiplier(equation_number_for_multiplier_arg)
{
}
SymbolTable::SymbolTable() : frozen(false), size(0)
{
}
int
SymbolTable::addSymbol(const string &name, SymbolType type, const string &tex_name, const string &long_name) throw (AlreadyDeclaredException, FrozenException)
{
if (frozen)
throw FrozenException();
if (exists(name))
{
if (type_table[getID(name)] == type)
throw AlreadyDeclaredException(name, true);
else
throw AlreadyDeclaredException(name, false);
}
string final_tex_name = tex_name;
if (final_tex_name.empty())
{
final_tex_name = name;
size_t pos = 0;
while ((pos = final_tex_name.find('_', pos)) != string::npos)
{
final_tex_name.insert(pos, "\\");
pos += 2;
}
}
string final_long_name = long_name;
if (final_long_name.empty())
final_long_name = name;