From a75eae8a22b9265aeaddb1deb904bf7bed53b400 Mon Sep 17 00:00:00 2001 From: Adam Wardynski <award@.(win7-laptop)> Date: Sun, 21 Nov 2010 21:11:41 +0100 Subject: [PATCH] String for conditional is now if(x, y, z) It's a change from if x then y else z, which wasn't exactly proper anyway without parentheses. --- libwccl/ops/conditional.h | 4 ++-- tests/conditional.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/libwccl/ops/conditional.h b/libwccl/ops/conditional.h index 80398fd..580b02d 100644 --- a/libwccl/ops/conditional.h +++ b/libwccl/ops/conditional.h @@ -119,7 +119,7 @@ template<class T> std::string Conditional<T>::to_raw_string() const { std::stringstream ss; - ss << boost::format("%1% %2% then %3% else %4%") + ss << boost::format("%1%(%2%, %3%, %4%)") % this->raw_operator_name() % this->cond_expr_->to_raw_string() % this->iftrue_expr_->to_raw_string() @@ -131,7 +131,7 @@ template<class T> std::string Conditional<T>::to_string(const Corpus2::Tagset &tagset) const { std::stringstream ss; - ss << boost::format("%1% %2% then %3% else %4%") + ss << boost::format("%1%(%2%, %3%, %4%)") % this->operator_name(tagset) % this->cond_expr_->to_string(tagset) % this->iftrue_expr_->to_string(tagset) diff --git a/tests/conditional.cpp b/tests/conditional.cpp index cfa78ab..e6e5d55 100644 --- a/tests/conditional.cpp +++ b/tests/conditional.cpp @@ -119,7 +119,7 @@ BOOST_FIXTURE_TEST_CASE(cond_to_string, CondFixStrSet) true_constant, empty_strset_expr, one_elem_strset_expr)); - std::string expected = "if True then [] else [\"oNe\"]"; + std::string expected = "if(True, [], [\"oNe\"])"; BOOST_CHECK_EQUAL(expected, cond->to_string(tagset)); } @@ -128,7 +128,7 @@ BOOST_FIXTURE_TEST_CASE(cond_to_string_raw, CondFixStrSet) boost::shared_ptr<Conditional<StrSet> > cond(new Conditional<StrSet>( true_constant, one_elem_strset_expr)); - std::string expected = "if True then [\"oNe\"] else []"; + std::string expected = "if(True, [\"oNe\"], [])"; BOOST_CHECK_EQUAL(expected, cond->to_string(tagset)); } -- GitLab