From c3d114a7a1b9c426858bc72bd616cb7adb856933 Mon Sep 17 00:00:00 2001
From: sebastien <sebastien@ac1d8469-bf42-47a9-8791-bf33cf982152>
Date: Mon, 5 Feb 2007 09:55:41 +0000
Subject: [PATCH] v4 parser: * declared ExprNode::cost as const * Makefile:
removed DynareBison.{cc,hh} from "clean" rule. Added a "distclean" rule for
that purpose * various minor changes
git-svn-id: https://www.dynare.org/svn/dynare/dynare_v4@1179 ac1d8469-bf42-47a9-8791-bf33cf982152
---
parser.src/ComputingTasks.cc | 2 +-
parser.src/ExprNode.cc | 6 +++---
parser.src/Makefile | 8 ++++++--
parser.src/ParsingDriver.cc | 14 +++++++-------
parser.src/include/ComputingTasks.hh | 2 +-
parser.src/include/ExprNode.hh | 6 +++---
6 files changed, 21 insertions(+), 17 deletions(-)
diff --git a/parser.src/ComputingTasks.cc b/parser.src/ComputingTasks.cc
index 65a42e370..88020ee24 100644
--- a/parser.src/ComputingTasks.cc
+++ b/parser.src/ComputingTasks.cc
@@ -82,7 +82,7 @@ StochSimulStatement::writeOutput(ostream &output, const string &basename) const
}
RamseyPolicyStatement::RamseyPolicyStatement(const TmpSymbolTable &tmp_symbol_table_arg,
- const OptionsList &options_list_arg) :
+ const OptionsList &options_list_arg) :
tmp_symbol_table(tmp_symbol_table_arg),
options_list(options_list_arg)
{
diff --git a/parser.src/ExprNode.cc b/parser.src/ExprNode.cc
index 166217982..4ec5e96ff 100644
--- a/parser.src/ExprNode.cc
+++ b/parser.src/ExprNode.cc
@@ -46,7 +46,7 @@ ExprNode::precedence(const temporary_terms_type &temporary_terms) const
}
int
-ExprNode::cost(temporary_terms_type &temporary_terms) const
+ExprNode::cost(const temporary_terms_type &temporary_terms) const
{
// For a terminal node, the cost is null
return 0;
@@ -318,7 +318,7 @@ UnaryOpNode::computeDerivative(int varID)
}
int
-UnaryOpNode::cost(temporary_terms_type &temporary_terms) const
+UnaryOpNode::cost(const temporary_terms_type &temporary_terms) const
{
// For a temporary term, the cost is null
temporary_terms_type::const_iterator it = temporary_terms.find(const_cast<UnaryOpNode *>(this));
@@ -617,7 +617,7 @@ BinaryOpNode::precedence(const temporary_terms_type &temporary_terms) const
}
int
-BinaryOpNode::cost(temporary_terms_type &temporary_terms) const
+BinaryOpNode::cost(const temporary_terms_type &temporary_terms) const
{
temporary_terms_type::const_iterator it = temporary_terms.find(const_cast<BinaryOpNode *>(this));
// For a temporary term, the cost is null
diff --git a/parser.src/Makefile b/parser.src/Makefile
index 551064850..7ad72c5e5 100644
--- a/parser.src/Makefile
+++ b/parser.src/Makefile
@@ -101,10 +101,14 @@ DynareBison.cc include/DynareBison.hh: DynareBison.yy include/ParsingDriver.hh
clean:
rm -f *.o *.P \
*~ include/*~ \
- DynareBison.cc \
- include/DynareBison.hh \
DynareBison.output \
DynareFlex.cc \
$(DYNARE_M) \
$(DYNARE_S)
+distclean: clean
+ rm -f DynareBison.cc \
+ include/position.hh \
+ include/stack.hh \
+ include/location.hh \
+ include/DynareBison.hh
diff --git a/parser.src/ParsingDriver.cc b/parser.src/ParsingDriver.cc
index d67f779d1..ed288f02b 100644
--- a/parser.src/ParsingDriver.cc
+++ b/parser.src/ParsingDriver.cc
@@ -237,7 +237,7 @@ ParsingDriver::init_val(string *name, ExpObj *rhs)
&& type != eExogenousDet)
error("initval/endval: " + *name + " should be an endogenous or exogenous variable");
- init_values.push_back(pair<string, string>(*name, get_expression(rhs)));
+ init_values.push_back(make_pair(*name, get_expression(rhs)));
delete name;
delete rhs;
@@ -434,7 +434,7 @@ ParsingDriver::add_period(string *p1, string *p2)
{
int p1_val = atoi(p1->c_str());
int p2_val = atoi(p2->c_str());
- det_shocks_periods.push_back(pair<int, int>(p1_val, p2_val));
+ det_shocks_periods.push_back(make_pair(p1_val, p2_val));
delete p1;
delete p2;
}
@@ -443,7 +443,7 @@ void
ParsingDriver::add_period(string *p1)
{
int p1_val = atoi(p1->c_str());
- det_shocks_periods.push_back(pair<int, int>(p1_val, p1_val));
+ det_shocks_periods.push_back(make_pair(p1_val, p1_val));
delete p1;
}
@@ -510,7 +510,7 @@ ParsingDriver::option_num(const string &name_option, string *opt1, string *opt2)
!= options_list.paired_num_options.end())
error("option " + name_option + " declared twice");
- options_list.paired_num_options[name_option] = pair<string, string>(*opt1, *opt2);
+ options_list.paired_num_options[name_option] = make_pair(*opt1, *opt2);
delete opt1;
delete opt2;
}
@@ -802,7 +802,7 @@ ParsingDriver::set_calib_var(string *name, string *weight, ExpObj *expression)
if (calib_var.find(*name) != calib_var.end())
error("calib_var: " + *name + " declared twice");
- calib_var[*name] = pair<string, string>(*weight, get_expression(expression));
+ calib_var[*name] = make_pair(*weight, get_expression(expression));
delete name;
delete weight;
@@ -827,7 +827,7 @@ ParsingDriver::set_calib_covar(string *name1, string *name2,
error("calib_var: pair of variables (" + *name1 + ", " + *name2
+ ") declared twice");
- calib_covar[covar_key] = pair<string, string>(*weight, get_expression(expression));
+ calib_covar[covar_key] = make_pair(*weight, get_expression(expression));
delete name1;
delete name2;
@@ -849,7 +849,7 @@ ParsingDriver::set_calib_ac(string *name, string *ar,
if (calib_ac.find(ac_key) != calib_ac.end())
error("calib_var: autocorr " + *name + "(" + *ar + ") declared twice");
- calib_ac[ac_key] = pair<string, string>(*weight, get_expression(expression));
+ calib_ac[ac_key] = make_pair(*weight, get_expression(expression));
delete name;
delete ar;
diff --git a/parser.src/include/ComputingTasks.hh b/parser.src/include/ComputingTasks.hh
index 86048a3b4..5df3cae1e 100644
--- a/parser.src/include/ComputingTasks.hh
+++ b/parser.src/include/ComputingTasks.hh
@@ -56,7 +56,7 @@ private:
const OptionsList options_list;
public:
RamseyPolicyStatement(const TmpSymbolTable &tmp_symbol_table_arg,
- const OptionsList &options_list_arg);
+ const OptionsList &options_list_arg);
virtual void checkPass(ModFileStructure &mod_file_struct);
virtual void writeOutput(ostream &output, const string &basename) const;
};
diff --git a/parser.src/include/ExprNode.hh b/parser.src/include/ExprNode.hh
index dfd1e16ee..dd607cc75 100644
--- a/parser.src/include/ExprNode.hh
+++ b/parser.src/include/ExprNode.hh
@@ -49,7 +49,7 @@ protected:
//! Cost of computing current node
/*! Nodes included in temporary_terms are considered having a null cost */
- virtual int cost(temporary_terms_type &temporary_terms) const;
+ virtual int cost(const temporary_terms_type &temporary_terms) const;
public:
ExprNode(DataTree &datatree_arg);
@@ -137,7 +137,7 @@ private:
const UnaryOpcode op_code;
virtual NodeID computeDerivative(int varID);
- int cost(temporary_terms_type &temporary_terms) const;
+ int cost(const temporary_terms_type &temporary_terms) const;
public:
UnaryOpNode(DataTree &datatree_arg, UnaryOpcode op_code_arg, const NodeID arg_arg);
virtual void computeTemporaryTerms(map<NodeID, int> &reference_count, temporary_terms_type &temporary_terms) const;
@@ -162,7 +162,7 @@ private:
const NodeID arg1, arg2;
const BinaryOpcode op_code;
virtual NodeID computeDerivative(int varID);
- int cost(temporary_terms_type &temporary_terms) const;
+ int cost(const temporary_terms_type &temporary_terms) const;
public:
BinaryOpNode(DataTree &datatree_arg, const NodeID arg1_arg,
BinaryOpcode op_code_arg, const NodeID arg2_arg);
--
GitLab