diff --git a/libwccl/ops/functions/bool/iterations/leftlook.cpp b/libwccl/ops/functions/bool/iterations/leftlook.cpp index d1a80282735c953fa4b714e79914fa7e2b589546..349b40c2ae301ead0b495dccb2a72cc29923fc0c 100644 --- a/libwccl/ops/functions/bool/iterations/leftlook.cpp +++ b/libwccl/ops/functions/bool/iterations/leftlook.cpp @@ -17,4 +17,24 @@ bool LeftLook::iterate( return false; } +std::string LeftLook::to_string(const Corpus2::Tagset& tagset) const +{ + std::ostringstream ss; + ss << name(tagset) << "(" + << right_pos_expr_->to_string(tagset) << ", " + << left_pos_expr_->to_string(tagset) << ", " + << Position::var_repr(iter_var_acc_.get_name()) << ", " + << evaluating_expr_->to_string(tagset) << ")"; + return ss.str(); +} + +std::ostream& LeftLook::write_to(std::ostream& os) const +{ + return os << raw_name() << "(" + << *right_pos_expr_ << ", " + << *left_pos_expr_ << ", " + << Position::var_repr(iter_var_acc_.get_name()) << ", " + << *evaluating_expr_ << ")"; +} + } /* end ns Wccl */ diff --git a/libwccl/ops/functions/bool/iterations/leftlook.h b/libwccl/ops/functions/bool/iterations/leftlook.h index 92e42dab29581b899b855639df708443495f9593..618aa3d11e63eefcfc9d3ed74abba08e5e9432a1 100644 --- a/libwccl/ops/functions/bool/iterations/leftlook.h +++ b/libwccl/ops/functions/bool/iterations/leftlook.h @@ -29,6 +29,12 @@ public: return "llook"; } + /** + * @returns String reperesentation of LeftLook Operator: + * llook(right_pos_expr, left_pos_expr, variable, eval_expr, min_matches) + */ + std::string to_string(const Corpus2::Tagset& tagset) const; + protected: /** * @returns True if, when scanning right-to-left, @@ -46,6 +52,15 @@ protected: int right, Position &p, const FunExecContext &context) const; + + /** + * Writes raw string reperesentation of LeftLook operator, in form of + * llook(raw_right_p_expr, raw_left_p_expr, var, raw_eval_expr, min_matches) + * @note This version doesn't require a Tagset, but may + * be incomplete and/or contain internal info. + * @returns Stream written to. + */ + std::ostream& write_to(std::ostream& ostream) const; };