From a7b2cec4719ed5b42889aafac20a25f1820ab78b Mon Sep 17 00:00:00 2001 From: Johnny Richard Date: Sun, 30 Apr 2023 02:00:39 +0200 Subject: ast: Rename variable and variable_declaration correctly Signed-off-by: Johnny Richard --- src/ast.c | 8 ++++---- src/ast.h | 4 ++-- src/parser.c | 2 +- test/parser_test.c | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/ast.c b/src/ast.c index 49d772a..1131bbf 100644 --- a/src/ast.c +++ b/src/ast.c @@ -52,7 +52,7 @@ ast_node_destroy(ast_node_t *node) ast_node_destroy(node->data.binary_operation.right); break; case AST_VARIABLE_DECLARATION: - ast_node_destroy(node->data.variable.value); + ast_node_destroy(node->data.variable_declaration.value); break; case AST_LITERAL: break; @@ -103,15 +103,15 @@ void ast_node_init_variable_declaration(ast_node_t *node, string_view_t variable_name, type_t type, ast_node_t *value) { node->kind = AST_VARIABLE_DECLARATION; - node->data = - (ast_node_data_t){ .variable = { .identifier = { .name = variable_name }, .type = type, .value = value } }; + node->data = (ast_node_data_t){ .variable_declaration = { + .identifier = { .name = variable_name }, .type = type, .value = value } }; } void ast_node_init_variable(ast_node_t *node, ast_identifier_t *identifier) { node->kind = AST_VARIABLE; - node->data = (ast_node_data_t){ .variable_ex = { .identifier = identifier } }; + node->data = (ast_node_data_t){ .variable = { .identifier = identifier } }; } void diff --git a/src/ast.h b/src/ast.h index 4fd1d1d..2bd700e 100644 --- a/src/ast.h +++ b/src/ast.h @@ -105,9 +105,9 @@ typedef union ast_function_declaration_t function; ast_literal_t literal; ast_return_stmt_t return_stmt; - ast_variable_declaration_t variable; // FIXME: Rename to variable_declaration + ast_variable_declaration_t variable_declaration; ast_identifier_t identifier; - ast_variable_t variable_ex; // FIXME: Rename to variable + ast_variable_t variable; } ast_node_data_t; typedef struct ast_node_t diff --git a/src/parser.c b/src/parser.c index 469fa99..87676d3 100644 --- a/src/parser.c +++ b/src/parser.c @@ -257,7 +257,7 @@ parser_parse_variable_definition(parser_t *parser, string_view_t variable_name, } ast_node_init_variable_declaration(node, variable_name, type, expression); - scope_push(parser->scope, &node->data.variable.identifier, node); + scope_push(parser->scope, &node->data.variable_declaration.identifier, node); return true; } diff --git a/test/parser_test.c b/test/parser_test.c index 0c54e50..d534509 100644 --- a/test/parser_test.c +++ b/test/parser_test.c @@ -118,7 +118,7 @@ test_parse_variable_definition(const MunitParameter params[], void *user_data_or ast_node_t *ast_variable = vector_at(ast_function->data.function.body, 0); assert_int(AST_VARIABLE_DECLARATION, ==, ast_variable->kind); - assert_string_view_equal("variable", ast_variable->data.variable.identifier.name); + assert_string_view_equal("variable", ast_variable->data.variable_declaration.identifier.name); ast_node_t *ast_return = vector_at(ast_function->data.function.body, 1); -- cgit v1.2.3