diff --git a/libwccl/parser/grammar.g b/libwccl/parser/grammar.g
index 6d8712b0500fd7974f41b61a3a0273f4e5a97fdf..d8b78df8733e8602287cd8984b986b1e8db1630e 100644
--- a/libwccl/parser/grammar.g
+++ b/libwccl/parser/grammar.g
@@ -3,11 +3,13 @@ header {
 	ANTLR_END_NAMESPACE
 
 	#include <libwccl/parser/ParserException.h>
+	#include <libwccl/parser/parsingscope.h>
 
 	#include <cstdio>
 	#include <antlr/Token.hpp>
 	#include <boost/lexical_cast.hpp>
 
+
 	// values/variables
 	#include <libwccl/variables.h>
 	#include <libwccl/values/bool.h>
@@ -175,11 +177,11 @@ parse_strset_operator
 	[const Corpus2::Tagset &tagset]
 	returns [boost::shared_ptr<Operator<StrSet> > res]
 {
-	Variables vars;
+	ParsingScope scope(tagset);
 	boost::shared_ptr<Function<StrSet> > body;
 }
-	: body = strset_operator [tagset, vars] {
-			res.reset(new Operator<StrSet>(body, vars));
+	: body = strset_operator [scope] {
+			res.reset(new Operator<StrSet>(body, scope.variables()));
 	}
 	EOF
 ;
@@ -191,11 +193,11 @@ parse_bool_operator
 	[const Corpus2::Tagset &tagset]
 	returns [boost::shared_ptr<Operator<Bool> > res]
 {
-	Variables vars;
+	ParsingScope scope(tagset);
 	boost::shared_ptr<Function<Bool> > body;
 }
-	: body = bool_operator [tagset, vars] {
-			res.reset(new Operator<Bool>(body, vars));
+	: body = bool_operator [scope] {
+			res.reset(new Operator<Bool>(body, scope.variables()));
 	}
 	EOF
 ;
@@ -207,11 +209,11 @@ parse_symset_operator
 	[const Corpus2::Tagset &tagset]
 	returns [boost::shared_ptr<Operator<TSet> > res]
 {
-	Variables vars;
+	ParsingScope scope(tagset);
 	boost::shared_ptr<Function<TSet> > body;
 }
-	: body = symset_operator [tagset, vars] {
-			res.reset(new Operator<TSet>(body, vars));
+	: body = symset_operator [scope] {
+			res.reset(new Operator<TSet>(body, scope.variables()));
 	}
 	EOF
 ;
@@ -223,11 +225,11 @@ parse_position_operator
 	[const Corpus2::Tagset &tagset]
 	returns [boost::shared_ptr<Operator<Position> > res]
 {	
-	Variables vars;
+	ParsingScope scope(tagset);
 	boost::shared_ptr<Function<Position> > body;
 }
-	: body = position_operator [tagset, vars] {
-			res.reset(new Operator<Position>(body, vars));
+	: body = position_operator [scope] {
+			res.reset(new Operator<Position>(body, scope.variables()));
 	}
 	EOF
 ;
@@ -240,9 +242,9 @@ parse_single_rule
 	[const Corpus2::Tagset &tagset]
 	returns [boost::shared_ptr<TagRule> rle]
 {	
-	Variables vars;
+	ParsingScope scope(tagset);
 }
-	: rle = rule [tagset, vars]
+	: rle = rule [scope]
 ;
 
 // Rule for parsing rules section in the wccl file
@@ -251,9 +253,9 @@ parse_rule_sequence
 	[const Corpus2::Tagset& tagset]
 	returns [boost::shared_ptr<RuleSequence> rule_seq]
 {
-	Variables vars;
+	ParsingScope scope(tagset);
 }
-	: rule_seq = rules[tagset, vars]
+	: rule_seq = rules[scope]
 ;
 
 // ----------------------------------------------------------------------------
@@ -264,10 +266,10 @@ parse_match_rule
 	[const Corpus2::Tagset& tagset]
 	returns [boost::shared_ptr<MatchRule> ret_match]
 {
-	Variables vars;
-	vars.get_put<Match>("_M");
+	ParsingScope scope(tagset);
+	scope.variables().get_put<Match>("_M");
 }
-	: ret_match = match_rule_operator[tagset, vars] 
+	: ret_match = match_rule_operator[scope] 
 ;
 
 ///////////////////////////////////////////////////////////////////////////////
@@ -688,26 +690,26 @@ match_vector_variable
 // Returns boost::shared_ptr<Function<TSet> >
 ///////////////////////////////////////////////////////////////////////////////
 symset_operator
-	[const Corpus2::Tagset& tagset, Variables& vars]
+	[ParsingScope& scope]
 	returns [boost::shared_ptr<Function<TSet> > ret]
-	: ret = symset_condition [tagset, vars]
-	| {LA(1)==SYMBOL && LA(2)==LBRACKET}? (ret = symset_getsymbol [tagset, vars])
-	| ret = symset_var_val [tagset, vars]
-	| ret = symset_class   [tagset, vars]
-	| ret = symset_range   [tagset, vars]
-	| ret = symset_catflt  [tagset, vars]
-	| ret = symset_agrflt  [tagset, vars]
+	: ret = symset_condition [scope]
+	| {LA(1)==SYMBOL && LA(2)==LBRACKET}? (ret = symset_getsymbol [scope])
+	| ret = symset_var_val [scope]
+	| ret = symset_class   [scope]
+	| ret = symset_range   [scope]
+	| ret = symset_catflt  [scope]
+	| ret = symset_agrflt  [scope]
 	//
-	| LPAREN ret = symset_operator [tagset, vars] RPAREN
+	| LPAREN ret = symset_operator [scope] RPAREN
 ;
 
 // ----------------------------------------------------------------------------
 // A wrapper for symset variable and symset value.
 symset_var_val
-	[const Corpus2::Tagset& tagset, Variables& vars]
+	[ParsingScope& scope]
 	returns [boost::shared_ptr<Function<TSet> > op]
-	: op = symset_variable [vars]
-	| op = symset_value    [tagset]
+	: op = symset_variable [scope.variables()]
+	| op = symset_value    [scope.tagset()]
 ;
 
 // ----------------------------------------------------------------------------
@@ -715,15 +717,15 @@ symset_var_val
 // 	if (Bool, TSet, TSet)
 // 	? TSet ? Bool : {}
 symset_condition
-	[const Corpus2::Tagset& tagset, Variables& vars]
+	[ParsingScope& scope]
 	returns [boost::shared_ptr<Function<TSet> > op]
 {
 	boost::shared_ptr<Function<Bool> > test;
 	boost::shared_ptr<Function<TSet> > p_true, p_false;
 }
-	: "if" LPAREN test  = bool_operator [tagset, vars] COMMA 
-							p_true  = symset_operator  [tagset, vars] 
-							(COMMA p_false = symset_operator [tagset, vars])? 
+	: "if" LPAREN test  = bool_operator [scope] COMMA 
+							p_true  = symset_operator  [scope] 
+							(COMMA p_false = symset_operator [scope])? 
 		RPAREN {
 			if (p_false) {
 				op.reset(new Conditional<TSet>(test, p_true, p_false));
@@ -733,9 +735,9 @@ symset_condition
 			}
 		}
 	| Q_MARK 
-			(p_true = symset_operator [tagset, vars])
+			(p_true = symset_operator [scope])
 		Q_MARK 
-			(test = bool_operator [tagset, vars]) {
+			(test = bool_operator [scope]) {
 			op.reset(new Conditional<TSet>(test, p_true));
 		}
 ;
@@ -744,15 +746,15 @@ symset_condition
 // GetSymbol operator may be cas, m1, f, sg...
 // WARNING! This rule can throw ParserException! Be careful!
 symset_getsymbol
-	[const Corpus2::Tagset& tagset, Variables& vars]
+	[ParsingScope& scope]
 	returns [boost::shared_ptr<Function<TSet> > op]
 {
 	Corpus2::Tag tag;
 	boost::shared_ptr<Wccl::Function<Position> > position;
 }
-	: t: SYMBOL LBRACKET position = position_operator [tagset, vars] RBRACKET {
+	: t: SYMBOL LBRACKET position = position_operator [scope] RBRACKET {
 			try {
-				tag = tagset.parse_symbol(str_token_rem_grav(t));
+				tag = scope.tagset().parse_symbol(str_token_rem_grav(t));
 			}
 			catch(Corpus2::TagParseError &e) {
 				throw(ParserException(e.info()));
@@ -765,12 +767,12 @@ symset_getsymbol
 // ----------------------------------------------------------------------------
 // Class operator.
 symset_class 
-	[const Corpus2::Tagset& tagset, Variables& vars]
+	[ParsingScope& scope]
 	returns [boost::shared_ptr<Function<TSet> > ret]
 {
 	boost::shared_ptr<Function<Position> > pos;
 }
-	: "class" LBRACKET pos = position_operator [tagset, vars] RBRACKET { 
+	: "class" LBRACKET pos = position_operator [scope] RBRACKET { 
 		ret.reset(new GetWordClass(pos));
 	}
 ;
@@ -778,16 +780,16 @@ symset_class
 // ----------------------------------------------------------------------------
 // Range operator: range(class, begin, end) or range({...}, begin, end)
 symset_range
-	[const Corpus2::Tagset& tagset, Variables& vars]
+	[ParsingScope& scope]
 	returns [boost::shared_ptr<Function<TSet> > ret]
 {
 	boost::shared_ptr<TSet> tset;
 	boost::shared_ptr<Function<Position> > p1, p2;
 }
 	: "range" LPAREN
-			(tset = symset_literal [tagset] | tag_class: "class") COMMA
-			p1  = position_operator [tagset, vars] COMMA 
-			p2  = position_operator [tagset, vars] 
+			(tset = symset_literal [scope.tagset()] | tag_class: "class") COMMA
+			p1  = position_operator [scope] COMMA 
+			p2  = position_operator [scope] 
 		RPAREN {
 			if (tag_class) {
 				ret.reset(new GetSymbolsInRange(Corpus2::Tag(-1), p1, p2));
@@ -801,16 +803,16 @@ symset_range
 // ----------------------------------------------------------------------------
 // Catflt operator
 symset_catflt
-  [const Corpus2::Tagset& tagset, Variables& vars]
+  [ParsingScope& scope]
   returns [boost::shared_ptr<Function<TSet> > ret]
 {
   boost::shared_ptr<Function<TSet> > selector, mask;
   boost::shared_ptr<Function<Position> > position;
 }
   : "catflt" LPAREN 
-			position = position_operator [tagset, vars] COMMA
-			selector = symset_operator   [tagset, vars] COMMA
-			mask    = symset_operator    [tagset, vars] 
+			position = position_operator [scope] COMMA
+			selector = symset_operator   [scope] COMMA
+			mask    = symset_operator    [scope] 
   	RPAREN {
   	  ret.reset(new CatFilter(position, selector, mask));
   	}
@@ -819,19 +821,19 @@ symset_catflt
 // ----------------------------------------------------------------------------
 // Agrflt operator
 symset_agrflt
-  [const Corpus2::Tagset& tagset, Variables& vars]
+  [ParsingScope& scope]
   returns [boost::shared_ptr<Function<TSet> > ret]
 {
   boost::shared_ptr<Function<TSet> > attr, mask;
   boost::shared_ptr<Function<Position> > lpos, rpos;
 }
   : "agrflt" LPAREN 
-			lpos = position_operator [tagset, vars] COMMA
-			rpos = position_operator [tagset, vars] COMMA
-			attr = symset_operator   [tagset, vars] COMMA
-			mask = symset_operator   [tagset, vars] 
+			lpos = position_operator [scope] COMMA
+			rpos = position_operator [scope] COMMA
+			attr = symset_operator   [scope] COMMA
+			mask = symset_operator   [scope] 
   	RPAREN {
-  	  ret.reset(new AgrFilter(lpos, rpos, attr, mask, tagset));
+  	  ret.reset(new AgrFilter(lpos, rpos, attr, mask, scope.tagset()));
   	}
 ;
 
@@ -841,14 +843,14 @@ symset_agrflt
 // Returns boost::shared_ptr<Function<Position> >
 ///////////////////////////////////////////////////////////////////////////////
 position_operator
-	[const Corpus2::Tagset& tagset, Variables& vars]
+	[ParsingScope& scope]
 	returns [boost::shared_ptr<Function<Position> > ret]
 	: 
-	( ret = position_var_val     [vars]
-	| ret = position_condition   [tagset, vars]
-	| ret = position_first_token [tagset, vars]
-	| ret = position_last_token  [tagset, vars]
-	| LPAREN ret = position_operator [tagset, vars] RPAREN
+	( ret = position_var_val     [scope.variables()]
+	| ret = position_condition   [scope]
+	| ret = position_first_token [scope]
+	| ret = position_last_token  [scope]
+	| LPAREN ret = position_operator [scope] RPAREN
 	) 
 	( // if there is SIGNED_INT after the position, it is actually a relative position
 		i: SIGNED_INT {
@@ -871,15 +873,15 @@ position_var_val
 // if (Bool, Position, Position)
 // ? Position ? Bool : 0
 position_condition
-	[const Corpus2::Tagset& tagset, Variables& vars]
+	[ParsingScope& scope]
 	returns [boost::shared_ptr<Function<Position> > op]
 {
 	boost::shared_ptr<Function<Bool> > test;
 	boost::shared_ptr<Function<Position> > p_true, p_false;
 }
-	: "if" LPAREN test  = bool_operator [tagset, vars] COMMA 
-							p_true  = position_operator [tagset, vars] 
-							(COMMA p_false = position_operator [tagset, vars])? 
+	: "if" LPAREN test  = bool_operator [scope] COMMA 
+							p_true  = position_operator [scope] 
+							(COMMA p_false = position_operator [scope])? 
 	RPAREN {
 		if (p_false) {
 			op.reset(new Conditional<Position>(test, p_true, p_false));
@@ -889,9 +891,9 @@ position_condition
 		}
 	}
 	| Q_MARK 
-			p_true = position_operator [tagset, vars]
+			p_true = position_operator [scope]
 		Q_MARK 
-			test = bool_operator [tagset, vars] {
+			test = bool_operator [scope] {
 			op.reset(new Conditional<Position>(test, p_true));
 		}
 ;
@@ -899,12 +901,12 @@ position_condition
 // ----------------------------------------------------------------------------
 // Taking position of a first token in a match
 // first(Match)
-position_first_token [const Corpus2::Tagset& tagset, Variables& vars]
+position_first_token [ParsingScope& scope]
 	returns [boost::shared_ptr<Function<Position> > ret]
 {
 	boost::shared_ptr<Function<Match> > m;
 }
-	: "first" LPAREN m = match_operator [tagset, vars] RPAREN {
+	: "first" LPAREN m = match_operator [scope] RPAREN {
 		ret.reset(new FirstToken(m));
 	}
 ;
@@ -912,12 +914,12 @@ position_first_token [const Corpus2::Tagset& tagset, Variables& vars]
 // ----------------------------------------------------------------------------
 // Taking position of a first token in a match
 // last(Match)
-position_last_token [const Corpus2::Tagset& tagset, Variables& vars]
+position_last_token [ParsingScope& scope]
 	returns [boost::shared_ptr<Function<Position> > ret]
 {
 	boost::shared_ptr<Function<Match> > m;
 }
-	: "last" LPAREN m = match_operator [tagset, vars] RPAREN {
+	: "last" LPAREN m = match_operator [scope] RPAREN {
 		ret.reset(new LastToken(m));
 	}
 ;
@@ -926,28 +928,28 @@ position_last_token [const Corpus2::Tagset& tagset, Variables& vars]
 // String operator
 // Returns boost::shared_ptr<Function<StrSet> >
 ///////////////////////////////////////////////////////////////////////////////
-strset_operator [const Corpus2::Tagset& tagset, Variables& vars]
+strset_operator [ParsingScope& scope]
 	returns [boost::shared_ptr<Function<StrSet> > ret]
-	: ret = strset_orth      [tagset, vars] 
-	| ret = strset_base      [tagset, vars]
-	| ret = strset_lower     [tagset, vars] 
-	| ret = strset_upper     [tagset, vars]
-	| ret = strset_affix     [tagset, vars] 
-	| ret = strset_var_val   [tagset, vars] 
-	| ret = strset_condition [tagset, vars]
+	: ret = strset_orth      [scope] 
+	| ret = strset_base      [scope]
+	| ret = strset_lower     [scope] 
+	| ret = strset_upper     [scope]
+	| ret = strset_affix     [scope] 
+	| ret = strset_var_val   [scope] 
+	| ret = strset_condition [scope]
 	//
-	| LPAREN ret = strset_operator [tagset, vars] RPAREN
+	| LPAREN ret = strset_operator [scope] RPAREN
 ;
 
 // ----------------------------------------------------------------------------
 // Orth operator.
 strset_orth 
-	[const Corpus2::Tagset& tagset, Variables& vars]
+	[ParsingScope& scope]
 	returns [boost::shared_ptr<Function<StrSet> > ret]
 {
 	boost::shared_ptr<Function<Position> > pos;
 }
-	: "orth" LBRACKET pos = position_operator [tagset, vars] RBRACKET { 
+	: "orth" LBRACKET pos = position_operator [scope] RBRACKET { 
 			ret.reset(new GetOrth(pos));
 	}
 ;
@@ -955,12 +957,12 @@ strset_orth
 // ----------------------------------------------------------------------------
 // Base operator.
 strset_base 
-	[const Corpus2::Tagset& tagset, Variables& vars]
+	[ParsingScope& scope]
 	returns [boost::shared_ptr<Function<StrSet> > ret]
 {
 	boost::shared_ptr<Function<Position> > pos;
 }
-	: "base" LBRACKET pos = position_operator [tagset, vars] RBRACKET { 
+	: "base" LBRACKET pos = position_operator [scope] RBRACKET { 
 		ret.reset(new GetLemmas(pos));
 	}
 ;
@@ -968,12 +970,12 @@ strset_base
 // ----------------------------------------------------------------------------
 // Lower operator.
 strset_lower 
-	[const Corpus2::Tagset& tagset, Variables& vars]
+	[ParsingScope& scope]
 	returns [boost::shared_ptr<Function<StrSet> > ret]
 {
 	boost::shared_ptr<Function<StrSet> > o_ret;
 }
-	: "lower" LPAREN o_ret = strset_operator [tagset, vars] RPAREN {
+	: "lower" LPAREN o_ret = strset_operator [scope] RPAREN {
 		ret.reset(new ToLower(o_ret));
 	}
 ;
@@ -981,12 +983,12 @@ strset_lower
 // ----------------------------------------------------------------------------
 // Upper operator.
 strset_upper 
-	[const Corpus2::Tagset& tagset, Variables& vars]
+	[ParsingScope& scope]
 	returns [boost::shared_ptr<Function<StrSet> > ret]
 {
 	boost::shared_ptr<Function<StrSet> > o_ret;
 }
-	: "upper" LPAREN o_ret = strset_operator [tagset, vars] RPAREN {
+	: "upper" LPAREN o_ret = strset_operator [scope] RPAREN {
 		ret.reset(new ToUpper(o_ret));
 	}
 ;
@@ -994,14 +996,14 @@ strset_upper
 // ----------------------------------------------------------------------------
 // Affix operator.
 strset_affix 
-	[const Corpus2::Tagset& tagset, Variables& vars]
+	[ParsingScope& scope]
 	returns [boost::shared_ptr<Function<StrSet> > ret]
 {
 	int offset = 0;
 	boost::shared_ptr<Function<StrSet> > o_ret;
 }
 	: "affix" LPAREN 
-			o_ret = strset_operator [tagset, vars] COMMA offset = number 
+			o_ret = strset_operator [scope] COMMA offset = number 
 		RPAREN {
 			ret.reset(new Affix(o_ret, offset));
 		}
@@ -1010,10 +1012,10 @@ strset_affix
 // ----------------------------------------------------------------------------
 // A wrapper for strset value and strset variable
 strset_var_val
-	[const Corpus2::Tagset& /*tagset*/, Variables& vars]
+	[ParsingScope& scope]
 	returns [boost::shared_ptr<Function<StrSet> > op]
 	: op = strset_value 
-	| op = strset_variable [vars]
+	| op = strset_variable [scope.variables()]
 ;
 
 // ----------------------------------------------------------------------------
@@ -1021,15 +1023,15 @@ strset_var_val
 // if (Bool, StrSet, StrSet)
 // ? StrSet ? Bool : []
 strset_condition
-	[const Corpus2::Tagset& tagset, Variables& vars]
+	[ParsingScope& scope]
 	returns [boost::shared_ptr<Function<StrSet> > op]
 {
 	boost::shared_ptr<Function<Bool> > test;
 	boost::shared_ptr<Function<StrSet> > p_true, p_false;
 }
-	: "if" LPAREN test  = bool_operator [tagset, vars] COMMA 
-							p_true  = strset_operator   [tagset, vars] 
-							(COMMA p_false = strset_operator [tagset, vars])? 
+	: "if" LPAREN test  = bool_operator [scope] COMMA 
+							p_true  = strset_operator   [scope] 
+							(COMMA p_false = strset_operator [scope])? 
 	RPAREN {
 		if (p_false) {
 			op.reset(new Conditional<StrSet>(test, p_true, p_false));
@@ -1039,9 +1041,9 @@ strset_condition
 		}
 	}
 	| Q_MARK 
-			p_true = strset_operator [tagset, vars]
+			p_true = strset_operator [scope]
 		Q_MARK 
-			test = bool_operator [tagset, vars] {
+			test = bool_operator [scope] {
 			op.reset(new Conditional<StrSet>(test, p_true));
 		}
 ;
@@ -1051,42 +1053,42 @@ strset_condition
 // Returns boost::shared_ptr<Function<Bool> >
 ///////////////////////////////////////////////////////////////////////////////
 bool_operator
-	[const Corpus2::Tagset& tagset, Variables& vars]
+	[ParsingScope& scope]
 	returns [boost::shared_ptr<Function<Bool> > ret]
-	: ret = bool_and        [tagset, vars]  
-	| ret = bool_or         [tagset, vars]  
-	| ret = bool_nor        [tagset, vars]  
-	| ret = bool_var_val    [tagset, vars]	
-	| ret = bool_regex      [tagset, vars]
-	| ret = bool_inout      [tagset, vars]
-	| ret = bool_condition  [tagset, vars]
+	: ret = bool_and        [scope]  
+	| ret = bool_or         [scope]  
+	| ret = bool_nor        [scope]  
+	| ret = bool_var_val    [scope]	
+	| ret = bool_regex      [scope]
+	| ret = bool_inout      [scope]
+	| ret = bool_condition  [scope]
 	// setvar:
-	| ret = setvar_operator [tagset, vars]
+	| ret = setvar_operator [scope]
 	// empty
-	| ret = empty_operator  [tagset, vars]
+	| ret = empty_operator  [scope]
 	// equal/in/inter:
-	| ret = equal_operator  [tagset, vars]
-	| ret = in_operator     [tagset, vars]
-	| ret = inter_operator  [tagset, vars]
+	| ret = equal_operator  [scope]
+	| ret = in_operator     [scope]
+	| ret = inter_operator  [scope]
 	// iterations
-	| ret = bool_iteration  [tagset, vars]
+	| ret = bool_iteration  [scope]
 	// agreement
-	| ret = bool_agreement  [tagset, vars]
+	| ret = bool_agreement  [scope]
 	//
-	| ret = bool_phrase     [tagset, vars]
+	| ret = bool_phrase     [scope]
 	// annotation
-	| ret = bool_ann        [tagset, vars]
-	| ret = bool_annsub     [tagset, vars]
+	| ret = bool_ann        [scope]
+	| ret = bool_annsub     [scope]
 	// debug operators
-	| ret = debug_print_operator [tagset, vars]
+	| ret = debug_print_operator [scope]
 	//
-	| LPAREN ret = bool_operator [tagset, vars] RPAREN
+	| LPAREN ret = bool_operator [scope] RPAREN
 ;
 
 // ----------------------------------------------------------------------------
 // comma-separated predicates (bool operators)
 bool_operator_comma_sep
-	[const Corpus2::Tagset& tagset, Variables& vars]
+	[ParsingScope& scope]
 	returns 
 		[boost::shared_ptr<std::vector<boost::shared_ptr<Function<Bool> > > > ret_v]
 {
@@ -1095,11 +1097,11 @@ bool_operator_comma_sep
 		new std::vector<boost::shared_ptr<Function<Bool> > >
 	);
 }
-	: pred = bool_operator [tagset, vars] { 
+	: pred = bool_operator [scope] { 
 		ret_v->push_back(pred);
 	} 
 	(
-		COMMA pred = bool_operator [tagset, vars] {
+		COMMA pred = bool_operator [scope] {
 			ret_v->push_back(pred);
 		}
 	)*
@@ -1108,12 +1110,12 @@ bool_operator_comma_sep
 // ----------------------------------------------------------------------------
 // And operator.
 bool_and 
-	[const Corpus2::Tagset& tagset, Variables& vars]
+	[ParsingScope& scope]
 	returns [boost::shared_ptr<Function<Bool> > op]
 {
 	boost::shared_ptr<std::vector<boost::shared_ptr<Function<Bool> > > > ret_v;
 }
-	: "and" LPAREN ret_v = bool_operator_comma_sep [tagset, vars] RPAREN {
+	: "and" LPAREN ret_v = bool_operator_comma_sep [scope] RPAREN {
 			op.reset(new And(ret_v));
 	}
 ;
@@ -1121,12 +1123,12 @@ bool_and
 // ----------------------------------------------------------------------------
 // Or operator
 bool_or
-	[const Corpus2::Tagset& tagset, Variables& vars]
+	[ParsingScope& scope]
 	returns [boost::shared_ptr<Function<Bool> > op]
 {
 	boost::shared_ptr<std::vector<boost::shared_ptr<Function<Bool> > > > ret_v;
 }
-	: "or" LPAREN ret_v = bool_operator_comma_sep [tagset, vars] RPAREN {
+	: "or" LPAREN ret_v = bool_operator_comma_sep [scope] RPAREN {
 			op.reset(new Or(ret_v));
 	}
 ;
@@ -1134,12 +1136,12 @@ bool_or
 // ----------------------------------------------------------------------------
 // Nor/Not operator
 bool_nor
-	[const Corpus2::Tagset& tagset, Variables& vars]
+	[ParsingScope& scope]
 	returns [boost::shared_ptr<Function<Bool> > op]
 {
 	boost::shared_ptr<std::vector<boost::shared_ptr<Function<Bool> > > > ret_v;
 }
-	: "not" LPAREN ret_v = bool_operator_comma_sep [tagset, vars] RPAREN {
+	: "not" LPAREN ret_v = bool_operator_comma_sep [scope] RPAREN {
 			op.reset(new Nor(ret_v));
 	}
 ;
@@ -1147,23 +1149,23 @@ bool_nor
 // ----------------------------------------------------------------------------
 // Wrapper for bool value and bool variable
 bool_var_val
-	[const Corpus2::Tagset& /*tagset*/, Variables& vars]
+	[ParsingScope& scope]
 	returns [boost::shared_ptr<Function<Bool> > op]
 	: op = bool_value 
-	| op = bool_variable [vars]
+	| op = bool_variable [scope.variables()]
 ;
 
 // ----------------------------------------------------------------------------
 // Regex operator
 bool_regex
-	[const Corpus2::Tagset& tagset, Variables& vars]
+	[ParsingScope& scope]
 	returns [boost::shared_ptr<Function<Bool> > op]
 {
 	boost::shared_ptr<Function<StrSet> > expr;
 }
 	: "regex" 
 		LPAREN 
-			expr = strset_operator [tagset, vars] COMMA reg: STRING 
+			expr = strset_operator [scope] COMMA reg: STRING 
 		RPAREN {
 			op.reset(new Regex(expr, token_ref_to_ustring(reg)));
 		}
@@ -1172,15 +1174,15 @@ bool_regex
 // ----------------------------------------------------------------------------
 // Input/output operator
 bool_inout
-	[const Corpus2::Tagset& tagset, Variables& vars]
+	[ParsingScope& scope]
 	returns [boost::shared_ptr<Function<Bool> > op]
 {
 	boost::shared_ptr<Function<Position> > ret_pos;
 }
-	: "inside"  LPAREN ret_pos = position_operator [tagset, vars] RPAREN {
+	: "inside"  LPAREN ret_pos = position_operator [scope] RPAREN {
 		op.reset(new IsInside(ret_pos));
 	}
-	| "outside" LPAREN ret_pos = position_operator [tagset, vars] RPAREN {
+	| "outside" LPAREN ret_pos = position_operator [scope] RPAREN {
 		op.reset(new IsOutside(ret_pos));
 	}
 ;
@@ -1189,14 +1191,14 @@ bool_inout
 // if (Bool, Bool, Bool)
 // ? Bool ? Bool : False
 bool_condition
-	[const Corpus2::Tagset& tagset, Variables& vars]
+	[ParsingScope& scope]
 	returns [boost::shared_ptr<Function<Bool> > op]
 {
 	boost::shared_ptr<Function<Bool> > test, p_true, p_false;
 }
-	: "if" LPAREN test = bool_operator [tagset, vars] COMMA 
-							p_true = bool_operator [tagset, vars] 
-							(COMMA p_false = bool_operator [tagset, vars])? 
+	: "if" LPAREN test = bool_operator [scope] COMMA 
+							p_true = bool_operator [scope] 
+							(COMMA p_false = bool_operator [scope])? 
 	RPAREN {
 		if (p_false) {
 			op.reset(new Conditional<Bool>(test, p_true, p_false));
@@ -1206,9 +1208,9 @@ bool_condition
 		}
 	}
 	| Q_MARK 
-			p_true = bool_operator [tagset, vars]
+			p_true = bool_operator [scope]
 		Q_MARK 
-			test = bool_operator [tagset, vars] {
+			test = bool_operator [scope] {
 			op.reset(new Conditional<Bool>(test, p_true));
 		}
 ;
@@ -1216,7 +1218,7 @@ bool_condition
 // ----------------------------------------------------------------------------
 // Equal operator
 equal_operator
-	[const Corpus2::Tagset& tagset, Variables& vars]
+	[ParsingScope& scope]
 	returns [boost::shared_ptr<Function<Bool> > op]
 {
 	boost::shared_ptr<Function<TSet> > t1, t2;
@@ -1226,33 +1228,33 @@ equal_operator
 }
 	: "equal" LPAREN
 	(
-		(position_operator [tagset, vars]) =>
+		(position_operator [scope]) =>
 		(
-			p1 = position_operator [tagset, vars] COMMA 
-			p2 = position_operator [tagset, vars] {
+			p1 = position_operator [scope] COMMA 
+			p2 = position_operator [scope] {
 				op.reset(new Equals<Position>(p1, p2));
 			}
 		)
 	|
-		(symset_operator [tagset, vars]) =>
+		(symset_operator [scope]) =>
 		(
-			t1 = symset_operator [tagset, vars] COMMA  
-			t2 = symset_operator [tagset, vars] {
+			t1 = symset_operator [scope] COMMA  
+			t2 = symset_operator [scope] {
 				op.reset(new Equals<TSet>(t1, t2));
 			}
 		)
 	|
-		(strset_operator [tagset, vars]) =>
+		(strset_operator [scope]) =>
 		(
-			s1 = strset_operator [tagset, vars] COMMA  
-			s2 = strset_operator [tagset, vars] {
+			s1 = strset_operator [scope] COMMA  
+			s2 = strset_operator [scope] {
 				op.reset(new Equals<StrSet>(s1, s2));
 			}
 		)
 	|
 		(
-			b1 = bool_operator [tagset, vars] COMMA
-			b2 = bool_operator [tagset, vars] {
+			b1 = bool_operator [scope] COMMA
+			b2 = bool_operator [scope] {
 				op.reset(new Equals<Bool>(b1, b2));
 			}
 		)
@@ -1263,7 +1265,7 @@ equal_operator
 // ----------------------------------------------------------------------------
 // In operator
 in_operator
-	[const Corpus2::Tagset& tagset, Variables& vars]
+	[ParsingScope& scope]
 	returns [boost::shared_ptr<Function<Bool> > op]
 {
 	boost::shared_ptr<Function<TSet> > t1, t2;
@@ -1272,17 +1274,17 @@ in_operator
 :
 	"in" LPAREN
 	(
-		(symset_operator [tagset, vars]) =>
+		(symset_operator [scope]) =>
 		(
-			t1 = symset_operator [tagset, vars] COMMA 
-			t2 = symset_operator [tagset, vars] {
+			t1 = symset_operator [scope] COMMA 
+			t2 = symset_operator [scope] {
 				op.reset(new IsSubsetOf<TSet>(t1, t2));
 			}
 		)
 		|
 		(
-			s1 = strset_operator [tagset, vars] COMMA
-			s2 = strset_operator [tagset, vars] {
+			s1 = strset_operator [scope] COMMA
+			s2 = strset_operator [scope] {
 				op.reset(new IsSubsetOf<StrSet>(s1, s2));
 			}
 		)
@@ -1292,7 +1294,7 @@ in_operator
 // ----------------------------------------------------------------------------
 // Inter operator
 inter_operator
-	[const Corpus2::Tagset& tagset, Variables& vars]
+	[ParsingScope& scope]
 	returns [boost::shared_ptr<Function<Bool> > op]
 {
 	boost::shared_ptr<Function<TSet> > t1, t2;
@@ -1301,17 +1303,17 @@ inter_operator
 	:
 	"inter" LPAREN
 	(
-		(symset_operator [tagset, vars]) =>
+		(symset_operator [scope]) =>
 		(
-			t1 = symset_operator [tagset, vars] COMMA  
-			t2 = symset_operator [tagset, vars]  {
+			t1 = symset_operator [scope] COMMA  
+			t2 = symset_operator [scope]  {
 				op.reset(new Intersects<TSet>(t1, t2));
 			}
 		)
 	|
 		(
-			s1 = strset_operator [tagset, vars] COMMA  
-			s2 = strset_operator [tagset, vars]  {
+			s1 = strset_operator [scope] COMMA  
+			s2 = strset_operator [scope]  {
 				op.reset(new Intersects<StrSet>(s1, s2));
 			}
 		)
@@ -1322,7 +1324,7 @@ inter_operator
 // ----------------------------------------------------------------------------
 // Annotation operator.
 bool_ann
-	[const Corpus2::Tagset& tagset, Variables& vars]
+	[ParsingScope& scope]
 	returns [boost::shared_ptr<Function<Bool> > op]
 {
 	boost::shared_ptr< Function<Match> > match_from;
@@ -1330,8 +1332,8 @@ bool_ann
 	std::string chan_name;
 }
 	: "ann" LPAREN
-			match_from = match_operator [tagset, vars] COMMA
-			(match_to  = match_operator [tagset, vars] COMMA)?
+			match_from = match_operator [scope] COMMA
+			(match_to  = match_operator [scope] COMMA)?
 			name : STRING
 		RPAREN {
 			if (match_to) {
@@ -1346,7 +1348,7 @@ bool_ann
 // ----------------------------------------------------------------------------
 // Annotation-sub operator.
 bool_annsub
-	[const Corpus2::Tagset& tagset, Variables& vars]
+	[ParsingScope& scope]
 	returns [boost::shared_ptr<Function<Bool> > op]
 {
 	boost::shared_ptr< Function<Match> > match_from;
@@ -1354,8 +1356,8 @@ bool_annsub
 	std::string chan_name;
 }
 	: "annsub" LPAREN
-		match_from = match_operator [tagset, vars] COMMA
-		(match_to = match_operator [tagset, vars] COMMA)?
+		match_from = match_operator [scope] COMMA
+		(match_to = match_operator [scope] COMMA)?
 		name : STRING
 		RPAREN
 		{
@@ -1370,43 +1372,43 @@ bool_annsub
 // ----------------------------------------------------------------------------
 // Debug printing:
 debug_print_operator
-	[const Corpus2::Tagset& tagset, Variables& vars]
+	[ParsingScope& scope]
 	returns [boost::shared_ptr<Function<Bool> > ret]
 {
 	boost::shared_ptr<FunctionBase> v;
 }
 	: "debug" LPAREN
 	(
-		(position_operator [tagset, vars]) =>
+		(position_operator [scope]) =>
 		(
-			v = position_operator [tagset, vars] {
+			v = position_operator [scope] {
 				ret.reset(new DebugPrint(v));
 			}
 		)
 	|
-		(symset_operator [tagset, vars]) =>
+		(symset_operator [scope]) =>
 		(
-			v = symset_operator [tagset, vars] {
+			v = symset_operator [scope] {
 				ret.reset(new DebugPrint(v));
 			}
 		)
 	|
-		(strset_operator [tagset, vars]) =>
+		(strset_operator [scope]) =>
 		(
-			v = strset_operator [tagset, vars] {
+			v = strset_operator [scope] {
 				ret.reset(new DebugPrint(v));
 			}
 		)
 	|
-		(bool_operator [tagset, vars]) =>
+		(bool_operator [scope]) =>
 		(
-			v = bool_operator [tagset, vars] {
+			v = bool_operator [scope] {
 				ret.reset(new DebugPrint(v));
 			}
 		)
 	|
 		(
-			v = match_operator [tagset, vars] {
+			v = match_operator [scope] {
 				ret.reset(new DebugPrint(v));
 			}
 		)
@@ -1417,7 +1419,7 @@ debug_print_operator
 // ----------------------------------------------------------------------------
 // Iterations:
 bool_iteration
-	[const Corpus2::Tagset& tagset, Variables& vars]
+	[ParsingScope& scope]
 	returns [boost::shared_ptr<Function<Bool> > ret]
 {
 	int min_match = 0;
@@ -1426,36 +1428,36 @@ bool_iteration
 	boost::shared_ptr<VariableAccessor<Position> > pacc;
 }
 	: "only" LPAREN 
-			lpos = position_operator [tagset, vars] COMMA 
-			rpos = position_operator [tagset, vars] COMMA
-			pacc = position_variable_acc [vars]     COMMA
-			expr = bool_operator     [tagset, vars]
+			lpos = position_operator [scope] COMMA 
+			rpos = position_operator [scope] COMMA
+			pacc = position_variable_acc [scope.variables()]     COMMA
+			expr = bool_operator     [scope]
 		RPAREN {
 			ret.reset(new Only(lpos, rpos, *pacc, expr));
 		}
 
 	| "atleast" LPAREN
-			lpos = position_operator [tagset, vars] COMMA 
-			rpos = position_operator [tagset, vars] COMMA
-			pacc = position_variable_acc [vars]     COMMA
-			expr = bool_operator     [tagset, vars] COMMA
+			lpos = position_operator [scope] COMMA 
+			rpos = position_operator [scope] COMMA
+			pacc = position_variable_acc [scope.variables()]     COMMA
+			expr = bool_operator     [scope] COMMA
 			min_match = number
 		RPAREN {
 			ret.reset(new AtLeast(lpos, rpos, *pacc, expr, min_match));
 		}
 	| "llook" LPAREN //note inverted rpos/lpos order
-			rpos = position_operator [tagset, vars] COMMA 
-			lpos = position_operator [tagset, vars] COMMA
-			pacc = position_variable_acc [vars]     COMMA
-			expr = bool_operator     [tagset, vars] 
+			rpos = position_operator [scope] COMMA 
+			lpos = position_operator [scope] COMMA
+			pacc = position_variable_acc [scope.variables()]     COMMA
+			expr = bool_operator     [scope] 
 		RPAREN {
 			ret.reset(new LeftLook(lpos, rpos, *pacc, expr));
 		}
 	| "rlook" LPAREN
-			lpos = position_operator [tagset, vars] COMMA 
-			rpos = position_operator [tagset, vars] COMMA
-			pacc = position_variable_acc [vars]     COMMA
-			expr = bool_operator     [tagset, vars] 
+			lpos = position_operator [scope] COMMA 
+			rpos = position_operator [scope] COMMA
+			pacc = position_variable_acc [scope.variables()]     COMMA
+			expr = bool_operator     [scope] 
 		RPAREN {
 			ret.reset(new RightLook(lpos, rpos, *pacc, expr));
 		}
@@ -1464,76 +1466,76 @@ bool_iteration
 // ----------------------------------------------------------------------------
 // Agreement operator: agr, agrpp, wagr
 bool_agreement
-	[const Corpus2::Tagset& tagset, Variables& vars]
+	[ParsingScope& scope]
 	returns [boost::shared_ptr<Function<Bool> > ret]
 {
 	boost::shared_ptr<Function<TSet> > expr;
 	boost::shared_ptr<Function<Position> > lpos, rpos;
 }
 	: "agr"   LPAREN 
-			lpos = position_operator [tagset, vars] COMMA 
-			rpos = position_operator [tagset, vars] COMMA 
-			expr = symset_operator [tagset, vars]
+			lpos = position_operator [scope] COMMA 
+			rpos = position_operator [scope] COMMA 
+			expr = symset_operator [scope]
 		RPAREN {
-			ret.reset(new StrongAgreement(lpos, rpos, expr, tagset));
+			ret.reset(new StrongAgreement(lpos, rpos, expr, scope.tagset()));
 		}
 	| "agrpp" LPAREN
-			lpos = position_operator [tagset, vars] COMMA 
-			rpos = position_operator [tagset, vars] COMMA 
-			expr = symset_operator [tagset, vars]
+			lpos = position_operator [scope] COMMA 
+			rpos = position_operator [scope] COMMA 
+			expr = symset_operator [scope]
 		RPAREN {
-			ret.reset(new PointAgreement(lpos, rpos, expr, tagset));
+			ret.reset(new PointAgreement(lpos, rpos, expr, scope.tagset()));
 		}
 	| "wagr"  LPAREN
-			lpos = position_operator [tagset, vars] COMMA 
-			rpos = position_operator [tagset, vars] COMMA 
-			expr = symset_operator [tagset, vars]
+			lpos = position_operator [scope] COMMA 
+			rpos = position_operator [scope] COMMA 
+			expr = symset_operator [scope]
 		RPAREN {
-			ret.reset(new WeakAgreement(lpos, rpos, expr, tagset));
+			ret.reset(new WeakAgreement(lpos, rpos, expr, scope.tagset()));
 		}
 ;
 
 // ----------------------------------------------------------------------------
 // Parse operator on L1 level
 bool_phrase
-	[const Corpus2::Tagset& tagset, Variables& vars]
+	[ParsingScope& scope]
 	returns [boost::shared_ptr<Function<Bool> > ret]
-	: ret = bool_phrase_annotation [tagset, vars]
-	| ret = bool_phrase_iteration  [tagset, vars]
+	: ret = bool_phrase_annotation [scope]
+	| ret = bool_phrase_iteration  [scope]
 ;
 
 // ----------------------------------------------------------------------------
 // Annotation operator: phrase, phrase_beg, phrase_end, phrase_whole, phrase_pp
 bool_phrase_annotation
-	[const Corpus2::Tagset& tagset, Variables& vars]
+	[ParsingScope& scope]
 	returns [boost::shared_ptr<Function<Bool> > ret]
 {
 	boost::shared_ptr<Function<Position> > lpos, rpos;
 }
 	: "phrase" LPAREN 
-			lpos = position_operator [tagset, vars] COMMA n1: STRING 
+			lpos = position_operator [scope] COMMA n1: STRING 
 		RPAREN {
 			// TODO
 		}
 	| "phrase_beg" LPAREN 
-			lpos = position_operator [tagset, vars] COMMA n2: STRING 
+			lpos = position_operator [scope] COMMA n2: STRING 
 		RPAREN {
 			// TODO
 		}
 	| "phrase_end" LPAREN 
-			lpos = position_operator [tagset, vars] COMMA n3: STRING 
+			lpos = position_operator [scope] COMMA n3: STRING 
 		RPAREN {
 			// TODO
 		}
 	| "phrase_whole" LPAREN 
-			lpos = position_operator [tagset, vars] COMMA 
-			rpos = position_operator [tagset, vars] COMMA n4: STRING 
+			lpos = position_operator [scope] COMMA 
+			rpos = position_operator [scope] COMMA n4: STRING 
 		RPAREN {
 			// TODO
 		}
 	| "phrase_pp" LPAREN 
-			lpos = position_operator [tagset, vars] COMMA 
-			rpos = position_operator [tagset, vars] COMMA n5: STRING 
+			lpos = position_operator [scope] COMMA 
+			rpos = position_operator [scope] COMMA n5: STRING 
 		RPAREN {
 			// TODO
 		}
@@ -1542,22 +1544,22 @@ bool_phrase_annotation
 // ----------------------------------------------------------------------------
 // Phrase iteration operator: lphrase, rphrase
 bool_phrase_iteration
-	[const Corpus2::Tagset& tagset, Variables& vars]
+	[ParsingScope& scope]
 	returns [boost::shared_ptr<Function<Bool> > ret]
 {
 	boost::shared_ptr<Function<Position> > position;
 	boost::shared_ptr<VarGetter<Position> > var_position;
 }
 	: "lphrase" LPAREN
-			position     = position_operator [tagset, vars] COMMA
-			var_position = position_variable [vars]         COMMA
+			position     = position_operator [scope] COMMA
+			var_position = position_variable [scope.variables()]         COMMA
 			n1: STRING
 		RPAREN {
 			// TODO
 		}
 	| "rphrase" LPAREN 
-			position     = position_operator [tagset, vars] COMMA
-			var_position = position_variable [vars]         COMMA
+			position     = position_operator [scope] COMMA
+			var_position = position_variable [scope.variables()]         COMMA
 			n2: STRING
 		RPAREN {
 			// TODO
@@ -1570,14 +1572,14 @@ bool_phrase_iteration
 // Returns boost::shared_ptr<Function<Bool> >
 // ----------------------------------------------------------------------------
 setvar_operator 
-	[const Corpus2::Tagset& tagset, Variables& vars]
+	[ParsingScope& scope]
 	returns [boost::shared_ptr<Function<Bool> > ret]
 	: "setvar" LPAREN
 	  (
-		  ret = position_setvar [tagset, vars]
-		| ret = bool_setvar     [tagset, vars]
-		| ret = strset_setvar   [tagset, vars]
-		| ret = symset_setvar   [tagset, vars]
+		  ret = position_setvar [scope]
+		| ret = bool_setvar     [scope]
+		| ret = strset_setvar   [scope]
+		| ret = symset_setvar   [scope]
 	  )
 	  RPAREN
 ;
@@ -1585,15 +1587,15 @@ setvar_operator
 // ----------------------------------------------------------------------------
 // Setvar for position
 position_setvar 
-	[const Corpus2::Tagset& tagset, Variables& vars]
+	[ParsingScope& scope]
 	returns [boost::shared_ptr<Function<Bool> > op]
 {
 	boost::shared_ptr<Function<Position> > ret_op;
 	boost::shared_ptr<VariableAccessor<Position> > ret_acc;
 }
-	:	ret_acc = position_variable_acc [vars]
+	:	ret_acc = position_variable_acc [scope.variables()]
 		COMMA
-		ret_op  = position_operator [tagset, vars] {
+		ret_op  = position_operator [scope] {
 			op.reset(new VarSetter<Position>(*ret_acc, ret_op));
 		}
 ;
@@ -1601,15 +1603,15 @@ position_setvar
 // ----------------------------------------------------------------------------
 // Setvar for bool
 bool_setvar 
-	[const Corpus2::Tagset& tagset, Variables& vars]
+	[ParsingScope& scope]
 	returns [boost::shared_ptr<Function<Bool> > op]
 {
 	boost::shared_ptr<Function<Bool> > ret_op;
 	boost::shared_ptr<VariableAccessor<Bool> > ret_acc;
 }
-	:	ret_acc = bool_variable_acc [vars]
+	:	ret_acc = bool_variable_acc [scope.variables()]
 		COMMA
-		ret_op  = bool_operator [tagset, vars] {
+		ret_op  = bool_operator [scope] {
 			op.reset(new VarSetter<Bool>(*ret_acc, ret_op));
 		}
 ;
@@ -1617,15 +1619,15 @@ bool_setvar
 // ----------------------------------------------------------------------------
 // Setvar for strset
 strset_setvar
-	[const Corpus2::Tagset& tagset, Variables& vars]
+	[ParsingScope& scope]
 	returns [boost::shared_ptr<Function<Bool> > op]
 {
 	boost::shared_ptr<Function<StrSet> > ret_op;
 	boost::shared_ptr<VariableAccessor<StrSet> > ret_acc;
 }
-	: ret_acc = strset_variable_acc [vars]
+	: ret_acc = strset_variable_acc [scope.variables()]
 	  COMMA 
-		ret_op  = strset_operator [tagset, vars] {
+		ret_op  = strset_operator [scope] {
 			op.reset(new VarSetter<StrSet>(*ret_acc, ret_op));
 		}
 ;
@@ -1633,15 +1635,15 @@ strset_setvar
 // ----------------------------------------------------------------------------
 // Setvar for symset
 symset_setvar 
-	[const Corpus2::Tagset& tagset, Variables& vars]
+	[ParsingScope& scope]
 	returns [boost::shared_ptr<Function<Bool> > op]
 {
 	boost::shared_ptr<Function<TSet> > ret_op;
 	boost::shared_ptr<VariableAccessor<TSet> > ret_acc;
 }
-	: ret_acc = symset_variable_acc [vars]
+	: ret_acc = symset_variable_acc [scope.variables()]
 	  COMMA 
-	  ret_op  = symset_operator [tagset, vars] {
+	  ret_op  = symset_operator [scope] {
 			op.reset(new VarSetter<TSet>(*ret_acc, ret_op));
 		}
 ;
@@ -1651,32 +1653,32 @@ symset_setvar
 // Returns boost::shared_ptr<Function<Bool> > 
 //----------------------------------------------------------------------------
 empty_operator
-	[const Corpus2::Tagset& tagset, Variables& vars]
+	[ParsingScope& scope]
 	returns [boost::shared_ptr<Function<Bool> > op]
 	: "empty" LPAREN
 		(
-			  (match_empty[tagset, vars]) => 
+			  (match_empty[scope]) => 
 				(
-					op = match_empty  [tagset, vars]
+					op = match_empty  [scope]
 				)
-			| (symset_empty [tagset, vars]) => 
+			| (symset_empty [scope]) => 
 				(
-					op = symset_empty [tagset, vars]
+					op = symset_empty [scope]
 				)
-			| op = strset_empty [tagset, vars]
+			| op = strset_empty [scope]
 		)
 	RPAREN
 ;
 
 /*
 empty_operator
-	[const Corpus2::Tagset& tagset, Variables& vars]
+	[ParsingScope& scope]
 	returns [boost::shared_ptr<Function<Bool> > op]
 	: "empty" LPAREN
 	(
-		  op = match_empty  [tagset, vars]
-		| op = symset_empty [tagset, vars]
-		| op = strset_empty [tagset, vars]
+		  op = match_empty  [scope]
+		| op = symset_empty [scope]
+		| op = strset_empty [scope]
 	)
 	RPAREN
 ;
@@ -1686,12 +1688,12 @@ empty_operator
 // match empty() operator
 // Returns boost::shared_ptr<Function<Bool> > 
 match_empty
-	[const Corpus2::Tagset& tagset, Variables& vars]
+	[ParsingScope& scope]
 	returns [boost::shared_ptr<Function<Bool> > op]
 {
 	boost::shared_ptr<Function<Match> > arg;
 }
-	: arg = match_operator [tagset, vars] {
+	: arg = match_operator [scope] {
 		op.reset(new IsEmpty<Match>(arg));
 	}
 ;
@@ -1700,12 +1702,12 @@ match_empty
 // SymSet empty() operator
 // Returns boost::shared_ptr<Function<Bool> > 
 symset_empty
-	[const Corpus2::Tagset& tagset, Variables& vars]
+	[ParsingScope& scope]
 	returns [boost::shared_ptr<Function<Bool> > op]
 {
 	boost::shared_ptr<Function<TSet> > arg;
 }
-	: arg = symset_operator [tagset, vars] {
+	: arg = symset_operator [scope] {
 		op.reset(new IsEmpty<TSet>(arg));
 	}
 ;
@@ -1714,12 +1716,12 @@ symset_empty
 // Strset empty() operator
 // Returns boost::shared_ptr<Function<Bool> > 
 strset_empty
-	[const Corpus2::Tagset& tagset, Variables& vars]
+	[ParsingScope& scope]
 	returns [boost::shared_ptr<Function<Bool> > op]
 {
 	boost::shared_ptr<Function<StrSet> > arg;
 }
-	: arg = strset_operator [tagset, vars] {
+	: arg = strset_operator [scope] {
 		op.reset(new IsEmpty<StrSet>(arg));
 	}
 ;
@@ -1731,9 +1733,9 @@ strset_empty
 
 // ----------------------------------------------------------------------------
 // A wrapper for match variable and match value.
-match_var_val [const Corpus2::Tagset& tagset, Variables& vars]
+match_var_val [ParsingScope& scope]
 	returns [boost::shared_ptr<Function<Match> > ret]
-	: ret = match_vector_variable [vars]
+	: ret = match_vector_variable [scope.variables()]
 	| ret = match_value_const
 ;
 
@@ -1742,22 +1744,22 @@ match_var_val [const Corpus2::Tagset& tagset, Variables& vars]
 // Returns boost::shared_ptr<Function<Match> >
 ///////////////////////////////////////////////////////////////////////////////
 match_operator
-  [const Corpus2::Tagset& tagset, Variables& vars]
+  [ParsingScope& scope]
 	returns [boost::shared_ptr<Function<Match> > ret]
 {
 	//
 }
 	:
-	( ret = match_var_val [tagset, vars]
+	( ret = match_var_val [scope]
 	| {LA(1)==LITERAL_M || LA(1)==COLON}? ("M")? {
-			ret.reset(new VarGetter<Match>(vars.create_accessor<Match>("_M")));
+			ret.reset(new VarGetter<Match>(scope.variables().create_accessor<Match>("_M")));
 			ret.reset(new Submatch(ret, 1));
 		}
 	| "MA" { 
-			ret.reset(new VarGetter<Match>(vars.create_accessor<Match>("_M")));
+			ret.reset(new VarGetter<Match>(scope.variables().create_accessor<Match>("_M")));
 			ret.reset(new Submatch(ret, 2));
 		}
-	| LPAREN ret = match_operator [tagset, vars] RPAREN
+	| LPAREN ret = match_operator [scope] RPAREN
 	)
 	( // if there's a colon after the match, we have a submatch reference
 		COLON i: UNSIGNED_INT { ret.reset(new Submatch(ret, token_ref_to_int(i))); }
@@ -1772,32 +1774,32 @@ match_operator
 // ----------------------------------------------------------------------------
 // Single action such as select, delete, relabel or unify
 action
-	[const Corpus2::Tagset& tagset, Variables& vars]
+	[ParsingScope& scope]
 	returns [boost::shared_ptr<TagAction> act]
-	: act = action_select  [tagset, vars]
-	| act = action_delete  [tagset, vars]
-	| act = action_relabel [tagset, vars]
+	: act = action_select  [scope]
+	| act = action_delete  [scope]
+	| act = action_relabel [scope]
 	//
-	| act = action_unify [tagset, vars]
+	| act = action_unify [scope]
 	//
-	| act = action_mark [tagset, vars]
-	| act = action_unmark [tagset, vars]
+	| act = action_mark [scope]
+	| act = action_unmark [scope]
 ;
 
 // Action sequence - the actions are separated with commas:
 // 	select(...), select(...), delete(...)
 action_sequence
-	[const Corpus2::Tagset& tagset, Variables& vars]
+	[ParsingScope& scope]
 	returns [boost::shared_ptr<std::vector<boost::shared_ptr<TagAction> > > v_act]
 {
 	boost::shared_ptr<TagAction> act;
 	v_act.reset(new std::vector<boost::shared_ptr<TagAction> >);
 }
-	: act = action[tagset, vars] {
+	: act = action[scope] {
 		v_act->push_back(act);
 	} 
 	(
-		COMMA act = action[tagset, vars] {
+		COMMA act = action[scope] {
 			v_act->push_back(act);
 		}
 	)*
@@ -1807,42 +1809,42 @@ action_sequence
 // Single rule:
 // 	rule(NAME, ACTIONS) or rule(NAME, COND, ACTIONS)
 rule
-	[const Corpus2::Tagset& tagset, Variables& vars]
+	[ParsingScope& scope]
 	returns [boost::shared_ptr<TagRule> rle]
 {
 	boost::shared_ptr<Function<Bool> > condition;
 	boost::shared_ptr<std::vector<boost::shared_ptr<TagAction> > > actions;
 }
 	: "rule" LPAREN name: STRING COMMA 
-				(condition = bool_operator [tagset, vars] COMMA)?
-				actions = action_sequence [tagset, vars] 
+				(condition = bool_operator [scope] COMMA)?
+				actions = action_sequence [scope] 
 		RPAREN {
 			if (condition) {
 				rle.reset(
-					new TagRule(token_ref_to_std_string(name), vars, actions, condition));
+					new TagRule(token_ref_to_std_string(name), scope.variables(), actions, condition));
 			}
 			else {
 				rle.reset(
-					new TagRule(token_ref_to_std_string(name), vars, actions));
+					new TagRule(token_ref_to_std_string(name), scope.variables(), actions));
 			}
 		}
 /*
 	: "rule" LPAREN name: STRING COMMA
 	(
-		(bool_operator[tagset, vars]) =>
+		(bool_operator[scope]) =>
 		(
-			condition = bool_operator [tagset, vars] COMMA
-			actions = action_sequence [tagset, vars] {
+			condition = bool_operator [scope] COMMA
+			actions = action_sequence [scope] {
 				// rule(NAME, COND, ACTIONS)
 				rle.reset(
-					new TagRule(token_ref_to_std_string(name), vars, actions, condition));
+					new TagRule(token_ref_to_std_string(name), scope.variables(), actions, condition));
 			}
 		)
 	|
 		(
-			actions = action_sequence [tagset, vars] {
+			actions = action_sequence [scope] {
 				// rule(NAME, ACTIONS)
-				rle.reset(new TagRule(token_ref_to_std_string(name), vars, actions));
+				rle.reset(new TagRule(token_ref_to_std_string(name), scope.variables(), actions));
 			}
 		)
 	)
@@ -1852,7 +1854,7 @@ rule
 
 // Rule sequence
 rule_sequence
-	[const Corpus2::Tagset& tagset, Variables& vars]
+	[ParsingScope& scope]
 	returns [boost::shared_ptr<RuleSequence> rule_seq]
 {
 	// FIXME czy tutaj przypadkiem nie powinno byc shared_ptr?
@@ -1860,11 +1862,11 @@ rule_sequence
 
 	rule_seq.reset(new RuleSequence());
 }
-	: rle = rule [tagset, vars] {
+	: rle = rule [scope] {
 		rule_seq->push_back(*rle);
 	}
 	(
-		COMMA rle = rule [tagset, vars] {
+		COMMA rle = rule [scope] {
 			rule_seq->push_back(*rle);
 		}
 	)*
@@ -1873,9 +1875,9 @@ rule_sequence
 // Temporary name. 
 // This is wrapper for rule_sequence in rules section in the wccl file
 rules
-	[const Corpus2::Tagset& tagset, Variables& vars]
+	[ParsingScope& scope]
 	returns [boost::shared_ptr<RuleSequence> rule_seq]
-	: "rules" LPAREN rule_seq = rule_sequence [tagset, vars] RPAREN {
+	: "rules" LPAREN rule_seq = rule_sequence [scope] RPAREN {
 		//
 	}
 ;
@@ -1884,7 +1886,7 @@ rules
 // Select action: 
 //	select(position, predicate) or select(predicate);
 action_select 
-	[const Corpus2::Tagset& tagset, Variables& vars]
+	[ParsingScope& scope]
 	returns [boost::shared_ptr<Select> action]
 {
 	boost::shared_ptr<Function<Position> > pos;
@@ -1892,17 +1894,17 @@ action_select
 }
 	: "select" LPAREN
 	(
-		(position_operator [tagset, vars]) =>
+		(position_operator [scope]) =>
 		(
-			pos = position_operator [tagset, vars] COMMA
-			condition = bool_operator [tagset, vars] {
+			pos = position_operator [scope] COMMA
+			condition = bool_operator [scope] {
 				// select(positon, condition); 
 				action.reset(new Select(condition, pos));
 			}
 		)
 	|
 		(
-			condition = bool_operator [tagset, vars] {
+			condition = bool_operator [scope] {
 				// select(condition); 
 				action.reset(new Select(condition));
 			}
@@ -1915,7 +1917,7 @@ action_select
 // Delete action
 //	delete(position, predicate) or delete(predicate);
 action_delete
-	[const Corpus2::Tagset& tagset, Variables& vars]
+	[ParsingScope& scope]
 	returns [boost::shared_ptr<Delete> action]
 {
 	boost::shared_ptr<Function<Position> > pos;
@@ -1923,17 +1925,17 @@ action_delete
 }
 	: "delete" LPAREN
 	(
-		(position_operator [tagset, vars]) =>
+		(position_operator [scope]) =>
 		(
-			pos = position_operator [tagset, vars] COMMA
-			condition = bool_operator [tagset, vars] {
+			pos = position_operator [scope] COMMA
+			condition = bool_operator [scope] {
 				// delete(positon, condition); 
 				action.reset(new Delete(condition, pos));
 			}
 		)
 	|
 		(
-			condition = bool_operator [tagset, vars] {
+			condition = bool_operator [scope] {
 				// delete(condition); 
 				action.reset(new Delete(condition));
 			}
@@ -1946,7 +1948,7 @@ action_delete
 // Relabel action
 // 	relabel(pos, symset, predicate) or relabel(symset, predicate)
 action_relabel
-	[const Corpus2::Tagset& tagset, Variables& vars]
+	[ParsingScope& scope]
 	returns [boost::shared_ptr<Relabel> action]
 {
 	boost::shared_ptr<Function<Position> > pos;
@@ -1955,19 +1957,19 @@ action_relabel
 }
 	: "relabel" LPAREN
 	(
-		(position_operator [tagset, vars]) =>
+		(position_operator [scope]) =>
 		(
-			pos = position_operator [tagset, vars] COMMA
-			replace_with = symset_operator [tagset, vars] COMMA
-			condition = bool_operator [tagset, vars] {
+			pos = position_operator [scope] COMMA
+			replace_with = symset_operator [scope] COMMA
+			condition = bool_operator [scope] {
 				// relabel(pos, symset, predicate)
 				action.reset(new Relabel(replace_with, condition, pos));
 			}
 		)
 	|
 		(
-			replace_with = symset_operator [tagset, vars] COMMA
-			condition = bool_operator [tagset, vars] {
+			replace_with = symset_operator [scope] COMMA
+			condition = bool_operator [scope] {
 				// relabel(symset, predicate)
 				action.reset(new Relabel(replace_with, condition));
 			}
@@ -1979,16 +1981,16 @@ action_relabel
 // ----------------------------------------------------------------------------
 // Unify action 
 action_unify
-	[const Corpus2::Tagset& tagset, Variables& vars]
+	[ParsingScope& scope]
 	returns [boost::shared_ptr<Unify> action]
 {
 	boost::shared_ptr<Function<TSet> > attribs_expr;
 	boost::shared_ptr<Function<Position> > pos_begin, pos_end;
 }
 	: "unify" LPAREN
-			pos_begin    = position_operator [tagset, vars] COMMA
-			pos_end      = position_operator [tagset, vars] COMMA
-			attribs_expr = symset_operator   [tagset, vars]
+			pos_begin    = position_operator [scope] COMMA
+			pos_end      = position_operator [scope] COMMA
+			attribs_expr = symset_operator   [scope]
 		RPAREN  {
 			action.reset(new Unify(pos_begin, pos_end, attribs_expr));
 		}
@@ -1997,15 +1999,15 @@ action_unify
 // ----------------------------------------------------------------------------
 // Mark action
 action_mark
-	[const Corpus2::Tagset& tagset, Variables& vars]
+	[ParsingScope& scope]
 	returns [boost::shared_ptr<Mark> action]
 {
 	boost::shared_ptr<Function<Position> > pos_begin, pos_end, pos_head;
 }
 	: "mark" LPAREN
-			pos_begin    = position_operator [tagset, vars] COMMA
-			pos_end      = position_operator [tagset, vars] COMMA
-			(pos_head    = position_operator [tagset, vars] COMMA)?
+			pos_begin    = position_operator [scope] COMMA
+			pos_end      = position_operator [scope] COMMA
+			(pos_head    = position_operator [scope] COMMA)?
 			chan_name: STRING
 		RPAREN  {
 			action.reset(new Mark(pos_begin, pos_end, pos_head, ((antlr::Token*)chan_name)->getText()));
@@ -2015,13 +2017,13 @@ action_mark
 // ----------------------------------------------------------------------------
 // Unmark action
 action_unmark
-	[const Corpus2::Tagset& tagset, Variables& vars]
+	[ParsingScope& scope]
 	returns [boost::shared_ptr<Unmark> action]
 {
 	boost::shared_ptr<Function<Position> > pos;
 }
 	: "unmark" LPAREN
-			pos = position_operator [tagset, vars] COMMA
+			pos = position_operator [scope] COMMA
 			chan_name: STRING
 		RPAREN  {
 			action.reset(new Unmark(pos, ((antlr::Token*)chan_name)->getText()));
@@ -2033,13 +2035,13 @@ action_unmark
 // Match rules
 // Returns boost::shared_ptr<MatchRule>
 match_rule_operator
-	[const Corpus2::Tagset& tagset, Variables& vars]
+	[ParsingScope& scope]
 	returns [boost::shared_ptr<MatchRule> ret_op]
 {
 	boost::shared_ptr<ApplyOperator> apply;
 }
-	: apply = match_apply_operator [tagset, vars] {
-		ret_op = boost::make_shared<MatchRule>(vars, apply);
+	: apply = match_apply_operator [scope] {
+		ret_op = boost::make_shared<MatchRule>(scope.variables(), apply);
 	}
 ;
 
@@ -2048,18 +2050,18 @@ match_rule_operator
 // 	apply(match(), actions(actions))
 // Returns boost::shared_ptr<ApplyOperator>
 match_apply_operator
-	[const Corpus2::Tagset& tagset, Variables& vars]
+	[ParsingScope& scope]
 	returns [boost::shared_ptr<ApplyOperator> ret_op]
 {
-	VariableAccessor<Match> matches = vars.create_accessor<Match>("_M");;
+	VariableAccessor<Match> matches = scope.variables().create_accessor<Match>("_M");;
 	boost::shared_ptr<ConjConditions> match_cond;
 	boost::shared_ptr<std::vector<boost::shared_ptr<MatchAction> > > actions;
 	boost::shared_ptr<std::vector<boost::shared_ptr<Function<Bool> > > > conditions;
 }
 	: "apply" LPAREN 
-		"match" LPAREN match_cond = match_condition [tagset,vars] RPAREN COMMA
-		("cond"   LPAREN conditions = bool_operator_comma_sep [tagset, vars] RPAREN COMMA)?
-		"actions" LPAREN actions    =  match_action_comma_sep [tagset, vars] RPAREN
+		"match" LPAREN match_cond = match_condition [scope] RPAREN COMMA
+		("cond"   LPAREN conditions = bool_operator_comma_sep [scope] RPAREN COMMA)?
+		"actions" LPAREN actions    =  match_action_comma_sep [scope] RPAREN
 		RPAREN {
 			if (conditions) {
 				ret_op.reset(
@@ -2076,12 +2078,12 @@ match_apply_operator
 
 // Match conditions. Wrapper for vector of the match conditions
 match_condition
-	[const Corpus2::Tagset& tagset, Variables& vars]
+	[ParsingScope& scope]
 	returns [boost::shared_ptr<ConjConditions> condition]
 {
 	std::vector<boost::shared_ptr<const MatchCondition> > m_cond;
 }
-	: m_cond = match_condition_in [tagset, vars] {
+	: m_cond = match_condition_in [scope] {
 		condition.reset(new ConjConditions(m_cond));
 	}
 ;
@@ -2089,17 +2091,17 @@ match_condition
 // Match conditions.
 // Retutns std::vector< boost::shared_ptr<const MatchCondition> >
 match_condition_in
-	[const Corpus2::Tagset& tagset, Variables& vars]
+	[ParsingScope& scope]
 	returns [std::vector< boost::shared_ptr<const MatchCondition> > ret]
 {
 	boost::shared_ptr<const MatchCondition> r_cond;
 }
-	: r_cond = match_cond_all[tagset, vars] {
+	: r_cond = match_cond_all[scope] {
 		ret.push_back(r_cond);
 	}
 	(
 		COMMA
-		r_cond = match_cond_all[tagset, vars] {
+		r_cond = match_cond_all[scope] {
 			ret.push_back(r_cond);
 		}
 	)*
@@ -2108,19 +2110,19 @@ match_condition_in
 // Match variants variant(v1), variant(v2), ...
 // Retutns boost::shared_ptr<std::vector<ConjConditions> >
 match_variants
-	[const Corpus2::Tagset& tagset, Variables& vars]
+	[ParsingScope& scope]
 	returns [boost::shared_ptr<std::vector<ConjConditions> > variants]
 {
 	variants.reset(new std::vector<ConjConditions>());
 
 	boost::shared_ptr<ConjConditions> variant;
 }
-	: "variant" LPAREN variant = match_condition [tagset, vars] RPAREN {
+	: "variant" LPAREN variant = match_condition [scope] RPAREN {
 		// TODO
 		// variants->push_back(variant);
 	} 
 	(
-		COMMA "variant" LPAREN variant = match_condition [tagset, vars] RPAREN {
+		COMMA "variant" LPAREN variant = match_condition [scope] RPAREN {
 			// TODO
 			// variants->push_back(variant);
 		}
@@ -2130,13 +2132,13 @@ match_variants
 // One of the match condition
 // Returns boost::shared_ptr<const MatchCondition>
 match_cond_all
-	[const Corpus2::Tagset& tagset, Variables& vars]
+	[ParsingScope& scope]
 	returns [boost::shared_ptr<const MatchCondition> ret]
-	: ret = match_cond_optional [tagset, vars]
-	| ret = match_cond_repeate  [tagset, vars]
-	| ret = match_cond_token    [tagset, vars]
-	| ret = match_cond_oneof    [tagset, vars]
-	| ret = match_cond_longest  [tagset, vars]
+	: ret = match_cond_optional [scope]
+	| ret = match_cond_repeate  [scope]
+	| ret = match_cond_token    [scope]
+	| ret = match_cond_oneof    [scope]
+	| ret = match_cond_longest  [scope]
 	| ret = match_cond_is
 	| ret = match_cond_text
 ;
@@ -2144,12 +2146,12 @@ match_cond_all
 // Match condition - token (wraps a L0 predicate)
 // Returns boost::shared_ptr<const MatchCondition>
 match_cond_token
-	[const Corpus2::Tagset& tagset, Variables& vars]
+	[ParsingScope& scope]
 	returns [boost::shared_ptr<const TokenCondition> ret]
 {
 	boost::shared_ptr<Function<Bool> > bool_op;
 }
-	: bool_op = bool_operator [tagset, vars] {
+	: bool_op = bool_operator [scope] {
 		ret = boost::make_shared<TokenCondition>(bool_op);
 	}
 ;
@@ -2158,12 +2160,12 @@ match_cond_token
  // Match condition - optional
 // Returns boost::shared_ptr<OptionalMatch>
 match_cond_optional
-	[const Corpus2::Tagset& tagset, Variables& vars]
+	[ParsingScope& scope]
 	returns [boost::shared_ptr<OptionalMatch> mtch]
 {
 	boost::shared_ptr<ConjConditions> m_cond;
 }
-	: "optional" LPAREN m_cond = match_condition [tagset, vars] RPAREN {
+	: "optional" LPAREN m_cond = match_condition [scope] RPAREN {
 		mtch.reset(new OptionalMatch(m_cond));
 	}
 ;
@@ -2171,12 +2173,12 @@ match_cond_optional
 // Match condition - repeat
 // Returns boost::shared_ptr<RepeatedMatch>
 match_cond_repeate
-	[const Corpus2::Tagset& tagset, Variables& vars]
+	[ParsingScope& scope]
 	returns [boost::shared_ptr<RepeatedMatch> mtch]
 {
 	boost::shared_ptr<ConjConditions> m_cond;
 }
-	: "repeat" LPAREN m_cond = match_condition [tagset, vars] RPAREN {
+	: "repeat" LPAREN m_cond = match_condition [scope] RPAREN {
 		mtch.reset(new RepeatedMatch(m_cond));
 	}
 ;
@@ -2202,12 +2204,12 @@ match_cond_text
 // Match condition - oneof(variant1(v1), variant(v2), ...)
 // Returns boost::shared_ptr<OneOf>
 match_cond_oneof
-	[const Corpus2::Tagset& tagset, Variables& vars]
+	[ParsingScope& scope]
 	returns [boost::shared_ptr<OneOf> onf]
 {
 	boost::shared_ptr<std::vector<ConjConditions> > variants;
 }
-	: "oneof" LPAREN variants = match_variants [tagset, vars] RPAREN {
+	: "oneof" LPAREN variants = match_variants [scope] RPAREN {
 		onf.reset(new OneOf(variants));
 	}
 ;
@@ -2215,12 +2217,12 @@ match_cond_oneof
 // Match condition - longest(variant1(v1), variant(v2), ...)
 // Returns boost::shared_ptr<Longest>
 match_cond_longest
-	[const Corpus2::Tagset& tagset, Variables& vars]
+	[ParsingScope& scope]
 	returns [boost::shared_ptr<Longest> lng]
 {
 	boost::shared_ptr<std::vector<ConjConditions> > variants;
 }
-	: "longest" LPAREN variants = match_variants [tagset, vars] RPAREN {
+	: "longest" LPAREN variants = match_variants [scope] RPAREN {
 		lng.reset(new Longest(variants));
 	}
 ;
@@ -2230,16 +2232,16 @@ match_cond_longest
 // Match actions. Match action can be mark or unmark
 // Returns boost::shared_ptr<MatchAction>
 match_action
-	[const Corpus2::Tagset& tagset, Variables& vars]
+	[ParsingScope& scope]
 	returns [boost::shared_ptr<MatchAction> m_act]
-	: m_act = match_mark_action   [tagset, vars]
-	| m_act = match_unmark_action [tagset, vars]
+	: m_act = match_mark_action   [scope]
+	| m_act = match_unmark_action [scope]
 ;
 
 // Match mark action
 // Returns 
 match_mark_action
-	[const Corpus2::Tagset& tagset, Variables& vars]
+	[ParsingScope& scope]
 	returns [boost::shared_ptr<MarkMatch> m_act]
 {
 	boost::shared_ptr<Function<Match> > match_to;
@@ -2247,9 +2249,9 @@ match_mark_action
 	boost::shared_ptr<Function<Match> > head_match;
 }
 	: "mark" LPAREN 
-			match_from = match_operator[tagset, vars] COMMA
-			( match_to  = match_operator[tagset, vars] COMMA
-				( head_match = match_operator[tagset, vars] COMMA )?
+			match_from = match_operator[scope] COMMA
+			( match_to  = match_operator[scope] COMMA
+				( head_match = match_operator[scope] COMMA )?
 			)?
 			annotation_name : STRING
 		RPAREN {
@@ -2280,13 +2282,13 @@ match_mark_action
 // Match unmark action
 // Returns boost::shared_ptr<UnmarkMatch>
 match_unmark_action
-	[const Corpus2::Tagset& tagset, Variables& vars]
+	[ParsingScope& scope]
 	returns [boost::shared_ptr<UnmarkMatch> m_act]
 {
 	boost::shared_ptr<Function<Match> > match_at;
 }
 	: "unmark" LPAREN
-				match_at = match_operator[tagset, vars] COMMA
+				match_at = match_operator[scope] COMMA
 				annotation_name : STRING
 			RPAREN {
 				m_act.reset(
@@ -2299,7 +2301,7 @@ match_unmark_action
 // Match action separated by comma
 // Returns boost::shared_ptr<std::vector<boost::shared_ptr<MatchAction> > >
 match_action_comma_sep
-	[const Corpus2::Tagset& tagset, Variables& vars]
+	[ParsingScope& scope]
 	returns [boost::shared_ptr<std::vector<boost::shared_ptr<MatchAction> > > r_vec]
 {
 	boost::shared_ptr<MatchAction> act;
@@ -2308,11 +2310,11 @@ match_action_comma_sep
 		new std::vector<boost::shared_ptr<MatchAction> >
 	);
 }
-	: act = match_action [tagset, vars] {
+	: act = match_action [scope] {
 			r_vec->push_back(act);
 	}
 	(
-		COMMA act = match_action [tagset, vars] {
+		COMMA act = match_action [scope] {
 			r_vec->push_back(act);
 		}
 	)*
diff --git a/libwccl/parser/parsingscope.h b/libwccl/parser/parsingscope.h
new file mode 100644
index 0000000000000000000000000000000000000000..29727895a9a3e10d8de6533599e7b73781a6795f
--- /dev/null
+++ b/libwccl/parser/parsingscope.h
@@ -0,0 +1,32 @@
+#ifndef LIBWCCL_PARSER_PARSINGSCOPE_H
+#define LIBWCCL_PARSER_PARSINGSCOPE_H
+
+#include <libwccl/variables.h>
+
+namespace Wccl {
+
+class ParsingScope
+{
+public:
+	ParsingScope(const Corpus2::Tagset& tagset)
+		: tagset_(tagset),
+		  variables_()
+	{
+	}
+
+	const Corpus2::Tagset& tagset() {
+		return tagset_;
+	}
+
+	Variables& variables() {
+		return variables_;
+	}
+
+private:
+	const Corpus2::Tagset& tagset_;
+	Variables variables_;
+};
+
+} /* end ns Wccl */
+
+#endif // LIBWCCL_PARSER_PARSINGSCOPE_H