diff --git a/flamingo/flamingo.h b/flamingo/flamingo.h index 4568d7c..c444e9c 100644 --- a/flamingo/flamingo.h +++ b/flamingo/flamingo.h @@ -40,7 +40,7 @@ struct flamingo_val_t { union { struct { - bool val; + bool boolean; } boolean; struct { diff --git a/flamingo/grammar/assert.h b/flamingo/grammar/assert.h index 211d9cf..cfc52f2 100644 --- a/flamingo/grammar/assert.h +++ b/flamingo/grammar/assert.h @@ -34,7 +34,7 @@ static int parse_assert(flamingo_t* flamingo, TSNode node) { char const* const test_str = flamingo->src + start; size_t const test_size = end - start; - if (!val->boolean.val) { + if (!val->boolean.boolean) { return error(flamingo, "assertion test '%.*s' failed", (int) test_size, test_str); } diff --git a/flamingo/grammar/binary_expr.h b/flamingo/grammar/binary_expr.h index bac6d27..666a411 100644 --- a/flamingo/grammar/binary_expr.h +++ b/flamingo/grammar/binary_expr.h @@ -90,12 +90,12 @@ static int parse_binary_expr(flamingo_t* flamingo, TSNode node, flamingo_val_t** (*val)->kind = FLAMINGO_VAL_KIND_BOOL; if (strncmp(op, "==", op_size) == 0) { - (*val)->boolean.val = same_types; + (*val)->boolean.boolean = same_types; goto done; } if (strncmp(op, "!=", op_size) == 0) { - (*val)->boolean.val = !same_types; + (*val)->boolean.boolean = !same_types; goto done; } @@ -153,37 +153,37 @@ static int parse_binary_expr(flamingo_t* flamingo, TSNode node, flamingo_val_t** if (strncmp(op, "==", op_size) == 0) { (*val)->kind = FLAMINGO_VAL_KIND_BOOL; - (*val)->boolean.val = left_val->integer.integer == right_val->integer.integer; + (*val)->boolean.boolean = left_val->integer.integer == right_val->integer.integer; goto done; } if (strncmp(op, "!=", op_size) == 0) { (*val)->kind = FLAMINGO_VAL_KIND_BOOL; - (*val)->boolean.val = left_val->integer.integer != right_val->integer.integer; + (*val)->boolean.boolean = left_val->integer.integer != right_val->integer.integer; goto done; } if (strncmp(op, "<", op_size) == 0) { (*val)->kind = FLAMINGO_VAL_KIND_BOOL; - (*val)->boolean.val = left_val->integer.integer < right_val->integer.integer; + (*val)->boolean.boolean = left_val->integer.integer < right_val->integer.integer; goto done; } if (strncmp(op, "<=", op_size) == 0) { (*val)->kind = FLAMINGO_VAL_KIND_BOOL; - (*val)->boolean.val = left_val->integer.integer <= right_val->integer.integer; + (*val)->boolean.boolean = left_val->integer.integer <= right_val->integer.integer; goto done; } if (strncmp(op, ">", op_size) == 0) { (*val)->kind = FLAMINGO_VAL_KIND_BOOL; - (*val)->boolean.val = left_val->integer.integer > right_val->integer.integer; + (*val)->boolean.boolean = left_val->integer.integer > right_val->integer.integer; goto done; } if (strncmp(op, ">=", op_size) == 0) { (*val)->kind = FLAMINGO_VAL_KIND_BOOL; - (*val)->boolean.val = left_val->integer.integer >= right_val->integer.integer; + (*val)->boolean.boolean = left_val->integer.integer >= right_val->integer.integer; goto done; } } @@ -193,19 +193,19 @@ static int parse_binary_expr(flamingo_t* flamingo, TSNode node, flamingo_val_t** if (strncmp(op, "&&", op_size) == 0) { (*val)->kind = FLAMINGO_VAL_KIND_BOOL; - (*val)->boolean.val = left_val->boolean.val && right_val->boolean.val; + (*val)->boolean.boolean = left_val->boolean.boolean && right_val->boolean.boolean; goto done; } if (strncmp(op, "||", op_size) == 0) { (*val)->kind = FLAMINGO_VAL_KIND_BOOL; - (*val)->boolean.val = left_val->boolean.val || right_val->boolean.val; + (*val)->boolean.boolean = left_val->boolean.boolean || right_val->boolean.boolean; goto done; } if (strncmp(op, "^^", op_size) == 0) { (*val)->kind = FLAMINGO_VAL_KIND_BOOL; - (*val)->boolean.val = (!!left_val->boolean.val) ^ (!!right_val->boolean.val); + (*val)->boolean.boolean = (!!left_val->boolean.boolean) ^ (!!right_val->boolean.boolean); goto done; } @@ -213,13 +213,13 @@ static int parse_binary_expr(flamingo_t* flamingo, TSNode node, flamingo_val_t** if (strncmp(op, "==", op_size) == 0) { (*val)->kind = FLAMINGO_VAL_KIND_BOOL; - (*val)->boolean.val = left_val->boolean.val == right_val->boolean.val; + (*val)->boolean.boolean = left_val->boolean.boolean == right_val->boolean.boolean; goto done; } if (strncmp(op, "!=", op_size) == 0) { (*val)->kind = FLAMINGO_VAL_KIND_BOOL; - (*val)->boolean.val = left_val->boolean.val != right_val->boolean.val; + (*val)->boolean.boolean = left_val->boolean.boolean != right_val->boolean.boolean; goto done; } } @@ -245,13 +245,13 @@ static int parse_binary_expr(flamingo_t* flamingo, TSNode node, flamingo_val_t** if (strncmp(op, "==", op_size) == 0) { (*val)->kind = FLAMINGO_VAL_KIND_BOOL; - (*val)->boolean.val = left_val->str.size == right_val->str.size && memcmp(left_val->str.str, right_val->str.str, left_val->str.size) == 0; + (*val)->boolean.boolean = left_val->str.size == right_val->str.size && memcmp(left_val->str.str, right_val->str.str, left_val->str.size) == 0; goto done; } if (strncmp(op, "!=", op_size) == 0) { (*val)->kind = FLAMINGO_VAL_KIND_BOOL; - (*val)->boolean.val = left_val->str.size != right_val->str.size || memcmp(left_val->str.str, right_val->str.str, left_val->str.size) != 0; + (*val)->boolean.boolean = left_val->str.size != right_val->str.size || memcmp(left_val->str.str, right_val->str.str, left_val->str.size) != 0; goto done; } } diff --git a/flamingo/grammar/literal.h b/flamingo/grammar/literal.h index 53a4e44..480c1b7 100644 --- a/flamingo/grammar/literal.h +++ b/flamingo/grammar/literal.h @@ -29,7 +29,7 @@ static int parse_literal(flamingo_t* flamingo, TSNode node, flamingo_val_t** val if (strcmp(type, "bool") == 0) { (*val)->kind = FLAMINGO_VAL_KIND_BOOL; - (*val)->boolean.val = *(flamingo->src + ts_node_start_byte(child)) == 't'; + (*val)->boolean.boolean = *(flamingo->src + ts_node_start_byte(child)) == 't'; return 0; } diff --git a/flamingo/grammar/print.h b/flamingo/grammar/print.h index 895bb18..b7dd0dc 100644 --- a/flamingo/grammar/print.h +++ b/flamingo/grammar/print.h @@ -34,7 +34,7 @@ static int parse_print(flamingo_t* flamingo, TSNode node) { printf("\n"); break; case FLAMINGO_VAL_KIND_BOOL: - printf("%s\n", val->boolean.val ? "true" : "false"); + printf("%s\n", val->boolean.boolean ? "true" : "false"); break; case FLAMINGO_VAL_KIND_INT: printf("%ld\n", val->integer.integer);