diff --git a/flamingo/grammar/expr.h b/flamingo/grammar/expr.h index d5df411..94aae6d 100644 --- a/flamingo/grammar/expr.h +++ b/flamingo/grammar/expr.h @@ -164,6 +164,26 @@ static int parse_binary_expr(flamingo_t* flamingo, TSNode node, flamingo_val_t** } if (kind == FLAMINGO_VAL_KIND_BOOL) { + // Logical operators. + + 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; + } + + 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; + } + // Comparisons. if (strncmp(operator, "==", operator_size) == 0) {