From 2df874192de61886c288b9d89d6f24cd7586d8c4 Mon Sep 17 00:00:00 2001 From: JacobS999 <129122237+JacobS999@users.noreply.github.com> Date: Wed, 6 Nov 2024 11:49:04 -0800 Subject: [PATCH] removed printing extra transition arrow --- tree.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/tree.cpp b/tree.cpp index 7762170..b6ff975 100644 --- a/tree.cpp +++ b/tree.cpp @@ -85,13 +85,18 @@ Token* Tree::handleAssignment(Token* head) { } // Convert infix to postfix - for (Token* token : infixToPostfix(equationAsVec)) { - std::string tokenValue = token->getValue(); - //std::cout << "tokenVal = " << tokenValue << std::endl; // debug method ***** + std::vector postFix = infixToPostfix(equationAsVec); + //std::cout << "Size<: " << postFix.size() << std::endl; + for (int i = 0; i < postFix.size(); i++) { + std::string tokenValue = postFix.at(i)->getValue(); + // std::cout << "\ncurr token = " << tokenValue << " next token = " << postFix.at(i+1) << std::endl; + // Print token value directly and mark that a space is needed if (!tokenValue.empty()) { std::cout << tokenValue; - std::cout << " ----> "; + if (i != postFix.size() - 1) { + std::cout << " ----> "; + } } }