From 789baf30c8b29775c797ec322731d92ffac5810d Mon Sep 17 00:00:00 2001
From: Jan Travnicek <Jan.Travnicek@fit.cvut.cz>
Date: Wed, 11 Apr 2018 21:46:50 +0200
Subject: [PATCH] finish documentation of RTEs

---
 .../src/rte/formal/FormalRTEAlternation.h     | 106 ++++++++++++--
 alib2data/src/rte/formal/FormalRTEEmpty.h     |  51 ++++++-
 alib2data/src/rte/formal/FormalRTEIteration.h | 105 ++++++++++++--
 .../src/rte/formal/FormalRTESubstitution.h    | 129 ++++++++++++++++--
 alib2data/src/rte/formal/FormalRTESymbol.h    |  53 ++++++-
 .../src/rte/formal/FormalRTESymbolAlphabet.h  |  79 ++++++++++-
 .../src/rte/formal/FormalRTESymbolSubst.h     |  62 ++++++++-
 7 files changed, 537 insertions(+), 48 deletions(-)

diff --git a/alib2data/src/rte/formal/FormalRTEAlternation.h b/alib2data/src/rte/formal/FormalRTEAlternation.h
index 714e414367..bb3f362386 100644
--- a/alib2data/src/rte/formal/FormalRTEAlternation.h
+++ b/alib2data/src/rte/formal/FormalRTEAlternation.h
@@ -1,6 +1,22 @@
 /*
  * FormalRTEAlternation.h
  *
+ * This file is part of Algorithms library toolkit.
+ * Copyright (C) 2017 Jan Travnicek (jan.travnicek@fit.cvut.cz)
+
+ * Algorithms library toolkit is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+
+ * Algorithms library toolkit is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with Algorithms library toolkit.  If not, see <http://www.gnu.org/licenses/>.
+ *
  *  Created on: Feb 20, 2016
  *      Author: Tomas Pecka
  */
@@ -18,17 +34,39 @@
 namespace rte {
 
 /**
- * Represents alternation operator in the regular expression. Contains list of FormalRTEElement
- * as operands of the operator.
+ * \brief Represents the alternation operator in the regular tree expression. The node must have exactly two children.
+ *
+ * The structure is derived from BinaryNode that provides the children accessors.
+ *
+ * The node can be visited by the FormalRTEElement < SymbolType, RankType >::Visitor
+ *
+ * \tparam SymbolType used for the symbol part of the ranked symbol
+ * \tparam RankType used for the rank part of the ranked symbol
  */
 template < class SymbolType, class RankType >
 class FormalRTEAlternation : public FormalRTEElement < SymbolType, RankType >, public ext::BinaryNode < ext::smart_ptr < FormalRTEElement < SymbolType, RankType > >, ext::smart_ptr < FormalRTEElement < SymbolType, RankType > >, FormalRTEAlternation < SymbolType, RankType > > {
-public:
+	/**
+	 * @copydoc regexp::FormalRTEElement < SymbolType, RankType >::accept ( ) const
+	 */
 	virtual void accept ( typename FormalRTEElement < SymbolType, RankType >::Visitor & visitor ) const override {
 		visitor.visit ( * this );
 	}
 
+public:
+	/**
+	 * \brief Creates a new instance of the alternation node with explicit alternated elements
+	 *
+	 * \param left the first alternated element
+	 * \param right the second alternated element
+	 */
 	explicit FormalRTEAlternation ( FormalRTEElement < SymbolType, RankType > && left, FormalRTEElement < SymbolType, RankType > && right );
+
+	/**
+	 * \brief Creates a new instance of the alternation node with explicit alternated elements
+	 *
+	 * \param left the first alternated element
+	 * \param right the second alternated element
+	 */
 	explicit FormalRTEAlternation ( const FormalRTEElement < SymbolType, RankType > & left, const FormalRTEElement < SymbolType, RankType > & right );
 
 	/**
@@ -57,44 +95,92 @@ public:
 	virtual bool checkAlphabet ( const ext::set < common::ranked_symbol < SymbolType, RankType > > & alphabetF, const ext::set < common::ranked_symbol < SymbolType, RankType > > & alphabetK ) const override;
 
 	/**
-	 * @return elements
+	 * Getter of the left alternated element
+	 *
+	 * \return left alternated element
 	 */
 	const FormalRTEElement < SymbolType, RankType > & getLeftElement ( ) const;
+
+	/**
+	 * Getter of the right alternated element
+	 *
+	 * \return right alternated element
+	 */
 	const FormalRTEElement < SymbolType, RankType > & getRightElement ( ) const;
 
 	/**
-	 * @return elements
+	 * Getter of the left alternated element
+	 *
+	 * \return left alternated element
 	 */
 	FormalRTEElement < SymbolType, RankType > & getLeftElement ( );
+
+	/**
+	 * Getter of the right alternated element
+	 *
+	 * \return right alternated element
+	 */
 	FormalRTEElement < SymbolType, RankType > & getRightElement ( );
 
 	/**
-	 * @param element to append
+	 * Setter of the left alternated element
+	 *
+	 * \param element left alternated element
 	 */
-	void setLeftElement ( const FormalRTEElement < SymbolType, RankType > & element );
 	void setLeftElement ( FormalRTEElement < SymbolType, RankType > && element );
 
 	/**
-	 * @param element to append
+	 * Setter of the left alternated element
+	 *
+	 * \param element left alternated element
+	 */
+	void setLeftElement ( const FormalRTEElement < SymbolType, RankType > & element );
+
+	/**
+	 * Setter of the right alternated element
+	 *
+	 * \param element right alternated element
 	 */
-	void setRightElement ( const FormalRTEElement < SymbolType, RankType > & element );
 	void setRightElement ( FormalRTEElement < SymbolType, RankType > && element );
 
+	/**
+	 * Setter of the right alternated element
+	 *
+	 * \param element right alternated element
+	 */
+	void setRightElement ( const FormalRTEElement < SymbolType, RankType > & element );
+
+	/**
+	 * @copydoc alib::CommonBase < FormalRTEElement < SymbolType, RankType > >::compare ( const FormalRTEElement < SymbolType, RankType > & )
+	 */
 	virtual int compare ( const FormalRTEElement < SymbolType, RankType > & other ) const override {
 		if ( ext::type_index ( typeid ( * this ) ) == ext::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other );
 
 		return ext::type_index ( typeid ( * this ) ) - ext::type_index ( typeid ( other ) );
 	}
 
+	/**
+	 * The actual compare method
+	 *
+	 * \param other the other instance
+	 *
+	 * \returns the actual relation between two by type same node instances
+	 */
 	int compare ( const FormalRTEAlternation & ) const;
 
 	/**
-	 * @copydoc FormalRTEElement::operator>>() const
+	 * @copydoc alib::CommonBase < FormalRTEElement < SymbolType, RankType > >::operator >> ( std::ostream & )
 	 */
 	virtual void operator >>( std::ostream & out ) const override;
 
+	/**
+	 * @copydoc alib::CommonBase < FormalRTEElement < SymbolType, RankType > >::operator std::string ( )
+	 */
 	virtual explicit operator std::string ( ) const override;
 
+	/**
+	 * @copydoc regexp::FormalRTEElement < SymbolType, RankType >::normalize ( ) &&
+	 */
 	virtual ext::smart_ptr < FormalRTEElement < DefaultSymbolType, DefaultRankType > > normalize ( ) && override {
 		return ext::smart_ptr < FormalRTEElement < DefaultSymbolType, DefaultRankType > > ( new FormalRTEAlternation < DefaultSymbolType, DefaultRankType > ( std::move ( * std::move ( getLeftElement ( ) ).normalize ( ) ), std::move ( * std::move ( getRightElement ( ) ).normalize ( ) ) ) );
 	}
diff --git a/alib2data/src/rte/formal/FormalRTEEmpty.h b/alib2data/src/rte/formal/FormalRTEEmpty.h
index 3c53a3065f..d32272a683 100644
--- a/alib2data/src/rte/formal/FormalRTEEmpty.h
+++ b/alib2data/src/rte/formal/FormalRTEEmpty.h
@@ -1,6 +1,22 @@
 /*
  * FormalRTEEmpty.h
  *
+ * This file is part of Algorithms library toolkit.
+ * Copyright (C) 2017 Jan Travnicek (jan.travnicek@fit.cvut.cz)
+
+ * Algorithms library toolkit is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+
+ * Algorithms library toolkit is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with Algorithms library toolkit.  If not, see <http://www.gnu.org/licenses/>.
+ *
  *  Created on: Feb 20, 2016
  *      Author: Tomas Pecka
  */
@@ -14,15 +30,28 @@
 namespace rte {
 
 /**
- * Represents empty regular expression in the regular expression.
+ * \brief Represents the empty expression in the regular tree expression. The node can't have any children.
+ *
+ * The structure is derived from NullaryNode disallowing adding any child.
+ *
+ * The node can be visited by the FormalRTEElement < SymbolType, RankType >::Visitor
+ *
+ * \tparam SymbolType used for the symbol part of the ranked symbol
+ * \tparam RankType used for the rank part of the ranked symbol
  */
 template < class SymbolType, class RankType >
 class FormalRTEEmpty : public FormalRTEElement < SymbolType, RankType > {
-public:
+	/**
+	 * @copydoc regexp::FormalRTEElement < SymbolType, RankType >::accept ( ) const
+	 */
 	virtual void accept ( typename FormalRTEElement < SymbolType, RankType >::Visitor & visitor ) const override {
 		visitor.visit ( * this );
 	}
 
+public:
+	/**
+	 * \brief Creates a new instance of the empty node.
+	 */
 	explicit FormalRTEEmpty ( );
 
 	/**
@@ -50,21 +79,37 @@ public:
 	 */
 	virtual bool checkAlphabet ( const ext::set < common::ranked_symbol < SymbolType, RankType > > & alphabetF, const ext::set < common::ranked_symbol < SymbolType, RankType > > & alphabetK ) const override;
 
+	/**
+	 * @copydoc alib::CommonBase < FormalRTEElement < SymbolType, RankType > >::compare ( const FormalRTEElement < SymbolType, RankType > & )
+	 */
 	virtual int compare ( const FormalRTEElement < SymbolType, RankType > & other ) const override {
 		if ( ext::type_index ( typeid ( * this ) ) == ext::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other );
 
 		return ext::type_index ( typeid ( * this ) ) - ext::type_index ( typeid ( other ) );
 	}
 
+	/**
+	 * The actual compare method
+	 *
+	 * \param other the other instance
+	 *
+	 * \returns the actual relation between two by type same node instances
+	 */
 	int compare ( const FormalRTEEmpty & ) const;
 
 	/**
-	 * @copydoc FormalRTEElement::operator>>() const
+	 * @copydoc alib::CommonBase < FormalRTEElement < SymbolType, RankType > >::operator >> ( std::ostream & )
 	 */
 	virtual void operator >>( std::ostream & out ) const override;
 
+	/**
+	 * @copydoc alib::CommonBase < FormalRTEElement < SymbolType, RankType > >::operator std::string ( )
+	 */
 	virtual explicit operator std::string ( ) const override;
 
+	/**
+	 * @copydoc regexp::FormalRTEElement < SymbolType, RankType >::normalize ( ) &&
+	 */
 	virtual ext::smart_ptr < FormalRTEElement < DefaultSymbolType, DefaultRankType > > normalize ( ) && override {
 		return ext::smart_ptr < FormalRTEElement < DefaultSymbolType, DefaultRankType > > ( new FormalRTEEmpty < DefaultSymbolType, DefaultRankType > ( ) );
 	}
diff --git a/alib2data/src/rte/formal/FormalRTEIteration.h b/alib2data/src/rte/formal/FormalRTEIteration.h
index e7f0011d84..f8be708776 100644
--- a/alib2data/src/rte/formal/FormalRTEIteration.h
+++ b/alib2data/src/rte/formal/FormalRTEIteration.h
@@ -1,6 +1,22 @@
 /*
  * FormalRTEIteration.h
  *
+ * This file is part of Algorithms library toolkit.
+ * Copyright (C) 2017 Jan Travnicek (jan.travnicek@fit.cvut.cz)
+
+ * Algorithms library toolkit is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+
+ * Algorithms library toolkit is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with Algorithms library toolkit.  If not, see <http://www.gnu.org/licenses/>.
+ *
  *  Created on: Feb 20, 2016
  *      Author: Tomas Pecka
  */
@@ -19,21 +35,45 @@
 namespace rte {
 
 /**
- * Represents iteration operator in the regular expression. Contains one FormalRTEElement
- * as operand.
+ * \brief Represents the iteration operator in the regular tree expression. The node has exactly one child.
+ *
+ * The structure is derived from UnaryNode that provides the child node and its accessors.
+ *
+ * The node can be visited by the FormalRegExpElement < SymbolType, RankType >::Visitor
+ *
+ * \tparam SymbolType used for the symbol part of the ranked symbol
+ * \tparam RankType used for the rank part of the ranked symbol
  */
 template < class SymbolType, class RankType >
 class FormalRTEIteration : public FormalRTEElement < SymbolType, RankType >, public ext::UnaryNode < ext::smart_ptr < FormalRTEElement < SymbolType, RankType > >, ext::smart_ptr < const FormalRTEElement < SymbolType, RankType > >, FormalRTEIteration < SymbolType, RankType > > {
-protected:
+	/**
+	 * The substitution symbol of the node. The symbol will be substitued in left tree by right
+	 */
 	ext::smart_ptr < FormalRTESymbolSubst < SymbolType, RankType > > m_substitutionSymbol;
 
-public:
+	/**
+	 * @copydoc regexp::FormalRTEElement < SymbolType, RankType >::accept ( ) const
+	 */
 	virtual void accept ( typename FormalRTEElement < SymbolType, RankType >::Visitor & visitor ) const override {
 		visitor.visit ( * this );
 	}
 
-	explicit FormalRTEIteration ( FormalRTEElement < SymbolType, RankType > &&, FormalRTESymbolSubst < SymbolType, RankType > );
-	explicit FormalRTEIteration ( const FormalRTEElement < SymbolType, RankType > &, FormalRTESymbolSubst < SymbolType, RankType > );
+public:
+	/**
+	 * \brief Creates a new instance of the substitution node with explicit tree to iterate and a symbol representing place of substitution
+	 *
+	 * \param element the tree to iterate
+	 * \param substitutionSymbol the symbol representing the substitution place
+	 */
+	explicit FormalRTEIteration ( FormalRTEElement < SymbolType, RankType > && element, FormalRTESymbolSubst < SymbolType, RankType > substitionSymbol );
+
+	/**
+	 * \brief Creates a new instance of the substitution node with explicit tree to iterate and a symbol representing place of substitution
+	 *
+	 * \param element the tree to iterate
+	 * \param substitutionSymbol the symbol representing the substitution place
+	 */
+	explicit FormalRTEIteration ( const FormalRTEElement < SymbolType, RankType > & element, FormalRTESymbolSubst < SymbolType, RankType > substitutionSymbol );
 
 	/**
 	 * @copydoc FormalRTEElement::clone() const
@@ -61,40 +101,85 @@ public:
 	virtual bool checkAlphabet ( const ext::set < common::ranked_symbol < SymbolType, RankType > > & alphabetF, const ext::set < common::ranked_symbol < SymbolType, RankType > > & alphabetK ) const override;
 
 	/**
-	 * @return element
+	 * Getter of the iterated tree
+	 *
+	 * \return the iterated tree
 	 */
 	const FormalRTEElement < SymbolType, RankType > & getElement ( ) const;
+
+	/**
+	 * Getter of the substitution symbol
+	 *
+	 * \return the substitution symbol
+	 */
 	const FormalRTESymbolSubst < SymbolType, RankType > & getSubstitutionSymbol ( ) const;
 
 	/**
-	 * @return element
+	 * Getter of the iterated tree
+	 *
+	 * \return the iterated tree
 	 */
 	FormalRTEElement < SymbolType, RankType > & getElement ( );
+
+	/**
+	 * Getter of the substitution symbol
+	 *
+	 * \return the substitution symbol
+	 */
 	FormalRTESymbolSubst < SymbolType, RankType > & getSubstitutionSymbol ( );
 
 	/**
-	 * @param element to iterate
+	 * Setter of the iterated tree
+	 *
+	 * \param element the iterated tree
 	 */
 	void setElement ( const FormalRTEElement < SymbolType, RankType > & element );
+
+	/**
+	 * Setter of the iterated tree
+	 *
+	 * \param element the iterated tree
+	 */
 	void setElement ( FormalRTEElement < SymbolType, RankType > && element );
 
+	/**
+	 * Setter of the substitution symbol
+	 *
+	 * \param element the substitution symbol
+	 */
 	void setSubstitutionSymbol ( FormalRTESymbolSubst < SymbolType, RankType > element );
 
+	/**
+	 * @copydoc alib::CommonBase < FormalRTEElement < SymbolType, RankType > >::compare ( const FormalRTEElement < SymbolType, RankType > & )
+	 */
 	virtual int compare ( const FormalRTEElement < SymbolType, RankType > & other ) const override {
 		if ( ext::type_index ( typeid ( * this ) ) == ext::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other );
 
 		return ext::type_index ( typeid ( * this ) ) - ext::type_index ( typeid ( other ) );
 	}
 
+	/**
+	 * The actual compare method
+	 *
+	 * \param other the other instance
+	 *
+	 * \returns the actual relation between two by type same node instances
+	 */
 	int compare ( const FormalRTEIteration & ) const;
 
 	/**
-	 * @copydoc FormalRTEElement::operator>>() const
+	 * @copydoc alib::CommonBase < FormalRTEElement < SymbolType, RankType > >::operator >> ( std::ostream & )
 	 */
 	virtual void operator >>( std::ostream & out ) const override;
 
+	/**
+	 * @copydoc alib::CommonBase < FormalRTEElement < SymbolType, RankType > >::operator std::string ( )
+	 */
 	virtual explicit operator std::string ( ) const override;
 
+	/**
+	 * @copydoc regexp::FormalRTEElement < SymbolType, RankType >::normalize ( ) &&
+	 */
 	virtual ext::smart_ptr < FormalRTEElement < DefaultSymbolType, DefaultRankType > > normalize ( ) && override {
 		return ext::smart_ptr < FormalRTEElement < DefaultSymbolType, DefaultRankType > > ( new FormalRTEIteration < DefaultSymbolType, DefaultRankType > ( std::move ( * std::move ( getElement ( ) ).normalize ( ) ), std::move ( * m_substitutionSymbol ).normalizeRaw ( ) ) );
 	}
diff --git a/alib2data/src/rte/formal/FormalRTESubstitution.h b/alib2data/src/rte/formal/FormalRTESubstitution.h
index 41de0f90f7..bf58641abe 100644
--- a/alib2data/src/rte/formal/FormalRTESubstitution.h
+++ b/alib2data/src/rte/formal/FormalRTESubstitution.h
@@ -1,6 +1,22 @@
 /*
  * FormalRTESubstitution.h
  *
+ * This file is part of Algorithms library toolkit.
+ * Copyright (C) 2017 Jan Travnicek (jan.travnicek@fit.cvut.cz)
+
+ * Algorithms library toolkit is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+
+ * Algorithms library toolkit is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with Algorithms library toolkit.  If not, see <http://www.gnu.org/licenses/>.
+ *
  *  Created on: Feb 20, 2016
  *      Author: Tomas Pecka
  */
@@ -18,20 +34,46 @@
 namespace rte {
 
 /**
- * Represents concatenation operator in the regular expression. Contains list of FormalRTEElement
- * as operands of the operator.
+ * \brief Represents the concatenation operator in the regular tree expression. The node must have exactly two children.
+ *
+ * The structure is derived from BinaryNode that provides the children accessors.
+ *
+ * The node can be visited by the FormalRTEElement < SymbolType, RankType >::Visitor
+ *
+ * \tparam SymbolType used for the symbol part of the ranked symbol
+ * \tparam RankType used for the rank part of the ranked symbol
  */
 template < class SymbolType, class RankType >
 class FormalRTESubstitution : public FormalRTEElement < SymbolType, RankType >, public ext::BinaryNode < ext::smart_ptr < FormalRTEElement < SymbolType, RankType > >, ext::smart_ptr < FormalRTEElement < SymbolType, RankType > >, FormalRTESubstitution < SymbolType, RankType > > {
-protected:
-	ext::smart_ptr < FormalRTESymbolSubst < SymbolType, RankType > > m_substitutionSymbol; // substite this in left by right
+	/**
+	 * The substitution symbol of the node. The symbol will be substitued in left tree by right
+	 */
+	ext::smart_ptr < FormalRTESymbolSubst < SymbolType, RankType > > m_substitutionSymbol;
 
-public:
+	/**
+	 * @copydoc regexp::FormalRTEElement < SymbolType, RankType >::accept ( ) const
+	 */
 	virtual void accept ( typename FormalRTEElement < SymbolType, RankType >::Visitor & visitor ) const override {
 		visitor.visit ( * this );
 	}
 
+public:
+	/**
+	 * \brief Creates a new instance of the substitution node with explicit tree to substitute in, tree to substitue by and a symbol representing place of substitution
+	 *
+	 * \param left the tree to substitute in
+	 * \param right the tree to substitute by
+	 * \param substitutionSymbol the symbol representing the substitution place
+	 */
 	explicit FormalRTESubstitution ( FormalRTEElement < SymbolType, RankType > && left, FormalRTEElement < SymbolType, RankType > && right, FormalRTESymbolSubst < SymbolType, RankType > substitutionSymbol );
+
+	/**
+	 * \brief Creates a new instance of the substitution node with explicit tree to substitute in, tree to substitue by and a symbol representing place of substitution
+	 *
+	 * \param left the tree to substitute in
+	 * \param right the tree to substitute by
+	 * \param substitutionSymbol the symbol representing the substitution place
+	 */
 	explicit FormalRTESubstitution ( const FormalRTEElement < SymbolType, RankType > & left, const FormalRTEElement < SymbolType, RankType > & right, FormalRTESymbolSubst < SymbolType, RankType > substitutionSymbol );
 
 	/**
@@ -60,44 +102,113 @@ public:
 	virtual bool checkAlphabet ( const ext::set < common::ranked_symbol < SymbolType, RankType > > & alphabetF, const ext::set < common::ranked_symbol < SymbolType, RankType > > & alphabetK ) const override;
 
 	/**
-	 * @return elements
+	 * Getter of the tree to substitute in
+	 *
+	 * \return tree to substitute in
 	 */
 	const FormalRTEElement < SymbolType, RankType > & getLeftElement ( ) const;
+
+	/**
+	 * Getter of the tree to substitute by
+	 *
+	 * \return tree to substitute by
+	 */
 	const FormalRTEElement < SymbolType, RankType > & getRightElement ( ) const;
+
+	/**
+	 * Getter of the substitution symbol
+	 *
+	 * \return the substitution symbol
+	 */
 	const FormalRTESymbolSubst < SymbolType, RankType > & getSubstitutionSymbol ( ) const;
 
 	/**
-	 * @return elements
+	 * Getter of the tree to substitute in
+	 *
+	 * \return tree to substitute in
 	 */
 	FormalRTEElement < SymbolType, RankType > & getLeftElement ( );
+
+	/**
+	 * Getter of the tree to substitute by
+	 *
+	 * \return tree to substitute by
+	 */
 	FormalRTEElement < SymbolType, RankType > & getRightElement ( );
+
+	/**
+	 * Getter of the substitution symbol
+	 *
+	 * \return the substitution symbol
+	 */
 	FormalRTESymbolSubst < SymbolType, RankType > & getSubstitutionSymbol ( );
 
 	/**
-	 * @param element to append
+	 * Setter of the tree to substitute in
+	 *
+	 * \param element the tree to substitute in
 	 */
 	void setLeftElement ( const FormalRTEElement < SymbolType, RankType > & element );
+
+	/**
+	 * Setter of the tree to substitute by
+	 *
+	 * \param element the tree to substitute by
+	 */
 	void setLeftElement ( FormalRTEElement < SymbolType, RankType > && element );
 
+	/**
+	 * Setter of the tree to substitute in
+	 *
+	 * \param element the tree to substitute in
+	 */
 	void setRightElement ( const FormalRTEElement < SymbolType, RankType > & element );
+
+	/**
+	 * Setter of the tree to substitute by
+	 *
+	 * \param element the tree to substitute by
+	 */
 	void setRightElement ( FormalRTEElement < SymbolType, RankType > && element );
 
+	/**
+	 * Setter of the substitution symbol
+	 *
+	 * \param element the substitution symbol
+	 */
 	void setSubstitutionSymbol ( FormalRTESymbolSubst < SymbolType, RankType > element );
 
+	/**
+	 * @copydoc alib::CommonBase < FormalRTEElement < SymbolType, RankType > >::compare ( const FormalRTEElement < SymbolType, RankType > & )
+	 */
 	virtual int compare ( const FormalRTEElement < SymbolType, RankType > & other ) const override {
 		if ( ext::type_index ( typeid ( * this ) ) == ext::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other );
 
 		return ext::type_index ( typeid ( * this ) ) - ext::type_index ( typeid ( other ) );
 	}
 
+	/**
+	 * The actual compare method
+	 *
+	 * \param other the other instance
+	 *
+	 * \returns the actual relation between two by type same node instances
+	 */
 	int compare ( const FormalRTESubstitution & ) const;
 
 	/**
-	 * @copydoc FormalRTEElement::operator>>() const
+	 * @copydoc alib::CommonBase < FormalRTEElement < SymbolType, RankType > >::operator >> ( std::ostream & )
 	 */
 	virtual void operator >>( std::ostream & out ) const override;
+
+	/**
+	 * @copydoc alib::CommonBase < FormalRTEElement < SymbolType, RankType > >::operator std::string ( )
+	 */
 	virtual explicit operator std::string ( ) const override;
 
+	/**
+	 * @copydoc regexp::FormalRTEElement < SymbolType, RankType >::normalize ( ) &&
+	 */
 	virtual ext::smart_ptr < FormalRTEElement < DefaultSymbolType, DefaultRankType > > normalize ( ) && override {
 		return ext::smart_ptr < FormalRTEElement < DefaultSymbolType, DefaultRankType > > ( new FormalRTESubstitution < DefaultSymbolType, DefaultRankType > ( std::move ( * std::move ( getLeftElement ( ) ).normalize ( ) ), std::move ( * std::move ( getRightElement ( ) ).normalize ( ) ), std::move ( * m_substitutionSymbol ).normalizeRaw ( ) ) );
 	}
diff --git a/alib2data/src/rte/formal/FormalRTESymbol.h b/alib2data/src/rte/formal/FormalRTESymbol.h
index 241b83e890..ccb0030748 100644
--- a/alib2data/src/rte/formal/FormalRTESymbol.h
+++ b/alib2data/src/rte/formal/FormalRTESymbol.h
@@ -1,6 +1,22 @@
 /*
  * FormalRTESymbol.h
  *
+ * This file is part of Algorithms library toolkit.
+ * Copyright (C) 2017 Jan Travnicek (jan.travnicek@fit.cvut.cz)
+
+ * Algorithms library toolkit is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+
+ * Algorithms library toolkit is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with Algorithms library toolkit.  If not, see <http://www.gnu.org/licenses/>.
+ *
  *  Created on: Feb 20, 2016
  *      Author: Tomas Pecka
  */
@@ -14,14 +30,25 @@
 namespace rte {
 
 /**
- * Represents symbol, abstract class
+ * \brief Represents the common part of SubstitutionSymbol and TerminalSymbol.
+ *
+ * \tparam SymbolType used for the symbol part of the ranked symbol
+ * \tparam RankType used for the rank part of the ranked symbol
  */
 template < class SymbolType, class RankType >
 class FormalRTESymbol : public FormalRTEElement < SymbolType, RankType > {
 protected:
+	/**
+	 * The symbol of the node.
+	 */
 	common::ranked_symbol < SymbolType, RankType > m_symbol;
 
 public:
+	/**
+	 * \brief Creates a new instance of the symbol node using the actual symbol to represent.
+	 *
+	 * \param symbol the value of the represented symbol
+	 */
 	FormalRTESymbol ( common::ranked_symbol < SymbolType, RankType > symbol );
 
 	/**
@@ -34,8 +61,23 @@ public:
 	 */
 	virtual FormalRTESymbol < SymbolType, RankType > * plunder ( ) && override = 0;
 
-	const common::ranked_symbol < SymbolType, RankType > & getSymbol ( ) const;
+	/**
+	 * Getter of the symbol.
+	 *
+	 * \return the symbol
+	 */
+	const common::ranked_symbol < SymbolType, RankType > & getSymbol ( ) const &;
+
+	/**
+	 * Getter of the symbol.
+	 *
+	 * \return the symbol
+	 */
+	common::ranked_symbol < SymbolType, RankType > && getSymbol ( ) &&;
 
+	/**
+	 * FIXME changing the children of FormalRTESymbolAlphabet from FormalRTESymbol to FormalRTEElement like already used in the relevant RTE -> PDA paper there should not be any need for this
+	 */
 	virtual ext::smart_ptr < FormalRTESymbol < DefaultSymbolType, DefaultRankType > > normalizeSymbol ( ) && = 0;
 };
 
@@ -44,7 +86,12 @@ FormalRTESymbol < SymbolType, RankType >::FormalRTESymbol ( common::ranked_symbo
 }
 
 template < class SymbolType, class RankType >
-const common::ranked_symbol < SymbolType, RankType > & FormalRTESymbol < SymbolType, RankType >::getSymbol ( ) const {
+const common::ranked_symbol < SymbolType, RankType > & FormalRTESymbol < SymbolType, RankType >::getSymbol ( ) const & {
+	return m_symbol;
+}
+
+template < class SymbolType, class RankType >
+common::ranked_symbol < SymbolType, RankType > && FormalRTESymbol < SymbolType, RankType >::getSymbol ( ) && {
 	return m_symbol;
 }
 
diff --git a/alib2data/src/rte/formal/FormalRTESymbolAlphabet.h b/alib2data/src/rte/formal/FormalRTESymbolAlphabet.h
index 3e572c0a2c..90a7d6bdc7 100644
--- a/alib2data/src/rte/formal/FormalRTESymbolAlphabet.h
+++ b/alib2data/src/rte/formal/FormalRTESymbolAlphabet.h
@@ -1,6 +1,22 @@
 /*
  * FormalRTESymbolAlphabet.h
  *
+ * This file is part of Algorithms library toolkit.
+ * Copyright (C) 2017 Jan Travnicek (jan.travnicek@fit.cvut.cz)
+
+ * Algorithms library toolkit is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+
+ * Algorithms library toolkit is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with Algorithms library toolkit.  If not, see <http://www.gnu.org/licenses/>.
+ *
  *  Created on: Feb 20, 2016
  *      Author: Tomas Pecka
  */
@@ -18,15 +34,30 @@
 namespace rte {
 
 /**
- * Represents symbol in the regular expression. Contains name of the symbol.
+ * \brief Represents the terminal symbol in the regular tree expression. The number of children must be the same as the arity of the symbol of the node.
+ *
+ * The structure is derived from VararyNode, which however does not check the number of children of the node.
+ *
+ * The node can be visited by the FormalRTEElement < SymbolType, RankType >::Visitor
+ *
+ * \tparam SymbolType used for the symbol part of the ranked symbol
+ * \tparam RankType used for the rank part of the ranked symbol
  */
 template < class SymbolType, class RankType >
 class FormalRTESymbolAlphabet : public FormalRTESymbol < SymbolType, RankType >, public ext::VararyNode < ext::smart_ptr < FormalRTESymbol < SymbolType, RankType > >, ext::smart_ptr < const FormalRTESymbol < SymbolType, RankType > >, FormalRTESymbolAlphabet < SymbolType, RankType > > {
-public:
+	/**
+	 * @copydoc regexp::FormalRTEElement < SymbolType, RankType >::accept ( ) const
+	 */
 	virtual void accept ( typename FormalRTEElement < SymbolType, RankType >::Visitor & visitor ) const override {
 		visitor.visit ( * this );
 	}
 
+public:
+	/**
+	 * \brief Creates a new instance of the symbol node using the actual symbol to represent.
+	 *
+	 * \param symbol the value of the represented symbol
+	 */
 	explicit FormalRTESymbolAlphabet ( common::ranked_symbol < SymbolType, RankType > symbol );
 
 	/**
@@ -54,14 +85,33 @@ public:
 	 */
 	virtual bool checkAlphabet ( const ext::set < common::ranked_symbol < SymbolType, RankType > > & alphabetF, const ext::set < common::ranked_symbol < SymbolType, RankType > > & alphabetK ) const override;
 
+	/**
+	 * Getter of child nodes of the rte node
+	 *
+	 * \return child nodes
+	 */
 	const ext::vector < ext::smart_ptr < const FormalRTESymbol < SymbolType, RankType > > > & getElements ( ) const;
+
+	/**
+	 * Getter of child nodes of the rte node
+	 *
+	 * \return child nodes
+	 */
 	const ext::vector < ext::smart_ptr < FormalRTESymbol < SymbolType, RankType > > > & getElements ( );
 
+	/**
+	 * FIXME remove
+	 */
 	void appendElement ( const FormalRTESymbol < SymbolType, RankType > & element );
-	void appendElement ( FormalRTESymbol < SymbolType, RankType > && element );
 
-	int compare ( const FormalRTESymbolAlphabet & ) const;
+	/**
+	 * FIXME remove
+	 */
+	void appendElement ( FormalRTESymbol < SymbolType, RankType > && element );
 
+	/**
+	 * @copydoc alib::CommonBase < FormalRTEElement < SymbolType, RankType > >::compare ( const FormalRTEElement < SymbolType, RankType > & )
+	 */
 	virtual int compare ( const FormalRTEElement < SymbolType, RankType > & other ) const override {
 		if ( ext::type_index ( typeid ( * this ) ) == ext::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other );
 
@@ -69,15 +119,27 @@ public:
 	}
 
 	/**
-	 * @copydoc FormalRTEElement::operator>>() const
+	 * The actual compare method
+	 *
+	 * \param other the other instance
+	 *
+	 * \returns the actual relation between two by type same node instances
+	 */
+	int compare ( const FormalRTESymbolAlphabet & ) const;
+
+	/**
+	 * @copydoc alib::CommonBase < FormalRTEElement < SymbolType, RankType > >::operator >> ( std::ostream & )
 	 */
 	virtual void operator >>( std::ostream & out ) const override;
 
 	/**
-	 * Returns the string representation of RTE Symbol.
+	 * @copydoc alib::CommonBase < FormalRTEElement < SymbolType, RankType > >::operator std::string ( )
 	 */
 	virtual explicit operator std::string ( ) const override;
 
+	/**
+	 * FIXME remove
+	 */
 	virtual ext::smart_ptr < FormalRTESymbol < DefaultSymbolType, DefaultRankType > > normalizeSymbol ( ) && override {
 		FormalRTESymbolAlphabet < DefaultSymbolType, DefaultRankType > res ( alphabet::SymbolNormalize::normalizeRankedSymbol ( std::move ( this->m_symbol ) ) );
 
@@ -87,6 +149,9 @@ public:
 		return ext::smart_ptr < FormalRTESymbol < DefaultSymbolType, DefaultRankType > > ( std::move ( res ).plunder ( ) );
 	}
 
+	/**
+	 * @copydoc regexp::FormalRTEElement < SymbolType, RankType >::normalize ( ) &&
+	 */
 	virtual ext::smart_ptr < FormalRTEElement < DefaultSymbolType, DefaultRankType > > normalize ( ) && override {
 		return ext::smart_ptr < FormalRTEElement < DefaultSymbolType, DefaultRankType > > ( std::move ( * this ).normalizeSymbol ( ) );
 	}
@@ -123,7 +188,7 @@ void FormalRTESymbolAlphabet < SymbolType, RankType >::appendElement ( const For
 
 template < class SymbolType, class RankType >
 void FormalRTESymbolAlphabet < SymbolType, RankType >::appendElement ( FormalRTESymbol < SymbolType, RankType > && element ) {
-	// TODO: Remove this.  Pass vector in constructor. Now an Element can have LESS children that is MUST have.
+	// FIXME: Remove this.  Pass vector in constructor. Now an Element can have LESS children that is MUST have.
 
 	if ( this->getChildren ( ).size ( ) >= ( size_t ) this->getSymbol ( ).getRank ( ) )
 		throw exception::CommonException ( "Ranked node cannot have more children then its rank" );
diff --git a/alib2data/src/rte/formal/FormalRTESymbolSubst.h b/alib2data/src/rte/formal/FormalRTESymbolSubst.h
index dffba15bc0..326fd75580 100644
--- a/alib2data/src/rte/formal/FormalRTESymbolSubst.h
+++ b/alib2data/src/rte/formal/FormalRTESymbolSubst.h
@@ -1,6 +1,22 @@
 /*
  * FormalRTESymbolSubst.h
  *
+ * This file is part of Algorithms library toolkit.
+ * Copyright (C) 2017 Jan Travnicek (jan.travnicek@fit.cvut.cz)
+
+ * Algorithms library toolkit is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+
+ * Algorithms library toolkit is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with Algorithms library toolkit.  If not, see <http://www.gnu.org/licenses/>.
+ *
  *  Created on: Feb 20, 2016
  *      Author: Tomas Pecka
  */
@@ -17,15 +33,30 @@
 namespace rte {
 
 /**
- * Represents constant symbol (element of alphabet K) in the regular expression. Contains name of the symbol.
+ * \brief Represents the substitution symbol in the regular tree expression. The node can't have any children.
+ *
+ * The structure is derived from NullaryNode.
+ *
+ * The node can be visited by the FormalRTEElement < SymbolType, RankType >::Visitor
+ *
+ * \tparam SymbolType used for the symbol part of the ranked symbol
+ * \tparam RankType used for the rank part of the ranked symbol
  */
 template < class SymbolType, class RankType >
 class FormalRTESymbolSubst : public FormalRTESymbol < SymbolType, RankType >, public ext::NullaryNode < FormalRTESymbolSubst < SymbolType, RankType > > {
-public:
+	/**
+	 * @copydoc regexp::FormalRTEElement < SymbolType, RankType >::accept ( ) const
+	 */
 	virtual void accept ( typename FormalRTEElement < SymbolType, RankType >::Visitor & visitor ) const override {
 		visitor.visit ( * this );
 	}
 
+public:
+	/**
+	 * \brief Creates a new instance of the symbol node using the actual symbol to represent.
+	 *
+	 * \param symbol the value of the represented symbol
+	 */
 	explicit FormalRTESymbolSubst ( common::ranked_symbol < SymbolType, RankType > symbol );
 
 	/**
@@ -53,8 +84,9 @@ public:
 	 */
 	virtual bool checkAlphabet ( const ext::set < common::ranked_symbol < SymbolType, RankType > > & alphabetF, const ext::set < common::ranked_symbol < SymbolType, RankType > > & alphabetK ) const override;
 
-	int compare ( const FormalRTESymbolSubst & ) const;
-
+	/**
+	 * @copydoc alib::CommonBase < FormalRTEElement < SymbolType, RankType > >::compare ( const FormalRTEElement < SymbolType, RankType > & )
+	 */
 	virtual int compare ( const FormalRTEElement < SymbolType, RankType > & other ) const override {
 		if ( ext::type_index ( typeid ( * this ) ) == ext::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other );
 
@@ -62,23 +94,41 @@ public:
 	}
 
 	/**
-	 * @copydoc FormalRTEElement::operator>>() const
+	 * The actual compare method
+	 *
+	 * \param other the other instance
+	 *
+	 * \returns the actual relation between two by type same node instances
+	 */
+	int compare ( const FormalRTESymbolSubst & ) const;
+
+	/**
+	 * @copydoc alib::CommonBase < FormalRTEElement < SymbolType, RankType > >::operator >> ( std::ostream & )
 	 */
 	virtual void operator >>( std::ostream & out ) const override;
 
 	/**
-	 * Returns the string representation of RTE Substitution Symbol.
+	 * @copydoc alib::CommonBase < FormalRTEElement < SymbolType, RankType > >::operator std::string ( )
 	 */
 	virtual explicit operator std::string ( ) const override;
 
+	/**
+	 * FIXME remove
+	 */
 	FormalRTESymbolSubst < DefaultSymbolType, DefaultRankType > normalizeRaw ( ) && {
 		return FormalRTESymbolSubst < DefaultSymbolType, DefaultRankType > ( alphabet::SymbolNormalize::normalizeRankedSymbol ( std::move ( this->m_symbol ) ) );
 	}
 
+	/**
+	 * FIXME remove
+	 */
 	virtual ext::smart_ptr < FormalRTESymbol < DefaultSymbolType, DefaultRankType > > normalizeSymbol ( ) && override {
 		return ext::smart_ptr < FormalRTESymbol < DefaultSymbolType, DefaultRankType > > ( std::move ( * this ).normalizeRaw ( ).plunder ( ) );
 	}
 
+	/**
+	 * @copydoc regexp::FormalRTEElement < SymbolType, RankType >::normalize ( ) &&
+	 */
 	virtual ext::smart_ptr < FormalRTEElement < DefaultSymbolType, DefaultRankType > > normalize ( ) && override {
 		return ext::smart_ptr < FormalRTEElement < DefaultSymbolType, DefaultRankType > > ( std::move ( * this ).normalizeSymbol ( ) );
 	}
-- 
GitLab