2008-04-07 15:14:40 +02:00
|
|
|
/*
|
2023-12-01 14:02:38 +01:00
|
|
|
* Copyright © 2003-2023 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
|
|
|
*/
|
|
|
|
|
2023-12-01 15:39:01 +01:00
|
|
|
#ifndef SYMBOL_LIST_HH
|
|
|
|
#define SYMBOL_LIST_HH
|
2008-04-07 15:14:40 +02:00
|
|
|
|
2023-11-30 15:28:57 +01:00
|
|
|
#include <algorithm>
|
|
|
|
#include <ostream>
|
2008-04-07 15:14:40 +02:00
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
2019-12-19 14:48:55 +01:00
|
|
|
#include "SymbolTable.hh"
|
2023-11-30 15:28:57 +01:00
|
|
|
#include "WarningConsolidation.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:
|
|
|
|
vector<string> symbols;
|
2023-11-30 15:28:57 +01:00
|
|
|
|
2008-04-07 15:14:40 +02:00
|
|
|
public:
|
2022-03-28 18:11:53 +02:00
|
|
|
SymbolList() = default;
|
|
|
|
// This constructor is deliberately not marked explicit, to allow implicit conversion
|
|
|
|
SymbolList(vector<string> symbols_arg);
|
|
|
|
|
2022-07-20 13:22:21 +02:00
|
|
|
struct SymbolListException
|
2019-12-19 14:48:55 +01:00
|
|
|
{
|
|
|
|
const string message;
|
|
|
|
};
|
2022-03-28 18:11:53 +02:00
|
|
|
//! Remove duplicate symbols
|
2023-11-30 15:28:57 +01:00
|
|
|
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
|
2023-11-30 15:28:57 +01:00
|
|
|
void checkPass(WarningConsolidation& warnings, const vector<SymbolType>& types,
|
|
|
|
const SymbolTable& symbol_table) 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" */
|
2023-11-30 15:28:57 +01:00
|
|
|
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
|
2023-11-30 15:28:57 +01:00
|
|
|
void write(ostream& output) const;
|
2017-02-08 18:29:57 +01:00
|
|
|
//! Write JSON output
|
2023-11-30 15:28:57 +01:00
|
|
|
void writeJsonOutput(ostream& output) const;
|
2013-08-06 21:20:36 +02:00
|
|
|
//! Is Empty
|
2023-12-01 14:02:38 +01:00
|
|
|
[[nodiscard]] bool
|
2017-06-01 19:58:32 +02:00
|
|
|
empty() const
|
|
|
|
{
|
|
|
|
return symbols.empty();
|
|
|
|
};
|
2017-05-18 17:50:58 +02:00
|
|
|
//! Return the list of symbols
|
2023-12-01 14:02:38 +01:00
|
|
|
[[nodiscard]] vector<string> getSymbols() const;
|
2008-04-07 15:14:40 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|