From 12a78854dbeebffe09ab486592274e7cf2656e20 Mon Sep 17 00:00:00 2001
From: Adam Wardynski <award@.(win7-laptop)>
Date: Sun, 21 Nov 2010 21:20:16 +0100
Subject: [PATCH] Rebasing FunctionBase from Operator to Expression. Some other
 refactoring too, some augmented comments etc.

---
 libwccl/ops/affix.cpp            |  4 ++--
 libwccl/ops/affix.h              | 11 +++++----
 libwccl/ops/and.cpp              |  4 ----
 libwccl/ops/and.h                | 11 ++++++---
 libwccl/ops/conditional.h        | 38 ++++++++++++++++++--------------
 libwccl/ops/constant.h           | 23 +++++++++++++------
 libwccl/ops/equals.h             | 21 ++++++++++++++----
 libwccl/ops/formatters.cpp       |  8 +++----
 libwccl/ops/functions.h          | 22 ++++++++++++++++--
 libwccl/ops/intersects.h         |  7 ++++--
 libwccl/ops/isinside.h           | 19 ++++++++++++----
 libwccl/ops/isoutside.h          | 19 ++++++++++++----
 libwccl/ops/issubsetof.h         | 15 ++++++++-----
 libwccl/ops/logicalpredicate.cpp |  4 ++--
 libwccl/ops/logicalpredicate.h   |  4 ++--
 libwccl/ops/nor.cpp              |  4 ----
 libwccl/ops/nor.h                | 10 +++++++--
 libwccl/ops/or.cpp               |  4 ----
 libwccl/ops/or.h                 |  9 ++++++--
 libwccl/ops/regex.cpp            |  4 ++--
 libwccl/ops/regex.h              | 17 ++++++++------
 libwccl/ops/relativeposition.h   | 22 +++++++++++++-----
 libwccl/ops/setpredicate.h       | 14 ++++++++++--
 libwccl/ops/tolower.h            | 17 ++++++++------
 libwccl/ops/toupper.h            | 18 ++++++++-------
 libwccl/ops/vargetter.h          | 15 ++++++-------
 libwccl/ops/varsetter.h          | 12 +++++-----
 27 files changed, 234 insertions(+), 122 deletions(-)

diff --git a/libwccl/ops/affix.cpp b/libwccl/ops/affix.cpp
index 934787d..c9bc7e0 100644
--- a/libwccl/ops/affix.cpp
+++ b/libwccl/ops/affix.cpp
@@ -8,14 +8,14 @@ namespace Wccl {
 std::string Affix::to_string(const Corpus2::Tagset& tagset) const
 {
 	std::stringstream str;
-	str << operator_name(tagset) << "(" << strset_expr_->to_string(tagset)
+	str << name(tagset) << "(" << strset_expr_->to_string(tagset)
 		<< ", " << affix_length_ << ")";
 	return str.str();
 }
 
 std::string Affix::to_raw_string() const {
 	std::stringstream str;
-	str << raw_operator_name() << "(" << strset_expr_->to_raw_string()
+	str << raw_name() << "(" << strset_expr_->to_raw_string()
 		<< ", " << affix_length_ << ")";
 	return str.str();
 }
diff --git a/libwccl/ops/affix.h b/libwccl/ops/affix.h
index f52129d..ddda767 100644
--- a/libwccl/ops/affix.h
+++ b/libwccl/ops/affix.h
@@ -26,7 +26,7 @@ public:
 	 * String representation of the operator in form of:
 	 * "affix(strset_expr_string)"
 	 */
-	virtual std::string to_string(const Corpus2::Tagset& tagset) const;
+	std::string to_string(const Corpus2::Tagset& tagset) const;
 
 	/**
 	 * String representation of conditional operator in form of:
@@ -34,9 +34,12 @@ public:
 	 * This version does not require tagset, but may be inclomplete
 	 * and/or contain internal info.
 	 */
-	virtual std::string to_raw_string() const;
+	std::string to_raw_string() const;
 
-	virtual const std::string raw_operator_name() const {
+	/**
+	 * @returns Name of the function: "affix"
+	 */
+	std::string raw_name() const {
 		return "affix";
 	}
 
@@ -48,7 +51,7 @@ protected:
 	 * Get a string set from the argument expression and return copy of the set
 	 * with all strings converted into prefixes or suffixes of given length
 	 */
-	virtual BaseRetValPtr apply_internal(const FunExecContext& context) const;
+	BaseRetValPtr apply_internal(const FunExecContext& context) const;
 };
 
 } /* end ns Wccl */
diff --git a/libwccl/ops/and.cpp b/libwccl/ops/and.cpp
index 7cf39ec..2c18f47 100644
--- a/libwccl/ops/and.cpp
+++ b/libwccl/ops/and.cpp
@@ -15,8 +15,4 @@ And::BaseRetValPtr And::apply_internal(const FunExecContext& context) const
 	return Predicate::True(context);
 }
 
-const std::string And::raw_operator_name() const {
-	return "and";
-}
-
 } /* end ns Wccl */
diff --git a/libwccl/ops/and.h b/libwccl/ops/and.h
index 46b74a3..88b019d 100644
--- a/libwccl/ops/and.h
+++ b/libwccl/ops/and.h
@@ -16,16 +16,21 @@ public:
 	{
 	}
 
+	/**
+	 * @returns Name of the function: "and"
+	 */
+	std::string raw_name() const {
+		return "and";
+	}
+
 protected :
 	/**
 	 * "And" predicate evaluates each expression from left to right,
      * and returns False once an expression evaluating to False is found.
      * If all expressions were True, it returns True.
 	 */
-	virtual BaseRetValPtr apply_internal(
-		const FunExecContext& context) const;
+	BaseRetValPtr apply_internal(const FunExecContext& context) const;
 
-	virtual const std::string raw_operator_name() const;
 };
 
 } /* end ns Wccl */
diff --git a/libwccl/ops/conditional.h b/libwccl/ops/conditional.h
index 580b02d..03485d0 100644
--- a/libwccl/ops/conditional.h
+++ b/libwccl/ops/conditional.h
@@ -36,19 +36,22 @@ public:
 
 	/**
 	 * String representation of conditional operator in form of:
-	 * "if cond_expr_string then iftrue_expr_string else iffalse_expr_string"
+	 * "if(cond_expr_string, iftrue_expr_string, iffalse_expr_string)"
 	 */
-	virtual std::string to_string(const Corpus2::Tagset& tagset) const;
+	std::string to_string(const Corpus2::Tagset& tagset) const;
 
 	/**
 	 * String representation of conditional operator in form of:
-	 * "if cond_expr_raw_s then iftrue_expr_raw_s else iffalse_expr_raw_s"
+	 * "if(cond_expr_raw_s, iftrue_expr_raw_s, iffalse_expr_raw_s)"
 	 * This version does not require tagset, but may be inclomplete
 	 * and/or contain internal info.
 	 */
-	virtual std::string to_raw_string() const;
+	std::string to_raw_string() const;
 
-	virtual const std::string raw_operator_name() const {
+	/**
+	 * @returns Name of the function: "if"
+	 */
+	std::string raw_name() const {
 		return "if";
 	}
 
@@ -68,7 +71,7 @@ protected:
 	 * iftrue_expression. If predicate is false, evalute and return value
 	 * of iffalse_expression.
 	 */
-	virtual BaseRetValPtr apply_internal(const FunExecContext& context) const {
+	BaseRetValPtr apply_internal(const FunExecContext& context) const {
 		if(this->cond_expr_->apply(context)->get_value()) {
 			return iftrue_expr_->apply(context);
 		}
@@ -97,20 +100,23 @@ public:
 	}
 
 	/**
-	 * String representation of conditional operator in form of:
+	 * @returns String representation of conditional operator in form of:
 	 * "? if_true_expr_string ? cond_expr_string"
 	 */
-	virtual std::string to_string(const Corpus2::Tagset& tagset) const;
+	std::string to_string(const Corpus2::Tagset& tagset) const;
 
 	/**
-	 * String representation of conditional operator in form of:
+	 * @returns String representation of conditional operator in form of:
 	 * "? if_true_expr_raw_string ? cond_expr_raw_string"
-	 * This version does not require tagset, but may be inclomplete
+	 * @note This version does not require tagset, but may be inclomplete
 	 * and/or contain internal info.
 	 */
-	virtual std::string to_raw_string() const;
+	std::string to_raw_string() const;
 
-	virtual const std::string raw_operator_name() const {
+	/**
+	 * @returns Name of the function: "?".
+	 */
+	std::string raw_name() const {
 		return "?";
 	}
 };
@@ -120,7 +126,7 @@ std::string Conditional<T>::to_raw_string() const
 {
 	std::stringstream ss;
 	ss << boost::format("%1%(%2%, %3%, %4%)")
-			% this->raw_operator_name()
+			% this->raw_name()
 			% this->cond_expr_->to_raw_string()
 			% this->iftrue_expr_->to_raw_string()
 			% this->iffalse_expr_->to_raw_string();
@@ -132,7 +138,7 @@ std::string Conditional<T>::to_string(const Corpus2::Tagset &tagset) const
 {
 	std::stringstream ss;
 	ss << boost::format("%1%(%2%, %3%, %4%)")
-			% this->operator_name(tagset)
+			% this->name(tagset)
 			% this->cond_expr_->to_string(tagset)
 			% this->iftrue_expr_->to_string(tagset)
 			% this->iffalse_expr_->to_string(tagset);
@@ -145,7 +151,7 @@ std::string ConditionalOp<T>::to_raw_string() const
 {
 	std::stringstream ss;
 	ss << boost::format("%1% %2% ? %3%")
-			% this->raw_operator_name()
+			% this->raw_name()
 			% this->iftrue_expr_->to_raw_string()
 			% this->cond_expr_->to_raw_string();
 	return ss.str();
@@ -156,7 +162,7 @@ std::string ConditionalOp<T>::to_string(const Corpus2::Tagset &tagset) const
 {
 	std::stringstream ss;
 	ss << boost::format("%1% %2% ? %3%")
-			% this->operator_name(tagset)			
+			% this->name(tagset)			
 			% this->iftrue_expr_->to_string(tagset)
 			% this->cond_expr_->to_string(tagset);
 	return ss.str();
diff --git a/libwccl/ops/constant.h b/libwccl/ops/constant.h
index c9bb5d8..3620c55 100644
--- a/libwccl/ops/constant.h
+++ b/libwccl/ops/constant.h
@@ -23,22 +23,31 @@ public:
 	{
 		BOOST_ASSERT(value_);
 	}
-	
+
+	/**
+	 * @returns Name of the function: "const".
+	 */
+	std::string raw_name() const {
+		return "const";
+	}
+
 	/**
-	 * Operator name for constant is string representation of its value
+	 * @returns String representation of the Constant, which is the
+	 * the string representation of the underlying Value.
 	 */
-	virtual const std::string operator_name(const Corpus2::Tagset& tagset) const {
+	std::string to_string(const Corpus2::Tagset& tagset) const {
 		return value_->to_string(tagset);
 	}
 
 	/**
-	 * Operator name for constant is string representation of its value,
-	 * tagset-independent in this case
+	 * @returns String representation of the Constant that does
+	 * not require a tagset. It is same as raw string representation
+	 * of underlying Value.
+	 * @note May be incomplete and/or containt internal info.
 	 */
-	virtual const std::string raw_operator_name() const {
+	std::string to_raw_string() const {
 		return value_->to_raw_string();
 	}
-
 protected :
 	typedef FunctionBase::BaseRetValPtr BaseRetValPtr ;
 	/**
diff --git a/libwccl/ops/equals.h b/libwccl/ops/equals.h
index 3aea68b..06bc4ad 100644
--- a/libwccl/ops/equals.h
+++ b/libwccl/ops/equals.h
@@ -61,15 +61,28 @@ public:
 		BOOST_ASSERT(arg2_expr_);
 	}
 
-	virtual std::string to_string(const Corpus2::Tagset& tagset) const {
+	/**
+	 * @returns String representation of the function in form of:
+	 * "equals(arg1_expr_string, arg2_expr_string)"
+	 */
+	std::string to_string(const Corpus2::Tagset& tagset) const {
 		return BinaryFunctionFormatter::to_string(tagset, *this, *arg1_expr_, *arg2_expr_);
 	}
 
-	virtual std::string to_raw_string() const {
+	/**
+	 * @returns String representation of the function in form of:
+	 * "equals(arg1_expr_raw_string, arg2_expr_raw_string)".
+	 * @note This version does not require tagset but may be incomplete
+	 * and/or contain internal info.
+	 */
+	std::string to_raw_string() const {
 		return BinaryFunctionFormatter::to_raw_string(*this, *arg1_expr_, *arg2_expr_);
 	}
 
-	virtual const std::string raw_operator_name() const {
+	/**
+	 * @returns Name of the function: "equals".
+	 */
+	std::string raw_name() const {
 		return "equals";
 	}
 
@@ -81,7 +94,7 @@ protected:
 	 * Take values of arguments from expressions and return True if they are equal,
 	 * False otherwise.
 	 */
-	virtual BaseRetValPtr apply_internal(const FunExecContext& context) const {
+	BaseRetValPtr apply_internal(const FunExecContext& context) const {
 		return EqualityComparer<T>::apply(
 			*(this->arg1_expr_->apply(context)),
 			*(this->arg2_expr_->apply(context)),
diff --git a/libwccl/ops/formatters.cpp b/libwccl/ops/formatters.cpp
index a9bb0cf..122bc8e 100644
--- a/libwccl/ops/formatters.cpp
+++ b/libwccl/ops/formatters.cpp
@@ -12,7 +12,7 @@ std::string UnaryFunctionFormatter::to_raw_string(
 	const char* close_bracket)
 {
 	std::stringstream ss;
-	ss << f.raw_operator_name() << open_bracket << arg_str << close_bracket;
+	ss << f.raw_name() << open_bracket << arg_str << close_bracket;
 	return ss.str();
 }
 
@@ -24,7 +24,7 @@ std::string UnaryFunctionFormatter::to_string(
 	const char* close_bracket)
 {
 	std::stringstream ss;
-	ss << f.operator_name(tagset) << open_bracket << arg_str << close_bracket;
+	ss << f.name(tagset) << open_bracket << arg_str << close_bracket;
 	return ss.str();
 }
 
@@ -37,7 +37,7 @@ std::string BinaryFunctionFormatter::to_string(
 	const std::string& arg2_str)
 {
 	std::stringstream ss;
-	ss << f.operator_name(tagset) << "(" << arg1_str << ", " << arg2_str << ")";
+	ss << f.name(tagset) << "(" << arg1_str << ", " << arg2_str << ")";
 	return ss.str();
 }
 
@@ -47,7 +47,7 @@ std::string BinaryFunctionFormatter::to_raw_string(
 	const std::string& arg2_str)
 {
 	std::stringstream ss;
-	ss << f.raw_operator_name() << "(" << arg1_str << ", " << arg2_str << ")";
+	ss << f.raw_name() << "(" << arg1_str << ", " << arg2_str << ")";
 	return ss.str();
 }
 
diff --git a/libwccl/ops/functions.h b/libwccl/ops/functions.h
index bda8751..ea3b55d 100644
--- a/libwccl/ops/functions.h
+++ b/libwccl/ops/functions.h
@@ -6,7 +6,7 @@
 #include <boost/mpl/assert.hpp>
 #include <boost/type_traits/is_base_of.hpp>
 
-#include <libwccl/ops/operator.h>
+#include <libwccl/ops/expression.h>
 #include <libwccl/values/value.h>
 #include <libwccl/ops/funexeccontext.h>
 
@@ -15,8 +15,26 @@ namespace Wccl {
 /**
  * Abstract base class for WCCL operators that are functions returning a Value
  */
-class FunctionBase : public Operator {
+class FunctionBase : public Expression
+{
+public:
+	/**
+	 * @returns Name of the function. By default it is same as raw name.
+	 */
+	virtual const std::string name(const Corpus2::Tagset&) const {
+		return raw_name();
+	}
+	/**
+	 * @returns A representation of function's name that does
+	 * not require a tagset.
+	 * @note May be incomplete and/or contain internal info.
+	 */
+	virtual std::string raw_name() const = 0;
 protected:
+	/**
+	 * Base type returned after application of function
+	 * (shared pointer to a const Value)
+	 */
 	typedef boost::shared_ptr<const Value> BaseRetValPtr;
 	/**
 	 * Applies the function for the given execution context.
diff --git a/libwccl/ops/intersects.h b/libwccl/ops/intersects.h
index 39ed272..82fdd3c 100644
--- a/libwccl/ops/intersects.h
+++ b/libwccl/ops/intersects.h
@@ -17,7 +17,10 @@ public:
 	{
 	}
 
-	virtual const std::string raw_operator_name() const {
+	/**
+	 * @returns Name of the function: "inter"
+	 */
+	std::string raw_name() const {
 		return "inter";
 	}
 
@@ -26,7 +29,7 @@ protected:
 	 * Take values for both sets and return True if they intersect,
 	 * False otherwise.
 	 */
-	virtual BaseRetValPtr apply_internal(const FunExecContext& context) const {
+	BaseRetValPtr apply_internal(const FunExecContext& context) const {
 		boost::shared_ptr<T> set1 = this->set1_expr_->apply(context);
 		boost::shared_ptr<T> set2 = this->set2_expr_->apply(context);
 		return Predicate::evaluate(set1->intersects(*set2), context);
diff --git a/libwccl/ops/isinside.h b/libwccl/ops/isinside.h
index 0acbb86..7ea1f1f 100644
--- a/libwccl/ops/isinside.h
+++ b/libwccl/ops/isinside.h
@@ -20,15 +20,26 @@ public:
 		BOOST_ASSERT(pos_expr_);
 	}
 
-	virtual std::string to_string(const Corpus2::Tagset& tagset) const {
+	/**
+	 * @returns String representation of the function in the form of:
+	 * "inside(arg_expr_string)"
+	 */
+	std::string to_string(const Corpus2::Tagset& tagset) const {
 		return UnaryFunctionFormatter::to_string(tagset, *this, *pos_expr_);
 	}
 
-	virtual std::string to_raw_string() const {
+	/**
+	 * @returns String representation of the function in the form of:
+	 * "inside(arg_expr_raw_string)"
+	 */
+	std::string to_raw_string() const {
 		return UnaryFunctionFormatter::to_raw_string(*this, *pos_expr_);
 	}
 
-	virtual const std::string raw_operator_name() const {
+	/**
+	 * @returns Name of the function: "inside"
+	 */
+	std::string raw_name() const {
 		return "inside";
 	}
 
@@ -40,7 +51,7 @@ protected:
 	 * boundaries.
 	 * @returns True value if position is within sentence boundaries, False otherwise.
 	 */
-	virtual BaseRetValPtr apply_internal(const FunExecContext& context) const {
+	BaseRetValPtr apply_internal(const FunExecContext& context) const {
 		const boost::shared_ptr<const Position>& pos = pos_expr_->apply(context);
 		return Predicate::evaluate(pos->is_inside(context.sentence_context()), context);
 	}
diff --git a/libwccl/ops/isoutside.h b/libwccl/ops/isoutside.h
index f32591d..17322e7 100644
--- a/libwccl/ops/isoutside.h
+++ b/libwccl/ops/isoutside.h
@@ -20,15 +20,26 @@ public:
 		BOOST_ASSERT(pos_expr_);
 	}
 
-	virtual std::string to_string(const Corpus2::Tagset& tagset) const {
+	/**
+	 * @returns String representation of the function in the form of:
+	 * "outside(arg_expr_string)"
+	 */
+	std::string to_string(const Corpus2::Tagset& tagset) const {
 		return UnaryFunctionFormatter::to_string(tagset, *this, *pos_expr_);
 	}
 
-	virtual std::string to_raw_string() const {
+	/**
+	 * @returns String representation of the function in the form of:
+	 * "outside(arg_expr_raw_string)"
+	 */
+	std::string to_raw_string() const {
 		return UnaryFunctionFormatter::to_raw_string(*this, *pos_expr_);
 	}
 
-	virtual const std::string raw_operator_name() const {
+	/**
+	 * @returns Name of the function: "outside"
+	 */
+	std::string raw_name() const {
 		return "outside";
 	}
 
@@ -40,7 +51,7 @@ protected:
 	 * sentence boundaries, in the given context (i.e. relative to current position)
 	 * @returns True value if position is outside of the sentence boundaries, False otherwise.
 	 */
-	virtual BaseRetValPtr apply_internal(const FunExecContext& context) const {
+	BaseRetValPtr apply_internal(const FunExecContext& context) const {
 		const boost::shared_ptr<const Position>& pos = pos_expr_->apply(context);
 		return Predicate::evaluate(pos->is_outside(context.sentence_context()), context);
 	}
diff --git a/libwccl/ops/issubsetof.h b/libwccl/ops/issubsetof.h
index 0fd276f..d8536de 100644
--- a/libwccl/ops/issubsetof.h
+++ b/libwccl/ops/issubsetof.h
@@ -6,7 +6,8 @@
 namespace Wccl {
 
 /**
- * Class that realises a predicate checking if one set is a subset of another
+ * Class that realises a predicate checking if one set is in another.
+ * Almost like being a subset of, but empty set is considered not to be "in".
  */
 template <class T>
 class IsSubsetOf : public SetPredicate<T>
@@ -19,7 +20,10 @@ public:
 	{
 	}
 
-	virtual const std::string raw_operator_name() const {
+	/**
+	 * @returns Name of the function: "in"
+	 */
+	std::string raw_name() const {
 		return "in";
 	}
 
@@ -27,10 +31,11 @@ protected:
 	/**
 	 * Take value of possible subset in question. If it is an empty set, return False.
 	 * Otherwise, take value of the set that is being compared to.
-	 * Return True if the possible subset is indeed a subset of the compared set,
-	 * otherwise return False.
+	 * @returns True if the possible subset is inside set compared to.
+	 * @note Take note this is not true "subset" function, because empty
+	 * set is considered not to be "in" any other set so False is returned.
 	 */
-	virtual BaseRetValPtr apply_internal(const FunExecContext& context) const {
+	BaseRetValPtr apply_internal(const FunExecContext& context) const {
 		boost::shared_ptr<T> possible_subset = this->set1_expr_->apply(context);
 		if(!possible_subset->empty())
 		{
diff --git a/libwccl/ops/logicalpredicate.cpp b/libwccl/ops/logicalpredicate.cpp
index c00be52..66945ab 100644
--- a/libwccl/ops/logicalpredicate.cpp
+++ b/libwccl/ops/logicalpredicate.cpp
@@ -7,7 +7,7 @@ namespace Wccl {
 std::string LogicalPredicate::to_string(const Corpus2::Tagset& tagset) const
 {
 	std::stringstream ss;
-	ss << operator_name(tagset) << "(";
+	ss << name(tagset) << "(";
 	BoolFunctionPtrVector::const_iterator it = expressions_->begin();
 	while(it != expressions_->end()) {
 		ss << (*it)->to_string(tagset);
@@ -22,7 +22,7 @@ std::string LogicalPredicate::to_string(const Corpus2::Tagset& tagset) const
 std::string LogicalPredicate::to_raw_string() const
 {
 	std::stringstream ss;
-	ss << raw_operator_name() << "(";
+	ss << raw_name() << "(";
 	BoolFunctionPtrVector::const_iterator it = expressions_->begin();
 	while(it != expressions_->end()) {
 		ss << (*it)->to_raw_string();
diff --git a/libwccl/ops/logicalpredicate.h b/libwccl/ops/logicalpredicate.h
index 02c6280..7d439b6 100644
--- a/libwccl/ops/logicalpredicate.h
+++ b/libwccl/ops/logicalpredicate.h
@@ -26,7 +26,7 @@ public:
 	 * String representation of the logical predicate, realised by default
 	 * as "operator_name(expr1_string, ..., exprn_string)"
 	 */
-	virtual std::string to_string(const Corpus2::Tagset& tagset) const;
+	std::string to_string(const Corpus2::Tagset& tagset) const;
 
 	/**
 	 * String representation of the logical predicate, realised by default
@@ -34,7 +34,7 @@ public:
 	 * (this version doesn't require tagset, but may be incomplete and/or
 	 * contain internal info)
 	 */
-	virtual std::string to_raw_string() const;
+	std::string to_raw_string() const;
 
 protected:
 	const boost::shared_ptr<BoolFunctionPtrVector> expressions_;
diff --git a/libwccl/ops/nor.cpp b/libwccl/ops/nor.cpp
index 50a8a4c..480025b 100644
--- a/libwccl/ops/nor.cpp
+++ b/libwccl/ops/nor.cpp
@@ -14,8 +14,4 @@ Nor::BaseRetValPtr Nor::apply_internal(const FunExecContext& context) const
 	return Predicate::True(context);
 }
 
-const std::string Nor::raw_operator_name() const {
-	return "not";
-}
-
 } /* end ns Wccl */
diff --git a/libwccl/ops/nor.h b/libwccl/ops/nor.h
index 1b5e10a..6374ad8 100644
--- a/libwccl/ops/nor.h
+++ b/libwccl/ops/nor.h
@@ -17,6 +17,13 @@ public:
 	{
 	}
 
+	/**
+	 * @returns Name of the function: "not"
+	 */
+	std::string raw_name() const {
+		return "not";
+	}
+
 protected :
 	/**
 	 * "Nor" (aka "not") predicate evaluates expressions one by one in order
@@ -24,9 +31,8 @@ protected :
      * to True is found.
 	 * If all of the expressions were False, True is returned.
 	 */
-	virtual BaseRetValPtr apply_internal(const FunExecContext&) const;
+	BaseRetValPtr apply_internal(const FunExecContext&) const;
 
-	virtual const std::string raw_operator_name() const;
 };
 
 } /* end ns Wccl */
diff --git a/libwccl/ops/or.cpp b/libwccl/ops/or.cpp
index af3d03e..24ce201 100644
--- a/libwccl/ops/or.cpp
+++ b/libwccl/ops/or.cpp
@@ -14,8 +14,4 @@ Or::BaseRetValPtr Or::apply_internal(const FunExecContext& context) const
 	return Predicate::False(context);
 }
 
-const std::string Or::raw_operator_name() const {
-	return "or";
-}
-
 } /* end ns Wccl */
diff --git a/libwccl/ops/or.h b/libwccl/ops/or.h
index 22b3597..0a60d69 100644
--- a/libwccl/ops/or.h
+++ b/libwccl/ops/or.h
@@ -16,15 +16,20 @@ public:
 	{
 	}
 
+	/**
+	 * @returns Name of the function: "or"
+	 */
+	std::string raw_name() const {
+		return "or";
+	}
 protected :
 	/**
 	 * "Or" predicate evaluates expressions one by one in order from left to right,
 	 * and True is returned once an expression evaluating to True is found.
 	 * If all of the expressions were False, False is returned.
 	 */
-	virtual BaseRetValPtr apply_internal(const FunExecContext&) const;
+	BaseRetValPtr apply_internal(const FunExecContext&) const;
 
-	virtual const std::string raw_operator_name() const;
 };
 
 } /* end ns Wccl */
diff --git a/libwccl/ops/regex.cpp b/libwccl/ops/regex.cpp
index c059324..1d0ac36 100644
--- a/libwccl/ops/regex.cpp
+++ b/libwccl/ops/regex.cpp
@@ -60,14 +60,14 @@ Regex::Regex(const Regex::StrSetFunctionPtr &strset_expr, const UnicodeString &p
 std::string Regex::to_string(const Corpus2::Tagset& tagset) const
 {
 	std::stringstream ss;
-	ss << operator_name(tagset) << "(" << strset_expr_->to_string(tagset)
+	ss << name(tagset) << "(" << strset_expr_->to_string(tagset)
 		<< ", \"" << PwrNlp::to_utf8(patstr_) << "\")"; //TODO: utf escaping?
 	return ss.str();
 }
 
 std::string Regex::to_raw_string() const {
 	std::stringstream ss;
-	ss << raw_operator_name() << "(" << strset_expr_->to_raw_string()
+	ss << raw_name() << "(" << strset_expr_->to_raw_string()
 		<< ", \"" << PwrNlp::to_utf8(patstr_) << "\")"; //TODO: utf escaping?
 	return ss.str();
 }
diff --git a/libwccl/ops/regex.h b/libwccl/ops/regex.h
index 7c87cf9..1c738c1 100644
--- a/libwccl/ops/regex.h
+++ b/libwccl/ops/regex.h
@@ -21,20 +21,23 @@ public:
 	Regex(const StrSetFunctionPtr& strset_expr, const UnicodeString& patstr);
 
 	/**
-	 * String representation of the operator in form of:
+	 * @returns String representation of the function in form of:
 	 * "regex(strset_expr_string, regex_string)"
 	 */
-	virtual std::string to_string(const Corpus2::Tagset& tagset) const;
+	std::string to_string(const Corpus2::Tagset& tagset) const;
 
 	/**
-	 * String representation of conditional operator in form of:
+	 * @returns String representation of the function in form of:
 	 * "regex(strset_expr_raw_string, regex_string)"
-	 * This version does not require tagset, but may be inclomplete
+	 * @note This version does not require a tagset, but may be inclomplete
 	 * and/or contain internal info.
 	 */
-	virtual std::string to_raw_string() const;
+	std::string to_raw_string() const;
 
-	virtual const std::string raw_operator_name() const {
+	/**
+	 * @returns Name of the function: "regex"
+	 */
+	std::string raw_name() const {
 		return "regex";
 	}
 
@@ -45,7 +48,7 @@ protected:
 	 * return false if a string not matching expression is found.
 	 * Return true if all strings matched the regular espression.
 	 */
-	virtual BaseRetValPtr apply_internal(const FunExecContext& context) const;
+	BaseRetValPtr apply_internal(const FunExecContext& context) const;
 
 private:
 	const StrSetFunctionPtr strset_expr_;
diff --git a/libwccl/ops/relativeposition.h b/libwccl/ops/relativeposition.h
index 2fb9961..dc27cae 100644
--- a/libwccl/ops/relativeposition.h
+++ b/libwccl/ops/relativeposition.h
@@ -22,12 +22,22 @@ public:
 		BOOST_ASSERT(pos_expr_);
 	}
 
-	virtual std::string to_string(const Corpus2::Tagset& tagset) const;
-
-	virtual std::string to_raw_string() const;
+	/**
+	 * @returns String representation of the function in the form of:
+	 * "arg_expr_string [+-] offset"
+	 */
+	std::string to_string(const Corpus2::Tagset& tagset) const;
+	/**
+	 * @returns String representation of the function in the form of:
+	 * "arg_expr_raw_string [+-] offset"
+	 */
+	std::string to_raw_string() const;
 
-	virtual const std::string raw_operator_name() const {
-		return "+";
+	/**
+	 * @returns Name of the function: "relpos"
+	 */
+	std::string raw_name() const {
+		return "relpos";
 	}
 
 protected:
@@ -49,7 +59,7 @@ protected:
 	 * @returns Position that is shifted by the represented offset relative
 	 * to the Position being passed as argument to Operator.
 	 */
-	virtual BaseRetValPtr apply_internal(const FunExecContext& context) const;
+	BaseRetValPtr apply_internal(const FunExecContext& context) const;
 };
 
 } /* end ns Wccl */
diff --git a/libwccl/ops/setpredicate.h b/libwccl/ops/setpredicate.h
index c8e0ca9..8886b5b 100644
--- a/libwccl/ops/setpredicate.h
+++ b/libwccl/ops/setpredicate.h
@@ -27,11 +27,21 @@ public:
 		BOOST_ASSERT(set2_expr_);
 	}
 
-	virtual std::string to_string(const Corpus2::Tagset& tagset) const {
+	/**
+	 * @returns String representation of the function in form of:
+	 * "name_string(arg1_expr_string, arg2_expr_string)"
+	 */
+	std::string to_string(const Corpus2::Tagset& tagset) const {
 		return BinaryFunctionFormatter::to_string(tagset, *this, *set1_expr_, *set2_expr_);
 	}
 
-	virtual std::string to_raw_string() const {
+	/**
+	 * @returns String representation of the function in form of:
+	 * "raw_name_string(arg1_expr_raw_string, arg2_expr_raw_string)"
+	 * @note This version does not require a tagset, but may be inclomplete
+	 * and/or contain internal info.
+	 */	
+	std::string to_raw_string() const {
 		return BinaryFunctionFormatter::to_raw_string(*this, *set1_expr_, *set2_expr_);
 	}
 
diff --git a/libwccl/ops/tolower.h b/libwccl/ops/tolower.h
index 6f7bd30..28175f1 100644
--- a/libwccl/ops/tolower.h
+++ b/libwccl/ops/tolower.h
@@ -21,20 +21,23 @@ public:
 	}
 
 	/**
-	 * String representation of the operator in form of:
+	 * @returns String representation of the function in the form of:
 	 * "lower(strset_expr_string)"
 	 */
-	virtual std::string to_string(const Corpus2::Tagset& tagset) const;
+	std::string to_string(const Corpus2::Tagset& tagset) const;
 
 	/**
-	 * String representation of conditional operator in form of:
+	 * @returns String representation of the function in the form of:
 	 * "lower(strset_expr_raw_string)"
-	 * This version does not require tagset, but may be inclomplete
+	 * @note This version does not require tagset, but may be inclomplete
 	 * and/or contain internal info.
 	 */
-	virtual std::string to_raw_string() const;
+	std::string to_raw_string() const;
 
-	virtual const std::string raw_operator_name() const {
+	/**
+	 * @returns Name of the function: "lower"
+	 */
+	std::string raw_name() const {
 		return "lower";
 	}
 
@@ -45,7 +48,7 @@ protected:
 	 * Get a string set from the argument expression and return copy of the set
 	 * with all strings in lower case form
 	 */
-	virtual BaseRetValPtr apply_internal(const FunExecContext& context) const;
+	BaseRetValPtr apply_internal(const FunExecContext& context) const;
 };
 
 } /* end ns Wccl */
diff --git a/libwccl/ops/toupper.h b/libwccl/ops/toupper.h
index c3414d3..e550e54 100644
--- a/libwccl/ops/toupper.h
+++ b/libwccl/ops/toupper.h
@@ -21,23 +21,25 @@ public:
 	}
 
 	/**
-	 * String representation of the operator in form of:
+	 * @returns String representation of the function in the form of:
 	 * "upper(strset_expr_string)"
 	 */
-	virtual std::string to_string(const Corpus2::Tagset& tagset) const;
+	std::string to_string(const Corpus2::Tagset& tagset) const;
 
 	/**
-	 * String representation of conditional operator in form of:
+	 * @returns String representation of the function in the form of:
 	 * "upper(strset_expr_raw_string)"
-	 * This version does not require tagset, but may be inclomplete
+	 * @note This version does not require tagset, but may be inclomplete
 	 * and/or contain internal info.
 	 */
-	virtual std::string to_raw_string() const;
+	std::string to_raw_string() const;
 
-	virtual const std::string raw_operator_name() const {
+	/**
+	 * @returns Name of the function: "upper"
+	 */
+	std::string raw_name() const {
 		return "upper";
 	}
-
 protected:
 	const StrSetFunctionPtr strset_expr_;
 
@@ -45,7 +47,7 @@ protected:
 	 * Get a string set from the argument expression and return copy of the set
 	 * with all strings in upper case form
 	 */
-	virtual BaseRetValPtr apply_internal(const FunExecContext& context) const;
+	BaseRetValPtr apply_internal(const FunExecContext& context) const;
 };
 
 } /* end ns Wccl */
diff --git a/libwccl/ops/vargetter.h b/libwccl/ops/vargetter.h
index 9224086..d6f07ec 100644
--- a/libwccl/ops/vargetter.h
+++ b/libwccl/ops/vargetter.h
@@ -5,7 +5,6 @@
 
 namespace Wccl {
 
-
 /**
  * Operator that returns value of a variable of given type T
  */
@@ -18,18 +17,17 @@ public:
 	}
 	
 	/**
-	 * @returns Operator name for variable getter, we assume "$", although real
-	 * string representation depends on given Value's var_repr function
+	 * @returns Function name for variable getter: "getvar"
 	 */
-	virtual const std::string raw_operator_name() const {
-		return "$";
+	std::string raw_name() const {
+		return "getvar";
 	}
 
 	/**
 	 * @returns String representation of the variable getter which is
 	 * equal to string representation of the underlying variable.
 	 */
-	virtual std::string to_raw_string() const {
+	std::string to_raw_string() const {
 		return T::var_repr(var_acc_.get_name());
 	}
 
@@ -37,15 +35,16 @@ public:
 	 * @returns String representation of the variable getter which is
 	 * equal to string representation of the underlying variable.
 	 */
-	virtual std::string to_string(const Corpus2::Tagset&) const {
+	std::string to_string(const Corpus2::Tagset&) const {
 		return T::var_repr(var_acc_.get_name());
 	}
+
 protected:
 	typedef FunctionBase::BaseRetValPtr BaseRetValPtr;
 	/**
 	 * Return value held by the underlying variable.
 	 */
-	virtual BaseRetValPtr apply_internal(const FunExecContext& context) const {
+	BaseRetValPtr apply_internal(const FunExecContext& context) const {
 		return context.variables()->get_fast(var_acc_);
 	}
 
diff --git a/libwccl/ops/varsetter.h b/libwccl/ops/varsetter.h
index 0dcbbce..4bfbdc9 100644
--- a/libwccl/ops/varsetter.h
+++ b/libwccl/ops/varsetter.h
@@ -23,17 +23,19 @@ public:
 	}
 	
 	/**
-	 * @returns Operator name for variable setter, "setvar"
+	 * @returns Function name for variable setter: "setvar"
 	 */
-	virtual const std::string raw_operator_name() const {
+	std::string raw_name() const {
 		return "setvar";
 	}
 
 	/**
 	 * @returns String representation of the variable setter which is
 	 * setvar(var_repr, arg_expr_str)
+	 * @note This version does not require a tagset, but may be incomplete
+	 * and/or contain internal info.
 	 */
-	virtual std::string to_raw_string() const {
+	std::string to_raw_string() const {
 		return BinaryFunctionFormatter::to_raw_string(
 			*this,
 			T::var_repr(var_acc_.get_name()),
@@ -44,7 +46,7 @@ public:
 	 * @returns String representation of the variable setter which is
 	 * setvar(var_repr, arg_raw_expr_str)
 	 */
-	virtual std::string to_string(const Corpus2::Tagset& tagset) const {
+	std::string to_string(const Corpus2::Tagset& tagset) const {
 		return BinaryFunctionFormatter::to_string(
 			tagset,
 			*this, 
@@ -56,7 +58,7 @@ protected:
 	 * Evaluate argument expression and assign the result to underlying variable.
 	 * @returns True.
 	 */
-	virtual BaseRetValPtr apply_internal(const FunExecContext& context) const {
+	BaseRetValPtr apply_internal(const FunExecContext& context) const {
 		context.variables()->get_fast(var_acc_)->set_value(
 			arg_expr_->apply(context)->get_value());
 		return Predicate::True(context);
-- 
GitLab