Skip to content

Commit

Permalink
documenting nso_ba.h
Browse files Browse the repository at this point in the history
  • Loading branch information
castrod committed Jan 9, 2025
1 parent fe202c7 commit 7184ffa
Showing 1 changed file with 104 additions and 32 deletions.
136 changes: 104 additions & 32 deletions src/nso_ba.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <typename... BAs>
tau<BAs...> operator&(const tau<BAs...>& l, const tau<BAs...>& r);

tau<BAs...> operator&(const tau<BAs...>& l, const tau<BAs...>& 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 <typename... BAs>
tau<BAs...> operator|(const tau<BAs...>& l, const tau<BAs...>& r);

/**
* @brief Bitwise NOT operator for tau.
* @param l Operand.
* @return Result of bitwise NOT operation.
*/
template <typename... BAs>
tau<BAs...> operator~(const tau<BAs...>& 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 <typename... BAs>
tau<BAs...> operator^(const tau<BAs...>& l, const tau<BAs...>& r);

/**
* @brief Addition operator for tau.
* @param l Left-hand side operand.
* @param r Right-hand side operand.
* @return Result of addition operation.
*/
template <typename... BAs>
tau<BAs...> operator+(const tau<BAs...>& l, const tau<BAs...>& r);

/**
* @brief Checks if the tau is zero.
* @param l Operand.
* @return True if the tau is zero, false otherwise.
*/
template <typename... BAs>
bool is_zero(const tau<BAs...>& l);

/**
* @brief Checks if the tau is one.
* @param l Operand.
* @return True if the tau is one, false otherwise.
*/
template <typename... BAs>
bool is_one(const tau<BAs...>& 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 <typename... BAs>
bool operator==(const tau<BAs...> &l, const tau<BAs...>& r);

bool operator==(const tau<BAs...>& l, const tau<BAs...>& 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 <typename... BAs>
bool operator!=(const tau<BAs...>& l, const tau<BAs...>& 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 <typename... BAs>
std::weak_ordering operator<=>(const tau<BAs...>& l, const tau<BAs...>& 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<typename... BAs>
bool operator<(const tau<BAs...>& l, const tau<BAs...>& 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<typename... BAs>
bool operator<=(const tau<BAs...>& l, const tau<BAs...>& 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<typename... BAs>
bool operator>(const tau<BAs...>& l, const tau<BAs...>& 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<typename... BAs>
bool operator>=(const tau<BAs...>& l, const tau<BAs...>& 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 <typename... BAs>
bool operator==(const tau<BAs...>& 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 <typename... BAs>
bool operator==(const bool l, const tau<BAs...>& 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 <typename... BAs>
tau<BAs...> splitter(const tau<BAs...>& n, splitter_type st = splitter_type::upper);

} // namespace idni::tau_lang


template <typename... BAs>
std::ostream& operator<<(std::ostream& stream,
const idni::tau_lang::tau<BAs...>& n);

// << for node<tau_sym>
template <typename... BAs>
std::ostream& operator<<(std::ostream& stream,
const idni::rewriter::node<idni::tau_lang::tau_sym<BAs...>>& 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__
} // namespace idni::tau_lang

0 comments on commit 7184ffa

Please sign in to comment.