From da8c29b99755b2fa66d1367300442faa35bdc19e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pawe=C5=82=20K=C4=99dzia?= <pawel.kedzia@pwr.wroc.pl>
Date: Wed, 8 Dec 2010 19:36:02 +0100
Subject: [PATCH] Added rules for parsing agreement operator (agr, agrpp, wagr)

---
 libwccl/parser/grammar.g | 39 ++++++++++++++++++++++++++++++++++++++-
 1 file changed, 38 insertions(+), 1 deletion(-)

diff --git a/libwccl/parser/grammar.g b/libwccl/parser/grammar.g
index e310b46..6fa656e 100644
--- a/libwccl/parser/grammar.g
+++ b/libwccl/parser/grammar.g
@@ -23,16 +23,19 @@ header {
 	#include <libwccl/ops/functions/vargetter.h>
 	#include <libwccl/ops/functions/conditional.h>
 
+	#include <libwccl/ops/functions/bool/varsetter.h>
 	#include <libwccl/ops/functions/bool/predicates/or.h>
 	#include <libwccl/ops/functions/bool/predicates/nor.h>
 	#include <libwccl/ops/functions/bool/predicates/and.h>
 	#include <libwccl/ops/functions/bool/predicates/regex.h>
-	#include <libwccl/ops/functions/bool/varsetter.h>
 	#include <libwccl/ops/functions/bool/predicates/intersects.h>
 	#include <libwccl/ops/functions/bool/predicates/issubsetof.h>
 	#include <libwccl/ops/functions/bool/predicates/isinside.h>
 	#include <libwccl/ops/functions/bool/predicates/isoutside.h>
 	#include <libwccl/ops/functions/bool/predicates/equals.h>
+	#include <libwccl/ops/functions/bool/predicates/weakagreement.h>
+	#include <libwccl/ops/functions/bool/predicates/pointagreement.h>
+	#include <libwccl/ops/functions/bool/predicates/strongagreement.h>
 
 	#include <libwccl/ops/functions/strset/affix.h>
 	#include <libwccl/ops/functions/strset/getorth.h>
@@ -822,6 +825,8 @@ bool_operator
 	| ret = inter_operator  [tagset, vars]
 	// iterations
 	| ret = bool_iteration  [tagset, vars]
+	// agreement
+	| ret = bool_agreement  [tagset, vars]
 	//
 	| LPAREN ret = bool_operator [tagset, vars] RPAREN
 ;
@@ -1109,6 +1114,38 @@ bool_iteration
 		}
 ;
 
+// ----------------------------------------------------------------------------
+// Agreement operator: agr, agrpp, wagr
+bool_agreement
+	[const Corpus2::Tagset& tagset, Variables& vars]
+	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]
+		RPAREN {
+			ret.reset(new StrongAgreement(lpos, rpos, expr, tagset));
+		}
+	| "agrpp" LPAREN
+			lpos = position_operator [tagset, vars] COMMA 
+			rpos = position_operator [tagset, vars] COMMA 
+			expr = symset_operator [tagset, vars]
+		RPAREN {
+			ret.reset(new PointAgreement(lpos, rpos, expr, tagset));
+		}
+	| "wagr"  LPAREN
+			lpos = position_operator [tagset, vars] COMMA 
+			rpos = position_operator [tagset, vars] COMMA 
+			expr = symset_operator [tagset, vars]
+		RPAREN {
+			ret.reset(new WeakAgreement(lpos, rpos, expr, tagset));
+		}
+;
+
 // ----------------------------------------------------------------------------
 // Setvar operator
 // Returns boost::shared_ptr<Function<Bool> >
-- 
GitLab