Skip to content

Commit 186f8c4

Browse files
feat(double eq): add func to identify double equals
1 parent 4c57409 commit 186f8c4

1 file changed

Lines changed: 20 additions & 4 deletions

File tree

src/core/Core/funcs.hpp

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,25 @@ static size_t findTopLevelEquals(const std::string& str) {
5656
return std::string::npos;
5757
}
5858

59+
//function to check for == operator specifically
60+
static bool hasEqualsEqualsOperator(const std::string& str) {
61+
int depth = 0;
62+
for (size_t i = 0; i < str.size(); ++i) {
63+
char c = str[i];
64+
65+
if (c == '(') {
66+
++depth;
67+
} else if (c == ')') {
68+
--depth;
69+
} else if (depth == 0) {
70+
if (c == '=' && i + 1 < str.size() && str[i+1] == '=') {
71+
return true;
72+
}
73+
}
74+
}
75+
return false;
76+
}
77+
5978
// function to check if expression contains inequality operators
6079
static bool hasInequalityOperator(const std::string& str) {
6180
int depth = 0;
@@ -67,16 +86,13 @@ static bool hasInequalityOperator(const std::string& str) {
6786
} else if (c == ')') {
6887
--depth;
6988
} else if (depth == 0) {
70-
// Check for <, >, <=, >=, !=, ==
89+
// check for <, >, <=, >=, !=
7190
if (c == '<' || c == '>') {
7291
return true;
7392
}
7493
if (c == '!' && i + 1 < str.size() && str[i+1] == '=') {
7594
return true;
7695
}
77-
if (c == '=' && i + 1 < str.size() && str[i+1] == '=') {
78-
return true;
79-
}
8096
}
8197
}
8298
return false;

0 commit comments

Comments
 (0)