Implement === and !== string comparison operators (#1832)

This commit is contained in:
Rangi
2025-09-19 14:06:36 -04:00
committed by GitHub
parent 67741ab428
commit e31bcabbaa
4 changed files with 41 additions and 6 deletions

View File

@@ -107,6 +107,7 @@
// String operators
%token OP_CAT "++"
%token OP_STREQU "===" OP_STRNE "!=="
// Comparison operators
%token OP_LOGICEQU "==" OP_LOGICNE "!="
@@ -1287,6 +1288,12 @@ relocexpr_no_str:
| CHARACTER {
$$.makeNumber(act_CharToNum($1));
}
| string OP_STREQU string {
$$.makeNumber($1.compare($3) == 0);
}
| string OP_STRNE string {
$$.makeNumber($1.compare($3) != 0);
}
| OP_LOGICNOT relocexpr %prec NEG {
$$.makeUnaryOp(RPN_LOGNOT, std::move($2));
}