diff --git a/src/nso_ba.h b/src/nso_ba.h index f8a1a27..e1baba1 100644 --- a/src/nso_ba.h +++ b/src/nso_ba.h @@ -7,82 +7,154 @@ namespace idni::tau_lang { +/** + * @brief Bitwise AND operator for tau. + * @param l Left-hand side operand. + * @param r Right-hand side operand. + * @return Result of bitwise AND operation. + */ template -tau operator&(const tau& l, const tau& r); - +tau operator&(const tau& l, const tau& r); + +/** + * @brief Bitwise OR operator for tau. + * @param l Left-hand side operand. + * @param r Right-hand side operand. + * @return Result of bitwise OR operation. + */ template tau operator|(const tau& l, const tau& r); +/** + * @brief Bitwise NOT operator for tau. + * @param l Operand. + * @return Result of bitwise NOT operation. + */ template tau operator~(const tau& l); +/** + * @brief Bitwise XOR operator for tau. + * @param l Left-hand side operand. + * @param r Right-hand side operand. + * @return Result of bitwise XOR operation. + */ template tau operator^(const tau& l, const tau& r); +/** + * @brief Addition operator for tau. + * @param l Left-hand side operand. + * @param r Right-hand side operand. + * @return Result of addition operation. + */ template tau operator+(const tau& l, const tau& r); +/** + * @brief Checks if the tau is zero. + * @param l Operand. + * @return True if the tau is zero, false otherwise. + */ template bool is_zero(const tau& l); +/** + * @brief Checks if the tau is one. + * @param l Operand. + * @return True if the tau is one, false otherwise. + */ template bool is_one(const tau& l); -// We overload the == operator for tau in order to store additional data -// which is not taken into account for the quality check +/** + * @brief Equality operator for tau. + * @param l Left-hand side operand. + * @param r Right-hand side operand. + * @return True if both tau are equal, false otherwise. + */ template -bool operator==(const tau &l, const tau& r); - +bool operator==(const tau& l, const tau& r); + +/** + * @brief Inequality operator for tau. + * @param l Left-hand side operand. + * @param r Right-hand side operand. + * @return True if both tau are not equal, false otherwise. + */ template bool operator!=(const tau& l, const tau& r); +/** + * @brief Three-way comparison operator for tau. + * @param l Left-hand side operand. + * @param r Right-hand side operand. + * @return Result of the three-way comparison. + */ template std::weak_ordering operator<=>(const tau& l, const tau& r); +/** + * @brief Less-than operator for tau. + * @param l Left-hand side operand. + * @param r Right-hand side operand. + * @return True if l is less than r, false otherwise. + */ template bool operator<(const tau& l, const tau& r); +/** + * @brief Less-than or equal-to operator for tau. + * @param l Left-hand side operand. + * @param r Right-hand side operand. + * @return True if l is less than or equal to r, false otherwise. + */ template bool operator<=(const tau& l, const tau& r); +/** + * @brief Greater-than operator for tau. + * @param l Left-hand side operand. + * @param r Right-hand side operand. + * @return True if l is greater than r, false otherwise. + */ template bool operator>(const tau& l, const tau& r); +/** + * @brief Greater-than or equal-to operator for tau. + * @param l Left-hand side operand. + * @param r Right-hand side operand. + * @return True if l is greater than or equal to r, false otherwise. + */ template bool operator>=(const tau& l, const tau& r); +/** + * @brief Equality operator for tau and bool. + * @param l Left-hand side operand. + * @param r Right-hand side operand. + * @return True if tau is equal to the boolean value, false otherwise. + */ template bool operator==(const tau& l, const bool& r); +/** + * @brief Equality operator for bool and tau. + * @param l Left-hand side operand. + * @param r Right-hand side operand. + * @return True if boolean value is equal to tau, false otherwise. + */ template bool operator==(const bool l, const tau& r); -// Splitter function for a nso tau_parser::bf_constant node holding a BA constant +/** + * @brief Splitter function for a nso tau_parser::bf_constant node holding a BA constant. + * @param n Operand. + * @param st Splitter type (default is splitter_type::upper). + * @return Result of the splitter operation. + */ template tau splitter(const tau& n, splitter_type st = splitter_type::upper); -} // namespace idni::tau_lang - - -template -std::ostream& operator<<(std::ostream& stream, - const idni::tau_lang::tau& n); - -// << for node -template -std::ostream& operator<<(std::ostream& stream, - const idni::rewriter::node>& n); - - -// outputs a sp_tau_source_node to a stream, using the stringify transformer -// and assumes that the constants also override operator<<. -std::ostream& operator<<(std::ostream& stream, - const idni::tau_lang::sp_tau_source_node& n); - -// << tau_source_node (make it shared to make use of the previous operator) -std::ostream& operator<<(std::ostream& stream, - const idni::tau_lang::tau_source_node& n); - -#include "nso_ba.tmpl.h" - -#endif // __NSO_BA_H__ \ No newline at end of file +} // namespace idni::tau_lang \ No newline at end of file