feat(Evaluator): add strict comparaison operators

This commit is contained in:
Matthieu Bessat 2022-05-15 20:49:23 +02:00
parent 35ca9c31ea
commit b72448c62d
4 changed files with 25 additions and 2 deletions

View file

@ -14,7 +14,9 @@ int is_operator(char candidate) {
candidate == '=' ||
candidate == '!' ||
candidate == '&' ||
candidate == '|'
candidate == '|' ||
candidate == '>' ||
candidate == '<'
);
}
@ -83,6 +85,10 @@ int operate(
res = m_float_pow(a, b);
} else if (operator == '=') {
res = (int) (a == b);
} else if (operator == '>') {
res = (int) (a > b);
} else if (operator == '<') {
res = (int) (a < b);
} else {
return 2;
}
@ -105,6 +111,10 @@ int operate(
res = integer_pow(aRepr, bRepr);
} else if (operator == '=') {
res = (int) (aRepr == bRepr);
} else if (operator == '<') {
res = (int) (aRepr < bRepr);
} else if (operator == '>') {
res = (int) (aRepr > bRepr);
} else {
return 2;
}