From 265af4672a9dd05b1751305df0141478334bc98b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20K=C4=99dzia?= <pawel.kedzia@pwr.wroc.pl> Date: Mon, 6 Dec 2010 11:10:20 +0100 Subject: [PATCH] Iteration operators: only, rlook, llook, atleast --- libwccl/parser/grammar.g | 54 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/libwccl/parser/grammar.g b/libwccl/parser/grammar.g index 088d270..beab755 100644 --- a/libwccl/parser/grammar.g +++ b/libwccl/parser/grammar.g @@ -46,6 +46,11 @@ header { #include <libwccl/ops/functions/position/relativeposition.h> + #include <libwccl/ops/functions/bool/iterations/only.h> + #include <libwccl/ops/functions/bool/iterations/atleast.h> + #include <libwccl/ops/functions/bool/iterations/leftlook.h> + #include <libwccl/ops/functions/bool/iterations/rightlook.h> + // Unicode String #include <unicode/uniset.h> #include <unicode/unistr.h> @@ -802,6 +807,8 @@ bool_operator | ret = equal_operator [tagset, vars] | ret = in_operator [tagset, vars] | ret = inter_operator [tagset, vars] + // iterations + | ret = bool_iteration [tagset, vars] // | LPAREN ret = bool_operator [tagset, vars] RPAREN ; @@ -1042,6 +1049,53 @@ inter_operator RPAREN ; +// ---------------------------------------------------------------------------- +// Iterations: +bool_iteration + [const Corpus2::Tagset& tagset, Variables& vars] + returns [boost::shared_ptr<Function<Bool> > ret] +{ + int min_match = 0; + boost::shared_ptr<Function<Bool> > expr; + boost::shared_ptr<Function<Position> > lpos, rpos; + 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] + 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 + min_match = number + RPAREN { + ret.reset(new AtLeast(lpos, rpos, *pacc, expr, min_match)); + } + | "llook" LPAREN + lpos = position_operator [tagset, vars] COMMA + rpos = position_operator [tagset, vars] COMMA + pacc = position_variable_acc [vars] COMMA + expr = bool_operator [tagset, vars] + 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] + RPAREN { + ret.reset(new RightLook(lpos, rpos, *pacc, expr)); + } +; + // ---------------------------------------------------------------------------- // Setvar operator // Returns boost::shared_ptr<Function<Bool> > -- GitLab