Combine TK_TRUE and TK_FALSE into TK_BOOL
This commit is contained in:
parent
75b18d96ee
commit
740d9b6566
@ -16,8 +16,7 @@ typedef enum {
|
||||
TK_L_BRACKET,
|
||||
TK_R_BRACKET,
|
||||
TK_NULL,
|
||||
TK_TRUE,
|
||||
TK_FALSE,
|
||||
TK_BOOL,
|
||||
TK_STR_KEY,
|
||||
TK_STR_VAL,
|
||||
TK_INTEGER,
|
||||
@ -29,6 +28,7 @@ typedef union {
|
||||
i64 num_int;
|
||||
f64 num_frac;
|
||||
str_view_t string;
|
||||
bool boolean;
|
||||
} token_value_t;
|
||||
|
||||
typedef struct {
|
||||
|
@ -301,11 +301,9 @@ void print_token(token_t token) {
|
||||
case TK_NULL:
|
||||
printf("%15s, VALUE: N/A", "TK_NULL");
|
||||
break;
|
||||
case TK_TRUE:
|
||||
printf("%15s, VALUE: N/A", "TK_TRUE");
|
||||
break;
|
||||
case TK_FALSE:
|
||||
printf("%15s, VALUE: N/A", "TK_FALSE");
|
||||
case TK_BOOL:
|
||||
printf("%15s, VALUE: %s", "TK_BOOL",
|
||||
token.value.boolean ? "true" : "false");
|
||||
break;
|
||||
case TK_STR_KEY:
|
||||
printf("%15s, VALUE: %s", "TK_STR_KEY", token.value.string);
|
||||
@ -1070,9 +1068,11 @@ lexer_state_t handle_keyword_end(lexer_t *lexer, char input) {
|
||||
if (strequal(keyword, "null")) {
|
||||
set_token(token, lexer->line, column, TK_NULL, (token_value_t){0});
|
||||
} else if (strequal(keyword, "true")) {
|
||||
set_token(token, lexer->line, column, TK_TRUE, (token_value_t){0});
|
||||
set_token(token, lexer->line, column, TK_BOOL,
|
||||
(token_value_t){.boolean = true});
|
||||
} else if (strequal(keyword, "false")) {
|
||||
set_token(token, lexer->line, column, TK_FALSE, (token_value_t){0});
|
||||
set_token(token, lexer->line, column, TK_BOOL,
|
||||
(token_value_t){.boolean = false});
|
||||
}
|
||||
|
||||
clear_lex_str(&(lexer->keyword));
|
||||
|
Loading…
Reference in New Issue
Block a user