diff --git a/libwccl/parser/grammar.g b/libwccl/parser/grammar.g index e310b46c1e976e2bd9b066593e6ce2964ed276e5..6fa656ee7348337d9ffcd8c4be679cb77d704821 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> >