From 5032e22fa6ae90c4dbbf9d7b0e5bc065b718ec77 Mon Sep 17 00:00:00 2001
From: Adam Wardynski <award@.(B-4.4.46a)>
Date: Wed, 4 May 2011 23:59:44 +0200
Subject: [PATCH] Change new_scope pattern to scope.reset_variables() to make
 gcc happy. It didn't like passing reference to something that could be
 treated as a value.

---
 libwccl/parser/grammar.g      | 33 +++++++++++++++++----------------
 libwccl/parser/parsingscope.h |  7 +++----
 2 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/libwccl/parser/grammar.g b/libwccl/parser/grammar.g
index 101fcf3..5071cda 100644
--- a/libwccl/parser/grammar.g
+++ b/libwccl/parser/grammar.g
@@ -1940,8 +1940,8 @@ bool_operator_sequence
 			seq.reset(new OpSequence<Bool>(token_ref_to_std_string(name)));
 		}
 		LPAREN
-			op = functional_operator_bool [scope] { seq->append(op); }
-			(SEMI op = functional_operator_bool [scope.new_scope()] { seq->append(op); })*
+			op = functional_operator_bool [scope] { seq->append(op); scope.reset_variables(); }
+			(SEMI op = functional_operator_bool [scope] { seq->append(op); scope.reset_variables(); })*
 		RPAREN
 ;
 
@@ -1956,8 +1956,8 @@ symset_operator_sequence
 			seq.reset(new OpSequence<TSet>(token_ref_to_std_string(name)));
 		}
 		LPAREN
-			op = functional_operator_symset [scope] { seq->append(op); }
-			(SEMI op = functional_operator_symset [scope.new_scope()] { seq->append(op); })*
+			op = functional_operator_symset [scope] { seq->append(op); scope.reset_variables(); }
+			(SEMI op = functional_operator_symset [scope] { seq->append(op); scope.reset_variables(); })*
 		RPAREN
 ;
 
@@ -1972,8 +1972,8 @@ strset_operator_sequence
 			seq.reset(new OpSequence<StrSet>(token_ref_to_std_string(name)));
 		}
 		LPAREN
-			op = functional_operator_strset [scope] { seq->append(op); }
-			(SEMI op = functional_operator_strset [scope.new_scope()] { seq->append(op); })*
+			op = functional_operator_strset [scope] { seq->append(op); scope.reset_variables(); }
+			(SEMI op = functional_operator_strset [scope] { seq->append(op); scope.reset_variables(); })*
 		RPAREN
 ;
 
@@ -1988,8 +1988,8 @@ position_operator_sequence
 			seq.reset(new OpSequence<Position>(token_ref_to_std_string(name)));
 		}
 		LPAREN
-			op = functional_operator_position [scope] { seq->append(op); }
-			(SEMI op = functional_operator_position [scope.new_scope()] { seq->append(op); })*
+			op = functional_operator_position [scope] { seq->append(op); scope.reset_variables(); }
+			(SEMI op = functional_operator_position [scope] { seq->append(op); scope.reset_variables(); })*
 		RPAREN
 ;
 
@@ -2004,8 +2004,8 @@ untyped_operator_sequence
 			seq.reset(new UntypedOpSequence(token_ref_to_std_string(name)));
 		}
 		LPAREN
-			op = functional_operator_any [scope] { seq->append(op); }
-			(SEMI op = functional_operator_any [scope.new_scope()] { seq->append(op); })*
+			op = functional_operator_any [scope] { seq->append(op); scope.reset_variables(); }
+			(SEMI op = functional_operator_any [scope] { seq->append(op); scope.reset_variables(); })*
 		RPAREN
 ;
 
@@ -2020,8 +2020,8 @@ match_operator_sequence
 			seq.reset(new OpSequence<Match>(token_ref_to_std_string(name)));
 		}
 		LPAREN
-			op = functional_operator_match [scope] { seq->append(op); }
-			(SEMI op = functional_operator_match [scope.new_scope()] { seq->append(op); })*
+			op = functional_operator_match [scope] { seq->append(op); scope.reset_variables(); }
+			(SEMI op = functional_operator_match [scope] { seq->append(op); scope.reset_variables();  })*
 		RPAREN
 ;
 
@@ -2103,17 +2103,18 @@ tag_rule
 
 // Rule sequence
 tag_rule_sequence
-	[const ParsingScope& scope]
+	[ParsingScope& scope]
 	returns [boost::shared_ptr<TagRuleSequence> rule_seq]
 {
 	boost::shared_ptr<TagRule> rle;
 	rule_seq.reset(new TagRuleSequence());
 }
-	: rle = tag_rule [scope.new_scope()] {
+	: rle = tag_rule [scope] {
 		rule_seq->push_back(*rle);
+		scope.reset_variables();
 	}
 	(
-		SEMI rle = tag_rule [scope.new_scope()] {
+		SEMI rle = tag_rule [scope] {
 			rule_seq->push_back(*rle);
 		}
 	)*
@@ -2122,7 +2123,7 @@ tag_rule_sequence
 // Temporary name. 
 // This is wrapper for tag_rule_sequence in rules section in the wccl file
 tag_rules
-	[const ParsingScope& scope]
+	[ParsingScope& scope]
 	returns [boost::shared_ptr<TagRuleSequence> rule_seq]
 	: "tag_rules" LPAREN rule_seq = tag_rule_sequence [scope] RPAREN {
 		//
diff --git a/libwccl/parser/parsingscope.h b/libwccl/parser/parsingscope.h
index 9157626..f04dd82 100644
--- a/libwccl/parser/parsingscope.h
+++ b/libwccl/parser/parsingscope.h
@@ -24,10 +24,6 @@ public:
 	{
 	}
 
-	ParsingScope new_scope() const {
-		return ParsingScope(tagset_, lexicons_);
-	}
-
 	const Corpus2::Tagset& tagset() const {
 		return tagset_;
 	}
@@ -44,6 +40,9 @@ public:
 		return lexicons_;
 	}
 
+	void reset_variables() {
+		variables_->reset_values();
+	}
 private:
 	const Corpus2::Tagset& tagset_;
 	boost::shared_ptr<Variables> variables_;
-- 
GitLab