2008-04-07 15:14:40 +02:00
|
|
|
/*
|
2019-09-09 16:16:36 +02:00
|
|
|
* Copyright © 2003-2019 Dynare Team
|
2008-04-07 15:14:40 +02:00
|
|
|
*
|
|
|
|
* 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
|
2021-06-09 16:52:20 +02:00
|
|
|
* along with Dynare. If not, see <https://www.gnu.org/licenses/>.
|
2008-04-07 15:14:40 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _SYMBOL_LIST_HH
|
|
|
|
#define _SYMBOL_LIST_HH
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
#include <ostream>
|
2019-12-18 11:53:20 +01:00
|
|
|
#include <algorithm>
|
2008-04-07 15:14:40 +02:00
|
|
|
|
2019-09-09 16:16:36 +02:00
|
|
|
#include "WarningConsolidation.hh"
|
2019-12-19 14:48:55 +01:00
|
|
|
#include "SymbolTable.hh"
|
2019-09-09 16:16:36 +02:00
|
|
|
|
2013-11-21 14:47:44 +01:00
|
|
|
using namespace std;
|
|
|
|
|
2008-04-07 15:14:40 +02:00
|
|
|
//! 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;
|
2019-12-19 14:48:55 +01:00
|
|
|
const SymbolTable *symbol_table;
|
2008-04-07 15:14:40 +02:00
|
|
|
public:
|
2019-12-19 14:48:55 +01:00
|
|
|
class SymbolListException
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
const string message;
|
2019-12-20 16:59:30 +01:00
|
|
|
SymbolListException(string message_arg) : message{move(message_arg)}
|
|
|
|
{
|
|
|
|
};
|
2019-12-19 14:48:55 +01:00
|
|
|
};
|
|
|
|
//! Set symbol table pointer
|
|
|
|
void setSymbolTable(const SymbolTable &symbol_table_arg);
|
2008-04-07 15:14:40 +02:00
|
|
|
//! Adds a symbol to the list
|
|
|
|
void addSymbol(const string &symbol);
|
2019-09-09 16:16:36 +02:00
|
|
|
//! Removed duplicate symbols
|
|
|
|
void removeDuplicates(const string &dynare_command, WarningConsolidation &warnings);
|
2019-12-19 14:48:55 +01:00
|
|
|
//! Check symbols to ensure variables have been declared and are endogenous
|
2019-12-23 16:22:23 +01:00
|
|
|
void checkPass(WarningConsolidation &warnings, const vector<SymbolType> &types) const noexcept(false);
|
2008-04-07 15:14:40 +02:00
|
|
|
//! Output content in Matlab format
|
|
|
|
/*! Creates a string array for Matlab, stored in variable "varname" */
|
|
|
|
void writeOutput(const string &varname, ostream &output) const;
|
2017-05-04 18:06:50 +02:00
|
|
|
//! Output content in Matlab format without preceding varname of writeOutput
|
|
|
|
void write(ostream &output) const;
|
2017-02-08 18:29:57 +01:00
|
|
|
//! Write JSON output
|
|
|
|
void writeJsonOutput(ostream &output) const;
|
2008-04-07 15:14:40 +02:00
|
|
|
//! Clears all content
|
|
|
|
void clear();
|
2011-01-26 19:55:01 +01:00
|
|
|
//! Get a copy of the string vector
|
2017-06-01 19:58:32 +02:00
|
|
|
vector<string>
|
|
|
|
get_symbols() const
|
|
|
|
{
|
|
|
|
return symbols;
|
|
|
|
};
|
2013-08-06 21:20:36 +02:00
|
|
|
//! Is Empty
|
2017-06-01 19:58:32 +02:00
|
|
|
int
|
|
|
|
empty() const
|
|
|
|
{
|
|
|
|
return symbols.empty();
|
|
|
|
};
|
2017-05-16 10:09:48 +02:00
|
|
|
//! Return the number of Symbols contained in the list
|
|
|
|
int getSize() const;
|
2017-05-18 17:50:58 +02:00
|
|
|
//! Return the list of symbols
|
|
|
|
vector<string> getSymbols() const;
|
2008-04-07 15:14:40 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|