diff --git a/libwccl/parser/grammar.g b/libwccl/parser/grammar.g index 628410a35b2dcbf92ef467a5757ccf81049d8078..f0f634b3ef7d2338320aca2ecfe29d3c30cae8e1 100644 --- a/libwccl/parser/grammar.g +++ b/libwccl/parser/grammar.g @@ -35,6 +35,7 @@ header { #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/isempty.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> @@ -1055,6 +1056,8 @@ bool_operator | ret = bool_condition [tagset, vars] // setvar: | ret = setvar_operator [tagset, vars] + // empty + | ret = empty_operator [tagset, vars] // equal/in/inter: | ret = equal_operator [tagset, vars] | ret = in_operator [tagset, vars] @@ -1639,6 +1642,84 @@ symset_setvar } ; +// ---------------------------------------------------------------------------- +// empty() operator +// Returns boost::shared_ptr<Function<Bool> > +//---------------------------------------------------------------------------- +empty_operator + [const Corpus2::Tagset& tagset, Variables& vars] + returns [boost::shared_ptr<Function<Bool> > op] + : "empty" LPAREN + ( + (match_empty[tagset, vars]) => + ( + op = match_empty [tagset, vars] + ) + | (symset_empty [tagset, vars]) => + ( + op = symset_empty [tagset, vars] + ) + | op = strset_empty [tagset, vars] + ) + RPAREN +; + +/* +empty_operator + [const Corpus2::Tagset& tagset, Variables& vars] + returns [boost::shared_ptr<Function<Bool> > op] + : "empty" LPAREN + ( + op = match_empty [tagset, vars] + | op = symset_empty [tagset, vars] + | op = strset_empty [tagset, vars] + ) + RPAREN +; +*/ + +//---------------------------------------------------------------------------- +// match empty() operator +// Returns boost::shared_ptr<Function<Bool> > +match_empty + [const Corpus2::Tagset& tagset, Variables& vars] + returns [boost::shared_ptr<Function<Bool> > op] +{ + boost::shared_ptr<Function<Match> > arg; +} + : arg = match_fit [tagset, vars] { + op.reset(new IsEmpty<Match>(arg)); + } +; + +//---------------------------------------------------------------------------- +// SymSet empty() operator +// Returns boost::shared_ptr<Function<Bool> > +symset_empty + [const Corpus2::Tagset& tagset, Variables& vars] + returns [boost::shared_ptr<Function<Bool> > op] +{ + boost::shared_ptr<Function<TSet> > arg; +} + : arg = symset_operator [tagset, vars] { + op.reset(new IsEmpty<TSet>(arg)); + } +; + +//---------------------------------------------------------------------------- +// Strset empty() operator +// Returns boost::shared_ptr<Function<Bool> > +strset_empty + [const Corpus2::Tagset& tagset, Variables& vars] + returns [boost::shared_ptr<Function<Bool> > op] +{ + boost::shared_ptr<Function<StrSet> > arg; +} + : arg = strset_operator [tagset, vars] { + op.reset(new IsEmpty<StrSet>(arg)); + } +; + // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // Tagging actions and rules: