Skip to content
Snippets Groups Projects
Commit 592ba564 authored by Adam Wardynski's avatar Adam Wardynski
Browse files

Adding first() & last() ops to the grammar.

parent d2878523
Branches
No related merge requests found
......@@ -53,6 +53,8 @@ header {
#include <libwccl/ops/functions/tset/getsymbolsinrange.h>
#include <libwccl/ops/functions/position/relativeposition.h>
#include <libwccl/ops/functions/position/lasttoken.h>
#include <libwccl/ops/functions/position/firsttoken.h>
#include <libwccl/ops/functions/bool/iterations/only.h>
#include <libwccl/ops/functions/bool/iterations/atleast.h>
......@@ -830,8 +832,10 @@ position_operator
[const Corpus2::Tagset& tagset, Variables& vars]
returns [boost::shared_ptr<Function<Position> > ret]
:
( ret = position_var_val [vars]
| ret = position_condition [tagset, vars]
( 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
)
( // if there is SIGNED_INT after the position, it is actually a relative position
......@@ -880,6 +884,32 @@ position_condition
}
;
// ----------------------------------------------------------------------------
// Taking position of a first token in a match
// first(Match)
position_first_token [const Corpus2::Tagset& tagset, Variables& vars]
returns [boost::shared_ptr<Function<Position> > ret]
{
boost::shared_ptr<Function<Match> > m;
}
: "first" LPAREN m = match_fit [tagset, vars] RPAREN {
ret.reset(new FirstToken(m));
}
;
// ----------------------------------------------------------------------------
// Taking position of a first token in a match
// last(Match)
position_last_token [const Corpus2::Tagset& tagset, Variables& vars]
returns [boost::shared_ptr<Function<Position> > ret]
{
boost::shared_ptr<Function<Match> > m;
}
: "last" LPAREN m = match_fit [tagset, vars] RPAREN {
ret.reset(new LastToken(m));
}
;
///////////////////////////////////////////////////////////////////////////////
// Stiring operator
// Returns boost::shared_ptr<Function<StrSet> >
......
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