Skip to content
Snippets Groups Projects
Commit 265af467 authored by Paweł Kędzia's avatar Paweł Kędzia
Browse files

Iteration operators: only, rlook, llook, atleast

parent 94b97137
Branches
No related merge requests found
......@@ -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> >
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment