Skip to content

Commit

Permalink
expr: Boolean comparisons
Browse files Browse the repository at this point in the history
  • Loading branch information
obiwac committed Sep 3, 2024
1 parent a829c7e commit 48cc473
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion flamingo/grammar/expr.h
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,19 @@ static int parse_binary_expr(flamingo_t* flamingo, TSNode node, flamingo_val_t**
}

if (kind == FLAMINGO_VAL_KIND_BOOL) {
// TODO Logical comparisons.
// Comparisons.

if (strncmp(operator, "==", operator_size) == 0) {
(*val)->kind = FLAMINGO_VAL_KIND_BOOL;
(*val)->boolean.val = left_val->boolean.val == right_val->boolean.val;
goto done;
}

if (strncmp(operator, "!=", operator_size) == 0) {
(*val)->kind = FLAMINGO_VAL_KIND_BOOL;
(*val)->boolean.val = left_val->boolean.val != right_val->boolean.val;
goto done;
}
}

rv = error(flamingo, "unknown operator '%.*s' for type %s", (int) operator_size, operator, val_type_str(left_val));
Expand Down

0 comments on commit 48cc473

Please sign in to comment.