diff --git a/parser.src/DynareBison.yy b/parser.src/DynareBison.yy
index 771af56c630e93cb1d9c21c5085eb09316838c27..f17d3180b298ee6de4a8d3cc0d8a0d95aa04e91f 100644
--- a/parser.src/DynareBison.yy
+++ b/parser.src/DynareBison.yy
@@ -294,13 +294,11 @@
;
model
- : MODEL {_parser->initialize_model();} ';' equation_list END
+ : MODEL ';' equation_list END
{_parser->check_model();}
- | MODEL '(' LINEAR ')' ';' {_parser->option_num("linear","1");
- _parser->initialize_model();}
+ | MODEL '(' LINEAR ')' ';' {_parser->option_num("linear","1");}
equation_list END {_parser->check_model();}
- | MODEL '(' USE_DLL ')' ';' {_parser->use_dll();
- _parser->initialize_model();}
+ | MODEL '(' USE_DLL ')' ';' {_parser->use_dll();}
equation_list END {_parser->check_model();}
;
diff --git a/parser.src/DynareParser.cc b/parser.src/DynareParser.cc
index 830308b044c6cd123a7b4913c67054afa37584b3..2e96ab7016f3363f5d6bac5ba603ee7aed7a63ba 100644
--- a/parser.src/DynareParser.cc
+++ b/parser.src/DynareParser.cc
@@ -209,13 +209,6 @@ void dynare::parser::init_param(Objects* lhs, Objects* rhs)
{
numerical_initialization.SetConstant(lhs->symbol, rhs->symbol);
}
-void dynare::parser::init_param(Objects* lhs)
-{
- //cout << "Befor set\n";
- expression.set();
- numerical_initialization.SetConstant(lhs->symbol, expression.get());
- expression.clear();
-}
void dynare::parser::init_val(Objects* lhs, Objects* rhs)
{
numerical_initialization.SetInit(lhs->symbol, rhs->symbol);
@@ -225,16 +218,6 @@ void dynare::parser::hist_val(Objects* lhs, Objects* slag, Objects* rhs)
int lag = atoi((slag->symbol).c_str());
numerical_initialization.SetHist(lhs->symbol, lag, rhs->symbol);
}
-void dynare::parser::hist_val(Objects* lhs, Objects* slag)
-{
- int lag = atoi((slag->symbol).c_str());
- expression.set();
- numerical_initialization.SetHist(lhs->symbol, lag, expression.get());
- expression.clear();
-}
-void dynare::parser::initialize_model(void)
-{
-}
void dynare::parser::use_dll(void)
{
// Seetting variable momber offset to use C outputs
diff --git a/parser.src/ModelTree.cc b/parser.src/ModelTree.cc
index c30e1b088556b2ffadc7d06cda426e985c6e5a36..8bffade363cc180bc15c5e488ca0b9e796533f45 100644
--- a/parser.src/ModelTree.cc
+++ b/parser.src/ModelTree.cc
@@ -658,7 +658,6 @@ inline NodeID ModelTree::DeriveArgument(NodeID iArg, Type iType, int iVarID)
case eUNDEF :
return NullID;
case eLoopIndex :
- case eUnkownFunction :
return Zero;
default :
cout << "ModelTree::DeriveArgument : Error: Unknown Type\n";
@@ -1141,130 +1140,6 @@ inline string ModelTree::getExpression(NodeID StartID, EquationType iEquationTy
return exp.str();
}
//------------------------------------------------------------------------------
-/*
-void ModelTree::RemoveUnref(int iBeginID, int iEndID, int iOrder)
-{
- int id = iEndID;
- while (id >= iBeginID)
- {
- //cout << id;
- if (accumulate(mModelTree[id].reference_count.begin(),mModelTree[id].reference_count.end(),0) == 0)
- {
- //cout << " Removed" << endl;
- //Decreasing reference count of arguments model tree
- // First argument is a temporary result,
- if (mModelTree[id].type1 == eTempResult)
- {
- //Decreasing reference count of argument 1 in model tree
- int arg = mModelTree[id].id1;
- mModelTree[arg].reference_count[iOrder]--;
- }
- // Second argument has id >=0 (temporary result),
- if (mModelTree[id].id2 >= 0)
- {
- //Decreasing reference count of argument 2 in model tree
- int arg = mModelTree[id].id2;
- mModelTree[arg].reference_count[iOrder]--;
- }
- //Updating equals ids in mDerivativeIndex
- for (int d=0; d<mDerivativeIndex[iOrder-1].size();d++)
- {
- if (mDerivativeIndex[iOrder-1][d].token_id>id)
- mDerivativeIndex[iOrder-1][d].token_id--;
- }
- //cout << "ModelTree size : " << mModelTree.size() << endl;
- //Updatting upper token ids in model tree and map
- mIndexOfTokens.erase(Key((MToken) mModelTree[id]));
- for (int id2 = id+1; id2 <= iEndID; id2++)
- {
- //cout << " - " << mIndexOfTokens[Key((MToken) mModelTree[id2])];
- mIndexOfTokens.erase(Key((MToken) mModelTree[id2]));
- }
- //cout << endl;
- for (int id2 = id+1; id2 <= iEndID; id2++)
- {
- // Updating derivative ids
- map<int, int, less<int> >::iterator it;
- for (it = mModelTree[id2].p1.begin(); it != mModelTree[id2].p1.end(); it++)
- {
- int p1 = (*it).second;
- int var = (*it).first;
- //cout << "===========" << mModelTree[p1].d1[var] << "/";
- mModelTree[p1].d1[var] = id2-1;
- //cout << mModelTree[p1].d1[var] << endl;
- }
- // Updating ModelTree map
- if (mModelTree[id2].type1 == eTempResult)
- {
- if (mModelTree[id2].id1>id)
- {
- mModelTree[id2].id1--;
- }
- }
- if (mModelTree[id2].id2>id)
- {
- mModelTree[id2].id2--;
- }
- }
- mModelTree.erase(mModelTree.begin()+id);
- for (int id2 = id; id2 < iEndID; id2++)
- {
- mIndexOfTokens[Key((MToken) mModelTree[id2])] = id2;
- //cout << " - " << mIndexOfTokens[Key((MToken) mModelTree[id2])];
- }
- //Removing token from model tree
- //cout << "ModelTree size : " << mModelTree.size() << endl;
-
-
- iEndID--;
- id--;
- }
- else
- {
- id--;
- //cout << endl;
- }
- }
-
-}
-//------------------------------------------------------------------------------
-*/
-/*
-void ModelTree::DecrementUnref(int iBeginID, int iEndID, int iOrder)
-{
- int id = iEndID;
- while (id >= iBeginID)
- {
- //cout << id;
- if (accumulate(mModelTree[id].reference_count.begin(),mModelTree[id].reference_count.end(),0) == 0)
- {
- //Decreasing reference count of arguments model tree
- // First argument is a temporary result,
- if (mModelTree[id].type1 == eTempResult)
- {
- //Decreasing reference count of argument 1 in model tree
- int arg = mModelTree[id].id1;
- mModelTree[arg].reference_count[iOrder]--;
- }
- // Second argument has id >=0 (temporary result),
- if (mModelTree[id].id2 >= 0)
- {
- //Decreasing reference count of argument 2 in model tree
- int arg = mModelTree[id].id2;
- mModelTree[arg].reference_count[iOrder]--;
- }
- id--;
- }
- else
- {
- id--;
- //cout << endl;
- }
- }
-
-}
-*/
-//------------------------------------------------------------------------------
inline string ModelTree::getArgument(NodeID id, Type type, EquationType iEquationType)
{
diff --git a/parser.src/NumericalInitialization.cc b/parser.src/NumericalInitialization.cc
index aa4548c8f62eb6986c19cdd51a1ef48c4b407dae..921c9ade8ea6f50fd03e6b4288e4cf602e6e2b1b 100644
--- a/parser.src/NumericalInitialization.cc
+++ b/parser.src/NumericalInitialization.cc
@@ -48,28 +48,6 @@ void NumericalInitialization::SetConstant (string name, string expression)
}
//------------------------------------------------------------------------------
-void NumericalInitialization::SetLocalConstant (string name, string expression)
-{
-
- //Testing if symbol exists
- if (SymbolTable::Exist(name))
- {
- if (SymbolTable::getType(name) != eLocalParameter)
- {
- string msg = "Using existing symbol " + name +
- " as local parameter name";
- (* error) (msg.c_str());
- }
- }
- else
- {
- SymbolTable::AddSymbolDeclar(name,eLocalParameter,name);
- }
-
- // Writing expression
- *output << name << " = " << expression << ";\n";
-}
-//------------------------------------------------------------------------------
void NumericalInitialization::BeginInitval (void)
{
diff --git a/parser.src/SymbolTable.cc b/parser.src/SymbolTable.cc
index eec7fc2602e27b2d4bc1a1de991a6ab93103fd66..df33f2b3957dd251a024a8e374c0c9d88e61667b 100644
--- a/parser.src/SymbolTable.cc
+++ b/parser.src/SymbolTable.cc
@@ -116,11 +116,6 @@ void SymbolTable::SetReferenced(string name)
symboltable[name].referenced = eReferenced;
}
//------------------------------------------------------------------------------
-void SymbolTable::SetOutOfScoop(string name)
-{
- symboltable[name].referenced = eOutOfScoop;
-}
-//------------------------------------------------------------------------------
Reference SymbolTable::isReferenced(std::string name)
{
return symboltable[name].referenced;
@@ -283,34 +278,3 @@ void SymbolTable::erase_local_parameters(void)
}
}
//------------------------------------------------------------------------------
-/*
-ostream & operator << (ostream & output, Symbol s)
-{
- switch (s.type) {
- case eExogenous : output << "Exogenous , "; break;
- case eExogenousDet : output << "ExogenousDet ,"; break;
- case eEndogenous : output << "Endogenous , "; break;
- case eRecursiveVariable : output << "RecursiveVariable , "; break;
- case eParameter : output << "Parameter , "; break;
- case eLoopIndex : output << "LoopIndex , "; break;
- }
- output << s.id;
- switch (s.referenced) {
- case eReferenced : cout << ", Referenced, "; break;
- case eNotReferenced : cout << ", NotReferenced, "; break;
- case eOutOfScoop : cout << ", OutOfScoop, "; break;
-
- }
- return output;
-}
-//------------------------------------------------------------------------------
-void SymbolTable::PrintSymbolTable(void)
-{
- map<string, Symbol, less<string> >::iterator iter;
- cout << "\nCurrent Map :\n";
- for (iter = symboltable.begin();iter != symboltable.end(); iter++)
- cout << (*iter).first << " , " << (*iter).second << endl;;
-}
-//------------------------------------------------------------------------------
-*/
-
diff --git a/parser.src/include/DynareParser.h b/parser.src/include/DynareParser.h
index 684ea7d26c158a705f618e9cf42463043584c7e0..baa007033d91dd3c7f6cd94c9f183692e992caf8 100644
--- a/parser.src/include/DynareParser.h
+++ b/parser.src/include/DynareParser.h
@@ -120,8 +120,6 @@ namespace dynare
void check_model(void);
/*! Executes final instructions */
void finish(void);
- /*! Initializes the model */
- void initialize_model(void);
/*! Sets variable offset of ModelTree class to use C output */
void use_dll(void);
/*! Adds an endogenous variable to SymbolTable*/
@@ -152,19 +150,16 @@ namespace dynare
Objects* add_expression_token( Objects* arg1, Objects* op);
/*! Gets literal expression string */
Objects* get_expression(Objects* exp);
- /* Concatenates two string objects */
+ /*! Concatenates two string objects */
Objects* cat(Objects* string1, Objects* string2);
+ /*! Concatenates two string objects with a space between */
Objects* cat_with_space(Objects* string1, Objects* string2);
/*! Writes parameter intitialisation expression */
void init_param(Objects* lhs, Objects* rhs);
- /*! Writes parameter intitialisation expression */
- void init_param(Objects* lhs);
/*! Writes an initval block */
void init_val(Objects* lhs, Objects* rhs);
/*! Writes an histval block */
void hist_val(Objects* lhs, Objects* lag, Objects* rhs);
- /*! Writes an histval block */
- void hist_val(Objects* lhs, Objects* lag);
/*! Writes begining of an initval block */
void begin_initval(void);
/*! Writes end of an initval block */
diff --git a/parser.src/include/ModelTree.h b/parser.src/include/ModelTree.h
index f530080b7a5d936eedb8e4e8cf4b86eae0382008..278f60eb3fa96870453f234a9ee225048ae7f9d0 100644
--- a/parser.src/include/ModelTree.h
+++ b/parser.src/include/ModelTree.h
@@ -13,7 +13,6 @@
#include <stack>
#include <sstream>
#include <fstream>
-//#include <ext/hash_map>
//------------------------------------------------------------------------------
#include "SymbolTable.h"
#include "OperatorTable.h"
@@ -31,10 +30,6 @@ class ModelTree : public DataTree
/*! Stores ID of equations and their derivatives */
std::vector<std::vector<DerivativeIndex> > mDerivativeIndex;
- /*! Stores ID of equations and their 1st ordre derivatives */
- //vector<DerivativeIndex> mDerivative1Index;
- /*! Stores ID of equations and their 2nd ordre derivatives */
- //vector<DerivativeIndex> mDerivative2Index;
/*! Only used for C++ standalone version */
std::vector<double> mResults;
/*! Output for static model */
@@ -71,10 +66,6 @@ class ModelTree : public DataTree
depending on its time cost and number of times it is referenced in model tree
*/
inline bool writeAsTemp(NodeID id);
- /*! Remove unreferenced tokens after a derivation */
- //void RemoveUnref(int iBeginID, int iEndID, int iOrder);
- /*! Decrementing reference couter of unreferenced tokens in last derivative */
- void DecrementUnref(int iBeginID, int iEndID, int iOrder);
inline int optimize(NodeID id);
public :
/*! When Jacobian (vs endogenous) is writen this flag is set to true */
diff --git a/parser.src/include/ModelTypes.h b/parser.src/include/ModelTypes.h
index 0aa6315ee024ef1a683dab9f2887924ec13e6490..4b6c8cb6423a03f04fee07d153fc5ad00e443798 100644
--- a/parser.src/include/ModelTypes.h
+++ b/parser.src/include/ModelTypes.h
@@ -212,7 +212,6 @@ struct MetaToken : public MToken
};
//------------------------------------------------------------------------------
/*!
- \function oparator <
\brief Less operator define comparaison function for map class
*/
diff --git a/parser.src/include/NumericalInitialization.h b/parser.src/include/NumericalInitialization.h
index b4b1658d47e060a2ca2476af078f0ccf15963011..46091485dd9f1bca2454876e4429d8216e102564 100644
--- a/parser.src/include/NumericalInitialization.h
+++ b/parser.src/include/NumericalInitialization.h
@@ -39,7 +39,6 @@ class NumericalInitialization
- in C++, evaluate expression and set value for Name in Parameters_Table\n
*/
void SetConstant(std::string name,std::string expression);
- void SetLocalConstant(std::string name,std::string expression);
/*!
\par Description
Initializes an initval block to set initial values for variables
diff --git a/parser.src/include/SymbolTable.h b/parser.src/include/SymbolTable.h
index 11aaa20922b0d6bbff2b63721d7d9773ef80fedd..a7ba4d3a3cba3410fa6e769287a51759ed2fafd7 100644
--- a/parser.src/include/SymbolTable.h
+++ b/parser.src/include/SymbolTable.h
@@ -34,8 +34,6 @@ class SymbolTable
- set Name and Type\n
- increase corresponding counter in ModelParameters class\n
*/
- /*! Pointer to current parssing line to set by class parser*/
- //int *current_line;
static int AddSymbol(std::string name,Type type, std::string tex_name);
protected :
/*! Symbol table map */
@@ -51,28 +49,26 @@ class SymbolTable
SymbolTable();
/*! Destructor*/
~SymbolTable();
+ /*! Pointer to error function of parser class */
+ static void (* error) (const char* m);
/*! Adds a symbol apearing in declaration
- warning if symbol is already set with same type
- error if symbol is already set with different type
- set name, type
- increase corresponding counter in ModelParameters
*/
- /*! Pointer to error function of parser class */
- static void (* error) (const char* m);
static int AddSymbolDeclar(std::string name,Type type, std::string tex_name);
/*! Adds symbol range */
static void AddSymbolRange(std::string name,int nbr,Type type, std::string tex_name);
/*! Adds a lag to field lags */
static void AddLag(std::string name,int lag);
- /*! Tests if symbol exists in symbol table
- \return true if exists, false outherwise
- */
/*! Sets a symbol as referenced */
static void SetReferenced(std::string name);
/*! Return eReferenced if symbol is referenced eNotReferenced otherwise*/
static Reference isReferenced(std::string name);
- /*! Sets a symbol as out of scoop */
- static void SetOutOfScoop(std::string name);
+ /*! Tests if symbol exists in symbol table
+ \return true if exists, false outherwise
+ */
inline static bool Exist(std::string name);
/*! Gets name by type and ID */
inline static std::string getNameByID(Type type,int id);
@@ -87,7 +83,6 @@ class SymbolTable
/*! Checks if symbols are used in model equations, removes unused symbol */
void clean();
void erase_local_parameters();
- //void PrintSymbolTable(void);
};
inline bool SymbolTable::Exist(std::string name)
{
diff --git a/parser.src/include/SymbolTableTypes.h b/parser.src/include/SymbolTableTypes.h
index 93960a2ac15014f54fe9712399d88fe370c6d1b2..6093363b6d483a71376c7a6f52891773f40b02b4 100644
--- a/parser.src/include/SymbolTableTypes.h
+++ b/parser.src/include/SymbolTableTypes.h
@@ -12,24 +12,22 @@
/*! Symbol type enum */
enum Type
{
- eEndogenous = 0, //!< Endogenousous
- eExogenous = 1, //!< Exogenousous
- eExogenousDet = 2, //!< Exogenousous deterministic (new)
+ eEndogenous = 0, //!< Endogenous
+ eExogenous = 1, //!< Exogenous
+ eExogenousDet = 2, //!< Exogenous deterministic (new)
eRecursiveVariable = 3, //!< Recursive variable (reserved for future use)
eParameter = 4, //!< Parameter
eLocalParameter = 10, //!< Parameter local to a model
eLoopIndex = 5, //!< Loop index
eTempResult = 6, //!< Temporary result, used only in Expression class
eNumericalConstant = 7, //!< Numerical constant, used only in Expression class
- eUnkownFunction = 8, //!< Unkown functions, used only in Expression class
- eUNDEF = 9 //!< Undefinded
+ eUNDEF = 9 //!< Undefined
};
/*! Symbol reference flag enum */
enum Reference
{
eNotReferenced, //!< Not yet referenced in model
eReferenced, //!< Already referenced in model
- eOutOfScoop, //!< Out of scoop (for loop index)
};
/*!
\class Symbol