From aba7302e7e98fd7bca2056d8ad622d9ca81c495f Mon Sep 17 00:00:00 2001 From: Carlos Maniero Date: Mon, 8 May 2023 23:53:41 -0300 Subject: parser: Add the bool type This commit introduces a new type for booleans. There is no code generation for this type yet. The intention of this commit is to enable flow control in the near future. Signed-off-by: Carlos Maniero Reviewed-by: Johnny Richard --- src/ast.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src/ast.h') diff --git a/src/ast.h b/src/ast.h index 69fc918..80148dc 100644 --- a/src/ast.h +++ b/src/ast.h @@ -22,7 +22,8 @@ typedef enum { - TYPE_I32 + TYPE_I32, + TYPE_BOOL } type_t; typedef struct ast_node_t ast_node_t; @@ -67,12 +68,14 @@ typedef struct ast_binary_operation_t typedef enum { - AST_LITERAL_INTEGER + AST_LITERAL_INTEGER, + AST_LITERAL_BOOL } ast_literal_kind_t; typedef union { uint32_t integer; + bool boolean; } ast_literal_value_t; typedef struct ast_literal_t @@ -147,6 +150,9 @@ ast_node_new_variable_declaration(string_view_t variable_name, type_t type, ast_ ast_node_t * ast_node_new_literal_integer(uint32_t number); +ast_node_t * +ast_node_new_literal_bool(bool boolean); + ast_node_t * ast_node_new_variable(ast_identifier_t *identifier); -- cgit v1.2.3