diff --git a/src/calculator.cpp b/src/calculator.cpp index cc435d8..6bf781b 100644 --- a/src/calculator.cpp +++ b/src/calculator.cpp @@ -1,5 +1,9 @@ -#include +#ifndef __CALCULATOR_CPP +#define __CALCULATOR_CPP + #include +#include +#include "debug.cpp" #include "stack.cpp" namespace Calculator @@ -22,34 +26,6 @@ struct Symbol { double value = 0; }; -void dbgPrint(const std::vector* _input) { - std::cout << "\033[31m"; - - for (auto it = _input->begin(); it != _input->end(); it++) { - auto type = it->type; - - std::cout << "["; - if (type == SymbolType::add) std::cout << "+"; - else if (type == SymbolType::subract) std::cout << "-"; - else if (type == SymbolType::divide) std::cout << "/"; - else if (type == SymbolType::multiply) std::cout << "*"; - else if (type == SymbolType::number) std::cout << it->value; - else if (type == SymbolType::left_bracket) std::cout << "("; - else if (type == SymbolType::right_bracket) std::cout << ")"; - - std::cout << "]"; - }; - std::cout << "\033[0m"; -} - -void dbgPrint(const std::vector* _input) { - std::cout << "\033[31m"; - for (auto it = _input->begin(); it != _input->end(); it++) { - std::cout << "[" << *it << "]"; - } - std::cout << "\033[31m"; -} - /** * @brief the result of parse function. */ @@ -412,4 +388,6 @@ parseAndCalculateResult parseAndCaluclate(const std::string& _input, bool debug return returnVal; } -}; // namespace Calculator \ No newline at end of file +}; // namespace Calculator + +#endif \ No newline at end of file diff --git a/src/debug.cpp b/src/debug.cpp index c0a2b9e..b141c40 100644 --- a/src/debug.cpp +++ b/src/debug.cpp @@ -2,6 +2,7 @@ #ifndef __DEBUG_CPP #define __DEBUG_CPP +#include "calculator.cpp" #include "cursor.cpp" /** @@ -25,5 +26,38 @@ void debugKey(cursor::key _key) { cursor::restorePosition(); } +/** + * @brief Prints the content of _input. + * + * @param _input vector of symbols + */ +void dbgPrint(const std::vector* _input) { + for (auto it = _input->begin(); it != _input->end(); it++) { + auto type = it->type; + + std::cout << "["; + if (type == Calculator::SymbolType::add) std::cout << "+"; + else if (type == Calculator::SymbolType::subract) std::cout << "-"; + else if (type == Calculator::SymbolType::divide) std::cout << "/"; + else if (type == Calculator::SymbolType::multiply) std::cout << "*"; + else if (type == Calculator::SymbolType::number) std::cout << it->value; + else if (type == Calculator::SymbolType::left_bracket) std::cout << "("; + else if (type == Calculator::SymbolType::right_bracket) std::cout << ")"; + + std::cout << "]"; + }; +} + +/** + * @brief Prints the content of _input. + * + * @param _input vetcor of unsigned int + */ +void dbgPrint(const std::vector* _input) { + for (auto it = _input->begin(); it != _input->end(); it++) { + std::cout << "[" << *it << "]"; + } +} + #endif #endif \ No newline at end of file