Skip to content

Commit e38e97b

Browse files
committed
bug fixing
1 parent af4e797 commit e38e97b

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

tree.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ void Tree::printTree(Token* head, Token* prevToken){
108108
std::cout << "CALL";
109109
while(head->getSibling() != nullptr) {
110110
head = head->getSibling();
111-
if (head->getType() == "IDENTIFIER"){
111+
if (head->getType() == "IDENTIFIER" || head->getType() == "L_PAREN" || head->getType() == "R_PAREN"){
112112
std::cout << " ----> " << head->getValue();
113113
}
114114
}
@@ -284,13 +284,13 @@ Token* Tree::handleAssignment(Token* head) {
284284
// Function to get precedence of operators
285285
int Tree::getPrecedence(std::string op) {
286286
if (op == "+" || op == "-" || op == ">=" || op == "<=" || op == "==" || op == ">" || op == "<" || op == "==" || op == "&&" || op == "!" || op == "||") return 1;
287-
if (op == "*" || op == "/") return 2;
287+
if (op == "*" || op == "/" || op == "%") return 2;
288288
return 0;
289289
}
290290

291291
// Function to check if a character is an operator
292292
bool Tree::isOperator(std::string c) {
293-
return c == "+" || c == "-" || c == "*" || c == "/" || c == "=";
293+
return c == "+" || c == "-" || c == "*" || c == "/" || c == "=" || c == "%";
294294
}
295295

296296
std::vector<Token*> Tree::infixToPostfix(const std::vector<Token*> infix, bool isFunctionCall) {

0 commit comments

Comments
 (0)