diff --git a/libwccl/ops/match/conditions/longest.cpp b/libwccl/ops/match/conditions/longest.cpp index ce8b9aaa56b9f9c4708b167dafc507a09220aa68..82a3653d12cf43216d76ce2561cd98cf239adf90 100644 --- a/libwccl/ops/match/conditions/longest.cpp +++ b/libwccl/ops/match/conditions/longest.cpp @@ -5,7 +5,7 @@ namespace Wccl { -Longest::Longest(const boost::shared_ptr<std::vector<ConjConditions> >& variants) +Longest::Longest(const boost::shared_ptr<std::vector<boost::shared_ptr<ConjConditions> > >& variants) : _variants(variants) { BOOST_ASSERT(_variants); @@ -18,8 +18,8 @@ MatchResult Longest::apply(const ActionExecContext& context) const int longest_pos = orig_pos; MatchResult longest; - foreach(const ConjConditions& variant, *_variants) { - MatchResult res = variant.apply(context); + foreach(const boost::shared_ptr<ConjConditions>& variant, *_variants) { + MatchResult res = variant->apply(context); int cur_pos = context.sentence_context().get_position(); if (res.matched() && longest_pos < cur_pos) { longest_pos = cur_pos; @@ -40,7 +40,7 @@ std::string Longest::to_string(const Corpus2::Tagset& tagset) const if (i != 0) { ostream << ", "; } - ostream << "variant" << _variants->at(i).to_string(tagset); + ostream << "variant" << _variants->at(i)->to_string(tagset); } ostream << ")"; return ostream.str(); @@ -53,7 +53,7 @@ std::ostream& Longest::write_to(std::ostream& ostream) const if (i != 0) { ostream << ", "; } - ostream << "variant" << _variants->at(i); + ostream << "variant" << *(_variants->at(i)); } return ostream << ")"; } diff --git a/libwccl/ops/match/conditions/longest.h b/libwccl/ops/match/conditions/longest.h index 2aed55ba7b4765a01784900e82fce96ed7b887b4..008b50767b811b3f7d0ef1a205755afd68fccdae 100644 --- a/libwccl/ops/match/conditions/longest.h +++ b/libwccl/ops/match/conditions/longest.h @@ -11,7 +11,7 @@ namespace Wccl { class Longest : public MatchCondition { public: - Longest(const boost::shared_ptr<std::vector<ConjConditions> >& variants); + Longest(const boost::shared_ptr<std::vector<boost::shared_ptr<ConjConditions> > >& variants); /** * @returns Name of the condition. @@ -45,7 +45,7 @@ protected: */ std::ostream& write_to(std::ostream& ostream) const; private: - const boost::shared_ptr<std::vector<ConjConditions> > _variants; + const boost::shared_ptr<std::vector<boost::shared_ptr<ConjConditions> > > _variants; }; } /* end ns Wccl */ diff --git a/libwccl/ops/match/conditions/oneof.cpp b/libwccl/ops/match/conditions/oneof.cpp index 78c3544c0656ddb6d828c3a6623a6943cbb66b4a..068b04af3df261586d6bf6b0c0e8cfeaeb586b78 100644 --- a/libwccl/ops/match/conditions/oneof.cpp +++ b/libwccl/ops/match/conditions/oneof.cpp @@ -5,7 +5,7 @@ namespace Wccl { -OneOf::OneOf(const boost::shared_ptr<std::vector<ConjConditions> >& variants) +OneOf::OneOf(const boost::shared_ptr<std::vector<boost::shared_ptr<ConjConditions> > >& variants) : _variants(variants) { BOOST_ASSERT(_variants); @@ -15,8 +15,8 @@ OneOf::OneOf(const boost::shared_ptr<std::vector<ConjConditions> >& variants) MatchResult OneOf::apply(const ActionExecContext& context) const { int orig_pos = context.sentence_context().get_position(); - foreach(const ConjConditions& variant, *_variants) { - MatchResult res = variant.apply(context); + foreach(const boost::shared_ptr<ConjConditions>& variant, *_variants) { + MatchResult res = variant->apply(context); if (res.matched()) { return res; } @@ -33,7 +33,7 @@ std::string OneOf::to_string(const Corpus2::Tagset& tagset) const if (i != 0) { ostream << ", "; } - ostream << "variant" << _variants->at(i).to_string(tagset); + ostream << "variant" << _variants->at(i)->to_string(tagset); } ostream << ")"; return ostream.str(); @@ -46,7 +46,7 @@ std::ostream& OneOf::write_to(std::ostream& ostream) const if (i != 0) { ostream << ", "; } - ostream << "variant" << _variants->at(i); + ostream << "variant" << *(_variants->at(i)); } return ostream << ")"; } diff --git a/libwccl/ops/match/conditions/oneof.h b/libwccl/ops/match/conditions/oneof.h index 0aba4762638cf33c594401be71a2adfbba19572a..a0d649a9d2d98c400569cd74abba4d98fa80d726 100644 --- a/libwccl/ops/match/conditions/oneof.h +++ b/libwccl/ops/match/conditions/oneof.h @@ -11,7 +11,7 @@ namespace Wccl { class OneOf : public MatchCondition { public: - OneOf(const boost::shared_ptr<std::vector<ConjConditions> >& variants); + OneOf(const boost::shared_ptr<std::vector<boost::shared_ptr<ConjConditions> > >& variants); /** * @returns Name of the condition. @@ -44,7 +44,7 @@ protected: */ std::ostream& write_to(std::ostream& ostream) const; private: - const boost::shared_ptr<std::vector<ConjConditions> > _variants; + const boost::shared_ptr<std::vector<boost::shared_ptr<ConjConditions> > > _variants; }; } /* end ns Wccl */ diff --git a/libwccl/parser/grammar.g b/libwccl/parser/grammar.g index 7d445e11d733becbf987b84dab22cba3275d63ed..f534a84a5b77d37af24a017b4720ee90bb7ce792 100644 --- a/libwccl/parser/grammar.g +++ b/libwccl/parser/grammar.g @@ -2111,20 +2111,18 @@ match_condition_in // Retutns boost::shared_ptr<std::vector<ConjConditions> > match_variants [ParsingScope& scope] - returns [boost::shared_ptr<std::vector<ConjConditions> > variants] + returns [boost::shared_ptr<std::vector<boost::shared_ptr<ConjConditions> > > variants] { - variants.reset(new std::vector<ConjConditions>()); + variants.reset(new std::vector<boost::shared_ptr<ConjConditions> >()); boost::shared_ptr<ConjConditions> variant; } : "variant" LPAREN variant = match_condition [scope] RPAREN { - // TODO - // variants->push_back(variant); + variants->push_back(variant); } ( COMMA "variant" LPAREN variant = match_condition [scope] RPAREN { - // TODO - // variants->push_back(variant); + variants->push_back(variant); } )* ; @@ -2207,7 +2205,7 @@ match_cond_oneof [ParsingScope& scope] returns [boost::shared_ptr<OneOf> onf] { - boost::shared_ptr<std::vector<ConjConditions> > variants; + boost::shared_ptr<std::vector<boost::shared_ptr<ConjConditions> > > variants; } : "oneof" LPAREN variants = match_variants [scope] RPAREN { onf.reset(new OneOf(variants)); @@ -2220,7 +2218,7 @@ match_cond_longest [ParsingScope& scope] returns [boost::shared_ptr<Longest> lng] { - boost::shared_ptr<std::vector<ConjConditions> > variants; + boost::shared_ptr<std::vector<boost::shared_ptr<ConjConditions> > > variants; } : "longest" LPAREN variants = match_variants [scope] RPAREN { lng.reset(new Longest(variants));