From 295d24f57ae3c65817dff534422f39315f353b62 Mon Sep 17 00:00:00 2001
From: Adam Wardynski <award@.(B-4.4.46a)>
Date: Mon, 7 Mar 2011 13:15:57 +0100
Subject: [PATCH] Rename Rule to TagRule.

---
 libwccl/ops/rule.cpp         | 10 +++----
 libwccl/ops/rule.h           | 56 ++++++++++++++++++------------------
 libwccl/ops/rulesequence.cpp |  2 +-
 libwccl/ops/rulesequence.h   | 12 ++++----
 libwccl/parser/Parser.cpp    |  6 ++--
 libwccl/parser/Parser.h      |  4 +--
 libwccl/parser/grammar.g     | 18 ++++++------
 7 files changed, 54 insertions(+), 54 deletions(-)

diff --git a/libwccl/ops/rule.cpp b/libwccl/ops/rule.cpp
index ba843bd..ca7c10a 100644
--- a/libwccl/ops/rule.cpp
+++ b/libwccl/ops/rule.cpp
@@ -1,9 +1,9 @@
-#include <libwccl/ops/rule.h>
+#include <libwccl/ops/tagrule.h>
 #include <sstream>
 
 namespace Wccl {
 
-Bool Rule::execute(SentenceContext &sentence_context)
+Bool TagRule::execute(SentenceContext &sentence_context)
 {
 	if(sentence_context.size() == 0) {
 		throw InvalidArgument(
@@ -27,7 +27,7 @@ Bool Rule::execute(SentenceContext &sentence_context)
 	return changed;
 }
 
-const boost::shared_ptr<const Function<Bool> > Rule::TrueCondition()
+const boost::shared_ptr<const Function<Bool> > TagRule::TrueCondition()
 {
 	static boost::shared_ptr<const Function<Bool> > true_constant(
 			new Constant<Bool>(Bool(true)));
@@ -35,7 +35,7 @@ const boost::shared_ptr<const Function<Bool> > Rule::TrueCondition()
 }
 
 
-std::string Rule::to_string(const Corpus2::Tagset &tagset) const
+std::string TagRule::to_string(const Corpus2::Tagset &tagset) const
 {
 	std::ostringstream os;
 	os << "rule(\"" << name_ << "\", " << condition_->to_string(tagset);
@@ -46,7 +46,7 @@ std::string Rule::to_string(const Corpus2::Tagset &tagset) const
 	return os.str();
 }
 
-std::ostream& Rule::write_to(std::ostream& os) const {
+std::ostream& TagRule::write_to(std::ostream& os) const {
 	os << "rule(\"" << name_ << "\", " << *condition_;
 	foreach(const boost::shared_ptr<Action>& action, *actions_) {
 		os << ", " << *action;
diff --git a/libwccl/ops/rule.h b/libwccl/ops/rule.h
index f66f903..c525add 100644
--- a/libwccl/ops/rule.h
+++ b/libwccl/ops/rule.h
@@ -1,5 +1,5 @@
-#ifndef LIBWCCL_OPS_RULE_H
-#define LIBWCCL_OPS_RULE_H
+#ifndef LIBWCCL_OPS_TAGRULE_H
+#define LIBWCCL_OPS_TAGRULE_H
 
 #include <boost/scoped_ptr.hpp>
 
@@ -14,10 +14,10 @@ namespace Wccl {
  * @note The class methods are not thread-safe, but you can use clone method
  * to acquire a separate copy of the Rule, and the copy can be used concurrently.
  */
-class Rule : public ParsedExpression
+class TagRule : public ParsedExpression
 {
 public:
-	Rule(
+	TagRule(
 		const std::string& name,
 		const Variables& variables,
 		const boost::shared_ptr<const std::vector<boost::shared_ptr<Action> > >& actions,
@@ -79,7 +79,7 @@ public:
 	 * @see \link operator=(const Rule&) operator= \endlink - assignment
 	 * Rule, yet another way to create a copy.
 	 */
-	Rule clone() const;
+	TagRule clone() const;
 
 	/**
 	 * Makes a copy of the Rule, having its own space for Variables.
@@ -95,21 +95,21 @@ public:
 	 * @see clone_clean_ptr - a version that returns a copy wrapped
 	 * in a shared pointer, and also having its Variables cleaned.
 	 */
-	Rule clone_clean() const;
+	TagRule clone_clean() const;
 
 	/**
 	 * @returns A copy of the expression, with values of the variables
 	 * copied as well.
 	 * @see clone_clean_ptr - convenience version that returns clean copy.
 	 */
-	boost::shared_ptr<Rule> clone_ptr() const;
+	boost::shared_ptr<TagRule> clone_ptr() const;
 
 	/**
 	 * @returns A copy of the expression, with values of the variables
 	 * set to their defaults.
 	 * @see clone_ptr - a version that keeps values of the variables.
 	 */
-	boost::shared_ptr<Rule> clone_clean_ptr() const;
+	boost::shared_ptr<TagRule> clone_clean_ptr() const;
 
 	/**
 	 * Copy constructor, creates a copy with new set of values for
@@ -119,12 +119,12 @@ public:
 	 * @param clean - true if copy needs to have its variables
 	 * set to default values, false to keep the values; false is default
 	 */
-	Rule(const Rule& other, bool clean = false);
+	TagRule(const TagRule& other, bool clean = false);
 
 	/**
 	 * Default constructor. Produces Rule that returns False.
 	 */
-	Rule();
+	TagRule();
 	/**
 	 * Assignment operator to create a workable copy of other Rule
 	 * (workable means it has a new set of values for variables, allowing
@@ -134,12 +134,12 @@ public:
 	 * @param other - Rule to copy
 	 * @returns A reference to the current object, after assignment.
 	 */
-	Rule& operator=(const Rule& other);
+	TagRule& operator=(const TagRule& other);
 
 	std::string to_string(const Corpus2::Tagset& tagset) const;
 
 protected:
-	Rule* clone_internal() const;
+	TagRule* clone_internal() const;
 	std::ostream& write_to(std::ostream& ostream) const;
 
 private:
@@ -155,7 +155,7 @@ private:
 //--- implementation details ---
 //
 inline
-Rule::Rule(
+TagRule::TagRule(
 		const std::string& name,
 		const Variables& variables,
 		const boost::shared_ptr<const std::vector<boost::shared_ptr<Action> > >& actions,
@@ -169,22 +169,22 @@ Rule::Rule(
 }
 
 inline
-Bool Rule::operator()(SentenceContext& sc) {
+Bool TagRule::operator()(SentenceContext& sc) {
 	return execute(sc);
 }
 
 inline
-std::string Rule::name() const {
+std::string TagRule::name() const {
 	return name_;
 }
 
 inline
-Rule* Rule::clone_internal() const {
-	return new Rule(name_, *variables_, actions_, condition_);
+TagRule* TagRule::clone_internal() const {
+	return new TagRule(name_, *variables_, actions_, condition_);
 }
 
 inline
-Rule::Rule(const Rule &other, bool clean)
+TagRule::TagRule(const TagRule &other, bool clean)
 	: ParsedExpression(*other.variables_),
 	  actions_(other.actions_),
 	  condition_(other.condition_),
@@ -198,17 +198,17 @@ Rule::Rule(const Rule &other, bool clean)
 }
 
 inline
-Rule Rule::clone() const {
+TagRule TagRule::clone() const {
 	return *this;
 }
 
 inline
-Rule Rule::clone_clean() const {
-	return Rule(*this, true);
+TagRule TagRule::clone_clean() const {
+	return TagRule(*this, true);
 }
 
 inline
-Rule& Rule::operator=(const Rule& other) {
+TagRule& TagRule::operator=(const TagRule& other) {
 	BOOST_ASSERT(other.actions_);
 	BOOST_ASSERT(other.condition_);
 	actions_ = other.actions_;
@@ -219,7 +219,7 @@ Rule& Rule::operator=(const Rule& other) {
 }
 
 inline
-Rule::Rule()
+TagRule::TagRule()
 	: ParsedExpression((Variables())),
 	  actions_(boost::make_shared<std::vector<boost::shared_ptr<Action> > >()),
 	  condition_(detail::DefaultFunction<Bool>()),
@@ -231,13 +231,13 @@ Rule::Rule()
 }
 
 inline
-boost::shared_ptr<Rule> Rule::clone_ptr() const {
-	return boost::shared_ptr<Rule>(clone_internal());
+boost::shared_ptr<TagRule> TagRule::clone_ptr() const {
+	return boost::shared_ptr<TagRule>(clone_internal());
 }
 
 inline
-boost::shared_ptr<Rule> Rule::clone_clean_ptr() const {
-	boost::shared_ptr<Rule> copy(clone_internal());
+boost::shared_ptr<TagRule> TagRule::clone_clean_ptr() const {
+	boost::shared_ptr<TagRule> copy(clone_internal());
 	BOOST_ASSERT(copy);
 	copy->clean();
 	return copy;
@@ -245,4 +245,4 @@ boost::shared_ptr<Rule> Rule::clone_clean_ptr() const {
 
 } /* end ns Wccl */
 
-#endif // LIBWCCL_OPS_RULE_H
+#endif // LIBWCCL_OPS_TAGRULE_H
diff --git a/libwccl/ops/rulesequence.cpp b/libwccl/ops/rulesequence.cpp
index 4e754db..b5c1f8a 100644
--- a/libwccl/ops/rulesequence.cpp
+++ b/libwccl/ops/rulesequence.cpp
@@ -14,7 +14,7 @@ Bool RuleSequence::execute_once(const boost::shared_ptr<Corpus2::Sentence>& sent
 	Bool changed(false);
 	SentenceContext sc(sentence);
 	while(sc.is_current_inside()) {
-		foreach (Rule& rule, *this) {
+		foreach (TagRule& rule, *this) {
 			if (rule.execute(sc).get_value()) {
 				changed.set_value(true);
 			}
diff --git a/libwccl/ops/rulesequence.h b/libwccl/ops/rulesequence.h
index d15b272..1015a9b 100644
--- a/libwccl/ops/rulesequence.h
+++ b/libwccl/ops/rulesequence.h
@@ -1,7 +1,7 @@
 #ifndef LIBWCCL_OPS_RULESEQUENCE_H
 #define LIBWCCL_OPS_RULESEQUENCE_H
 
-#include <libwccl/ops/rule.h>
+#include <libwccl/ops/tagrule.h>
 
 namespace Wccl {
 
@@ -11,10 +11,10 @@ namespace Wccl {
  * for all positions of a Sentence.
  * @note The class methods are not thread-safe
  */
-class RuleSequence : public std::vector<Rule>
+class RuleSequence : public std::vector<TagRule>
 {
 public:
-	RuleSequence(std::vector<Rule> rules);
+	RuleSequence(std::vector<TagRule> rules);
 
 	RuleSequence();
 
@@ -73,13 +73,13 @@ public:
 //--- implementation details ---
 //
 inline
-RuleSequence::RuleSequence(std::vector<Rule> rules)
-	: std::vector<Rule>(rules) {
+RuleSequence::RuleSequence(std::vector<TagRule> rules)
+	: std::vector<TagRule>(rules) {
 }
 
 inline
 RuleSequence::RuleSequence()
-	: std::vector<Rule>() {
+	: std::vector<TagRule>() {
 }
 
 inline
diff --git a/libwccl/parser/Parser.cpp b/libwccl/parser/Parser.cpp
index b7dca25..a8bdddf 100644
--- a/libwccl/parser/Parser.cpp
+++ b/libwccl/parser/Parser.cpp
@@ -452,7 +452,7 @@ boost::shared_ptr<RuleSequence> Parser::parseRuleSequence(
  * @arg str rule
  * @return the parsed rule via a shared pointer
  */
-boost::shared_ptr<Rule> Parser::parseSingleRule(
+boost::shared_ptr<TagRule> Parser::parseSingleRule(
 		const std::string& str) const
 {
 	std::stringstream ss (std::stringstream::in | std::stringstream::out);
@@ -472,12 +472,12 @@ boost::shared_ptr<Rule> Parser::parseSingleRule(
  * @arg istr input stream with writed rule
  * @return the parsed rule via a shared pointer
  */
-boost::shared_ptr<Rule> Parser::parseSingleRule(
+boost::shared_ptr<TagRule> Parser::parseSingleRule(
 		std::istream& istr) const
 {
 	ANTLRLexer lexer(istr);
 	ANTLRParser parser(lexer);
-	boost::shared_ptr<Rule> res;
+	boost::shared_ptr<TagRule> res;
 
 	try {
 		res = parser.parse_single_rule(tagset_);
diff --git a/libwccl/parser/Parser.h b/libwccl/parser/Parser.h
index 9f6e3f6..645caba 100644
--- a/libwccl/parser/Parser.h
+++ b/libwccl/parser/Parser.h
@@ -73,9 +73,9 @@ public:
 
 	// ---------------------------------------------------------------------------
 	// Parsing single rule from input string
-	boost::shared_ptr<Rule>
+	boost::shared_ptr<TagRule>
 			parseSingleRule(const std::string&) const;
-	boost::shared_ptr<Rule>
+	boost::shared_ptr<TagRule>
 			parseSingleRule(std::istream&) const;
 
 	// ---------------------------------------------------------------------------
diff --git a/libwccl/parser/grammar.g b/libwccl/parser/grammar.g
index d096933..4a213e9 100644
--- a/libwccl/parser/grammar.g
+++ b/libwccl/parser/grammar.g
@@ -59,7 +59,7 @@ header {
 	#include <libwccl/ops/functions/bool/iterations/rightlook.h>
 	
 	// Rules, actions
-	#include <libwccl/ops/rule.h>
+	#include <libwccl/ops/tagrule.h>
 	#include <libwccl/ops/rulesequence.h>
 	//
 	#include <libwccl/ops/actions/unify.h>
@@ -210,10 +210,10 @@ parse_position_operator
 // ----------------------------------------------------------------------------
 // ----------------------------------------------------------------------------
 // Rule for parsing single WCCL Rule
-// Returns boost::shared_ptr<Rule>
+// Returns boost::shared_ptr<TagRule>
 parse_single_rule
 	[const Corpus2::Tagset &tagset]
-	returns [boost::shared_ptr<Rule> rle]
+	returns [boost::shared_ptr<TagRule> rle]
 {	
 	Variables vars;
 }
@@ -1398,7 +1398,7 @@ action_sequence
 // 	rule(NAME, ACTIONS) or rule(NAME, COND, ACTIONS)
 rule
 	[const Corpus2::Tagset& tagset, Variables& vars]
-	returns [boost::shared_ptr<Rule> rle]
+	returns [boost::shared_ptr<TagRule> rle]
 {
 	boost::shared_ptr<Function<Bool> > condition;
 	boost::shared_ptr<std::vector<boost::shared_ptr<Action> > > actions;
@@ -1409,11 +1409,11 @@ rule
 		RPAREN {
 			if (condition) {
 				rle.reset(
-					new Rule(token_ref_to_std_string(name), vars, actions, condition));
+					new TagRule(token_ref_to_std_string(name), vars, actions, condition));
 			}
 			else {
 				rle.reset(
-					new Rule(token_ref_to_std_string(name), vars, actions));
+					new TagRule(token_ref_to_std_string(name), vars, actions));
 			}
 		}
 /*
@@ -1425,14 +1425,14 @@ rule
 			actions = action_sequence [tagset, vars] {
 				// rule(NAME, COND, ACTIONS)
 				rle.reset(
-					new Rule(token_ref_to_std_string(name), vars, actions, condition));
+					new TagRule(token_ref_to_std_string(name), vars, actions, condition));
 			}
 		)
 	|
 		(
 			actions = action_sequence [tagset, vars] {
 				// rule(NAME, ACTIONS)
-				rle.reset(new Rule(token_ref_to_std_string(name), vars, actions));
+				rle.reset(new TagRule(token_ref_to_std_string(name), vars, actions));
 			}
 		)
 	)
@@ -1446,7 +1446,7 @@ rule_sequence
 	returns [boost::shared_ptr<RuleSequence> rule_seq]
 {
 	// FIXME czy tutaj przypadkiem nie powinno byc shared_ptr?
-	boost::shared_ptr<Rule> rle;
+	boost::shared_ptr<TagRule> rle;
 
 	rule_seq.reset(new RuleSequence());
 }
-- 
GitLab