From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2.migadu.com ([2001:41d0:403:4876::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id iIhUDnBU8WbNRwAAe85BDQ:P1 (envelope-from ) for ; Mon, 23 Sep 2024 13:43:44 +0200 Received: from aspmx1.migadu.com ([2001:41d0:403:4876::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2.migadu.com with LMTPS id iIhUDnBU8WbNRwAAe85BDQ (envelope-from ) for ; Mon, 23 Sep 2024 13:43:44 +0200 X-Envelope-To: patches@johnnyrichard.com Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=lists.sr.ht header.s=20240113 header.b=KHoklwWw; dkim=pass header.d=maniero.me header.s=hostingermail1 header.b=Q2bRc2A4; spf=pass (aspmx1.migadu.com: domain of lists@sr.ht designates 46.23.81.152 as permitted sender) smtp.mailfrom=lists@sr.ht; dmarc=pass (policy=none) header.from=maniero.me; arc=pass ("mailchannels.net:s=arc-2022:i=1") ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=johnnyrichard.com; s=key1; t=1727091824; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=WsS2JWQdCrvCMiYkDVMj7og7AfpJBO+ipuOooTrrorM=; b=zbig9Xw3PrlwJfXMnQsQyQPsLX+zjdiCH6W6cgb9RLYeG38DXWugfmoQaps44EA/1yZQQc 8TB3Dg3twnMWE/1BUBNwgeXKowwNIw63Zz65LwO4xQHkxy8gE2h+JakwSP0SqvPY/loqJm k0/2CM3PZDOAqPZT+xP51AmVoqWv6vdguHNDaVE5SLVxdj5lee5LcYHBgEggjtTyeqE/W+ cJBf1b+6M7O7dN+1nrJYYBvchzEj/kmOsX1xOwxdjeU4280fdjceqhpX5wMJIqooJf2+NN iBkhCk/xyc6mElMpLhgHhDieDbRaR+OOYwCMxVIUkVFL4BTh0QFO1OZbgNHQoQ== ARC-Authentication-Results: i=2; aspmx1.migadu.com; dkim=pass header.d=lists.sr.ht header.s=20240113 header.b=KHoklwWw; dkim=pass header.d=maniero.me header.s=hostingermail1 header.b=Q2bRc2A4; spf=pass (aspmx1.migadu.com: domain of lists@sr.ht designates 46.23.81.152 as permitted sender) smtp.mailfrom=lists@sr.ht; dmarc=pass (policy=none) header.from=maniero.me; arc=pass ("mailchannels.net:s=arc-2022:i=1") ARC-Seal: i=2; s=key1; d=johnnyrichard.com; t=1727091824; a=rsa-sha256; cv=pass; b=recoxs0uMzC3KrXZo+L+43PR3xuhtV93wDs3Wf3xTTKToO5hM/TuqKIxHVairvzkGoY6Bf LPQ9+hAnCUAbaHcmPu0ArYwd3iAu2bfS/fKM9zTB5zqPitQh7RTONXU0NHN9tju5ynbZCk 4UTPMQ4H2XnaT++aikdsBkpQzUG5O4K0BODCdU1WyxJKX3OWrJjla8h1FPEraH0XDHt74X zddekXLO3o1YFUgOdb91G47+XdBZ09KJsV6pEQv7p82xVjcBq8kmh6YKc6c83RG5DWdDvq pxe3kJBZVuw6kIhYefGToa3qR0I3VIkoZPUmUuMHjf9GeL/gvrfc5dLlXI8AaQ== Received: from mail-a.sr.ht (mail-a.sr.ht [46.23.81.152]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 2A3A279D5 for ; Mon, 23 Sep 2024 13:43:44 +0200 (CEST) DKIM-Signature: a=rsa-sha256; bh=KeTdYUR1rgLMhFZiXrgMbE0lz41mOzI5pQDgp/2mNO0=; c=simple/simple; d=lists.sr.ht; h=From:To:Cc:Subject:In-Reply-To:References:Date:List-Unsubscribe:List-Subscribe:List-Archive:List-Post:List-ID; q=dns/txt; s=20240113; t=1727091823; v=1; b=KHoklwWwmIqKz8N0ryG9BCPDXWFBynXD2wdp1XXqDw6NEyRUILGX3nCzZVJxfpuxU3AolG5S PopieFadMo1fj4ots7uCGLovruGnqz5KiOIlxK7tXZIkbYYYxE5gegWISEBNtWrmHlExJ+iNg5b MOwtFTpSE1qQcNki1XQmGMQCDO4k62/ugv8f1L3EQLbXIxHvKXYPyjNqNObVFjZbJMmdFlcUl4q W5G9Mz+7EpLn6C/VCa3+m+gqu3KMU8PoTcN2YsvHrbs73PhiJ3l59wD5wj5jEz0xq7OpCnoP96d EPEAQIxiwBFgKXPMUjblcVfF1jApKCHZzjDccSziO+SSg== Received: from lists.sr.ht (unknown [46.23.81.154]) by mail-a.sr.ht (Postfix) with ESMTPSA id 83BE120238 for ; Mon, 23 Sep 2024 11:43:43 +0000 (UTC) Received: from cockroach.ash.relay.mailchannels.net (cockroach.ash.relay.mailchannels.net [23.83.222.37]) by mail-a.sr.ht (Postfix) with ESMTPS id 3F18E2015B for <~johnnyrichard/olang-devel@lists.sr.ht>; Mon, 23 Sep 2024 11:43:42 +0000 (UTC) X-Sender-Id: hostingeremail|x-authuser|carlos@maniero.me Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 556C984648E for <~johnnyrichard/olang-devel@lists.sr.ht>; Mon, 23 Sep 2024 11:43:40 +0000 (UTC) Received: from uk-fast-smtpout10.hostinger.io (100-99-96-141.trex-nlb.outbound.svc.cluster.local [100.99.96.141]) (Authenticated sender: hostingeremail) by relay.mailchannels.net (Postfix) with ESMTPA id A2E0B8468DA for <~johnnyrichard/olang-devel@lists.sr.ht>; Mon, 23 Sep 2024 11:43:39 +0000 (UTC) ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1727091820; a=rsa-sha256; cv=none; b=an0cImfDrT++SRuqaX96UZ6oxk5I1tSIGweQLNNPl7OqslyQUjhVXDPvImHzgELnxrKtKN pvADEYQJDBjvplSW25iZ0di+9C/jQwoxwY85iIuEbKHxcyZYHJZB9w8vmlBZIO93B9OVf6 NUY7C5QyBF1mNi4wbvuhuVooBN89bmYa5EJFQNsdcFJbhMC7jAwew3WIW0hAN6SREkKa2T EJhhmu+9FOt/u7jSIc2g903qAylrklPvrSXB+4uXGajmyjoNKaFQWg9K0oXzP+IO0iaFcz +gVInYLJeQEAVnsiNWrDh93QaIY4323in8ORYXpQm+Yz3LA+yYl+4Dt8LrndWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1727091820; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=WsS2JWQdCrvCMiYkDVMj7og7AfpJBO+ipuOooTrrorM=; b=u3b0bTJ5QpT4LuhyMdwtuQXjSzdY8ba0L6D56DN3C8oYFuZo2YHFqlin1epGgV0TBEcSmo DX20eJpsoy2kODQQroEaFno36oOpzCe+d6EJ578x0gwzVKiYE1ZFVf73+MjF4wbghmZ2YA nprMBGKVS2hBlUiz0ZORZ7xk8bdPqiOAHtlwf31pw+OBOZ9js6Y7QTRDZPzuC+mrqkcBqf aULq+9JOkzg+rtTJ2F5M2nC3N63JeKzwvxUf4bTaiip8+jdLqZqwBxwUlA1mDw/sKtuuHW Y0Q0Ac5su8NJ2ICXs7LRGkTpyCFK3ruz9ElGUe08LLJU0Vozx545mRFXS9EiPQ== ARC-Authentication-Results: i=1; rspamd-5b46bcd97f-2pssd; auth=pass smtp.auth=hostingeremail smtp.mailfrom=carlos@maniero.me X-Sender-Id: hostingeremail|x-authuser|carlos@maniero.me X-MC-Relay: Neutral X-MailChannels-SenderId: hostingeremail|x-authuser|carlos@maniero.me X-MailChannels-Auth-Id: hostingeremail X-Gusty-Quick: 6ab731d50fe9ee32_1727091820299_3179018035 X-MC-Loop-Signature: 1727091820299:1228354522 X-MC-Ingress-Time: 1727091820299 Received: from uk-fast-smtpout10.hostinger.io (uk-fast-smtpout10.hostinger.io [145.14.155.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.99.96.141 (trex/7.0.2); Mon, 23 Sep 2024 11:43:40 +0000 From: Carlos Maniero DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=maniero.me; s=hostingermail1; t=1727091817; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WsS2JWQdCrvCMiYkDVMj7og7AfpJBO+ipuOooTrrorM=; b=Q2bRc2A4DY0nO4nUUqc7vK4nTn3Qd42I1ZBGX+630Qm5OocOvpVgaYFVZxbm0DAgPMg0NI /KM3NBkY3LogM+GzDqDv0bdCwZ7/7I4G7RZjnDZ+Ftgvrvp13jbuwY1hShaqc1Tw90yPS1 6Uu1uRB7QYM4uH5HvACNkLJTzDbf43HOIOjrZKlMyTdRdUs4JVAE0BiuJhmlgzXKq8Q9oM 3hDQ8GaTCe5Tgc1ngR6v0d40L0P85BoPh75889fzHD0Hid4UmiLl+bC9MPPH0SUcekxro8 O49tX2lVVPvpfFh1qYtluuKuAen4ff+MIw9hcZT2GsJ2E6EsWqPA1xqUs2dNxw== To: ~johnnyrichard/olang-devel@lists.sr.ht Cc: Carlos Maniero Subject: [PATCH olang 1/2] ast: rename program to translation unit Message-Id: <20240923114330.120923-2-carlos@maniero.me> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240923114330.120923-1-carlos@maniero.me> References: <20240923114330.120923-1-carlos@maniero.me> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Date: Mon, 23 Sep 2024 11:43:36 +0000 (UTC) X-CM-Analysis: v=2.4 cv=TcnEtgQh c=1 sm=1 tr=0 ts=66f15469 a=WwxFCuf3mf1fs3oSi6/dng==:117 a=WwxFCuf3mf1fs3oSi6/dng==:17 a=MKtGQD3n3ToA:10 a=1oJP67jkp3AA:10 a=IGCRZ0Kd77xCY1R6oGQA:9 a=BXDaF_L80NY05PYiAFlV:22 X-CM-Envelope: MS4xfMNe6u93ZnhdjAvC5JrArZCNiyh8O6pz0m/3DRSxGXMibZMi3GGdCte4QFKwuqst5g2fYQrJcN0zmeTLBJYWvmo40RiHNMKBp2c4VUS2OEIsIhV1fAW/ +pXAkGRLNuCnT74s5uY9bJtBXdcLW3V8mtpUWtrR5V4i1OcK0ebaZCrhEzqlTnalXZhhrMNdV6rvsZ/2rwdtL3ts0May9zCtqoHEbsayF0rE9TDrNU+AcbUF X-AuthUser: carlos@maniero.me X-Sourcehut-Patchset-Status: UNKNOWN List-Unsubscribe: List-Subscribe: List-Archive: Archived-At: List-Post: List-ID: ~johnnyrichard/olang-devel <~johnnyrichard/olang-devel.lists.sr.ht> Sender: ~johnnyrichard/olang-devel <~johnnyrichard/olang-devel@lists.sr.ht> X-Migadu-Flow: FLOW_IN X-Migadu-Country: NL X-Migadu-Spam-Score: -0.16 X-Spam-Score: -0.16 X-Migadu-Queue-Id: 2A3A279D5 X-Migadu-Scanner: mx10.migadu.com X-TUID: Wy91a2xnKi8D That is the name we are calling it on the language spec and on --dump-ast. Signed-off-by: Carlos Maniero --- src/ast.c | 8 ++++---- src/ast.h | 10 +++++----- src/checker.c | 4 ++-- src/codegen_linux_aarch64.c | 8 ++++---- src/codegen_linux_aarch64.h | 2 +- src/codegen_linux_x86_64.c | 8 ++++---- src/codegen_linux_x86_64.h | 2 +- src/main.c | 10 +++++----- src/parser.c | 4 ++-- src/parser.h | 2 +- src/pretty_print_ast.c | 4 ++-- tests/unit/parser_test.c | 22 ++++++++++++---------- 12 files changed, 43 insertions(+), 41 deletions(-) diff --git a/src/ast.c b/src/ast.c index 7019316..f5fa483 100644 --- a/src/ast.c +++ b/src/ast.c @@ -23,15 +23,15 @@ #include "string_view.h" ast_node_t * -ast_new_program(arena_t *arena, ast_node_t *fn_def) +ast_new_translation_unit(arena_t *arena, ast_node_t *fn_def) { ast_node_t *node = (ast_node_t *)arena_alloc(arena, sizeof(ast_node_t)); assert(node); - node->kind = AST_NODE_PROGRAM; - ast_program_t *program = &node->as_program; + node->kind = AST_NODE_TRANSLATION_UNIT; + ast_translation_unit_t *translation_unit = &node->as_translation_unit; - program->fn = fn_def; + translation_unit->fn = fn_def; return node; } diff --git a/src/ast.h b/src/ast.h index df65e59..718c80f 100644 --- a/src/ast.h +++ b/src/ast.h @@ -29,7 +29,7 @@ typedef struct ast_node ast_node_t; typedef enum { - AST_NODE_PROGRAM, + AST_NODE_TRANSLATION_UNIT, AST_NODE_BLOCK, AST_NODE_FN_DEF, AST_NODE_VAR_DEF, @@ -46,10 +46,10 @@ typedef struct ast_block list_t *nodes; } ast_block_t; -typedef struct ast_program +typedef struct ast_translation_unit { ast_node_t *fn; -} ast_program_t; +} ast_translation_unit_t; typedef struct ast_fn_definition { @@ -133,7 +133,7 @@ typedef struct ast_node ast_node_kind_t kind; union { - ast_program_t as_program; + ast_translation_unit_t as_translation_unit; ast_fn_definition_t as_fn_def; ast_var_definition_t as_var_def; ast_binary_op_t as_bin_op; @@ -146,7 +146,7 @@ typedef struct ast_node } ast_node_t; ast_node_t * -ast_new_program(arena_t *arena, ast_node_t *fn_def); +ast_new_translation_unit(arena_t *arena, ast_node_t *fn_def); ast_node_t * ast_new_node_fn_def(arena_t *arena, string_view_t id, string_view_t return_type, ast_node_t *block); diff --git a/src/checker.c b/src/checker.c index 090920c..e9bfacb 100644 --- a/src/checker.c +++ b/src/checker.c @@ -53,8 +53,8 @@ static void populate_scope(checker_t *checker, scope_t *scope, ast_node_t *ast) { switch (ast->kind) { - case AST_NODE_PROGRAM: { - populate_scope(checker, scope, ast->as_program.fn); + case AST_NODE_TRANSLATION_UNIT: { + populate_scope(checker, scope, ast->as_translation_unit.fn); return; } diff --git a/src/codegen_linux_aarch64.c b/src/codegen_linux_aarch64.c index 93dde4f..e8ae729 100644 --- a/src/codegen_linux_aarch64.c +++ b/src/codegen_linux_aarch64.c @@ -42,14 +42,14 @@ static void codegen_linux_aarch64_emit_function(FILE *out, ast_fn_definition_t *fn); void -codegen_linux_aarch64_emit_program(FILE *out, ast_node_t *node) +codegen_linux_aarch64_emit_translation_unit(FILE *out, ast_node_t *node) { codegen_linux_aarch64_emit_start_entrypoint(out); - assert(node->kind == AST_NODE_PROGRAM); - ast_program_t program = node->as_program; + assert(node->kind == AST_NODE_TRANSLATION_UNIT); + ast_translation_unit_t translation_unit = node->as_translation_unit; - ast_fn_definition_t fn = program.fn->as_fn_def; + ast_fn_definition_t fn = translation_unit.fn->as_fn_def; assert(string_view_eq_to_cstr(fn.id, "main")); codegen_linux_aarch64_emit_function(out, &fn); diff --git a/src/codegen_linux_aarch64.h b/src/codegen_linux_aarch64.h index fb88b64..03e2f46 100644 --- a/src/codegen_linux_aarch64.h +++ b/src/codegen_linux_aarch64.h @@ -20,6 +20,6 @@ #include "ast.h" void -codegen_linux_aarch64_emit_program(FILE *out, ast_node_t *prog); +codegen_linux_aarch64_emit_translation_unit(FILE *out, ast_node_t *prog); #endif /* CODEGEN_LINUX_AARCH64_H */ diff --git a/src/codegen_linux_x86_64.c b/src/codegen_linux_x86_64.c index a0d9d97..37d4575 100644 --- a/src/codegen_linux_x86_64.c +++ b/src/codegen_linux_x86_64.c @@ -55,15 +55,15 @@ codegen_linux_x86_64_init(codegen_x86_64_t *codegen, arena_t *arena, FILE *out) } void -codegen_linux_x86_64_emit_program(codegen_x86_64_t *codegen, ast_node_t *node) +codegen_linux_x86_64_emit_translation_unit(codegen_x86_64_t *codegen, ast_node_t *node) { codegen->label_index = 0; codegen_linux_x86_64_emit_start_entrypoint(codegen); - assert(node->kind == AST_NODE_PROGRAM); - ast_program_t program = node->as_program; + assert(node->kind == AST_NODE_TRANSLATION_UNIT); + ast_translation_unit_t translation_unit = node->as_translation_unit; - ast_fn_definition_t fn = program.fn->as_fn_def; + ast_fn_definition_t fn = translation_unit.fn->as_fn_def; assert(string_view_eq_to_cstr(fn.id, "main")); codegen_linux_x86_64_emit_function(codegen, &fn); diff --git a/src/codegen_linux_x86_64.h b/src/codegen_linux_x86_64.h index 803c080..a4137de 100644 --- a/src/codegen_linux_x86_64.h +++ b/src/codegen_linux_x86_64.h @@ -35,6 +35,6 @@ void codegen_linux_x86_64_init(codegen_x86_64_t *codegen, arena_t *arena, FILE *out); void -codegen_linux_x86_64_emit_program(codegen_x86_64_t *codegen, ast_node_t *prog); +codegen_linux_x86_64_emit_translation_unit(codegen_x86_64_t *codegen, ast_node_t *prog); #endif /* CODEGEN_X86_64_H */ diff --git a/src/main.c b/src/main.c index 312b0c1..60b17bf 100644 --- a/src/main.c +++ b/src/main.c @@ -114,7 +114,7 @@ handle_dump_ast(cli_opts_t *opts) lexer_init(&lexer, file_content); parser_init(&parser, &lexer, &arena, opts->file_path); - ast_node_t *ast = parser_parse_program(&parser); + ast_node_t *ast = parser_parse_translation_unit(&parser); pretty_print_ast(ast); } @@ -135,7 +135,7 @@ handle_codegen_linux(cli_opts_t *opts) lexer_init(&lexer, file_content); parser_init(&parser, &lexer, &arena, opts->file_path); - ast_node_t *ast = parser_parse_program(&parser); + ast_node_t *ast = parser_parse_translation_unit(&parser); checker_t *checker = checker_new(&arena); checker_check(checker, ast); @@ -149,14 +149,14 @@ handle_codegen_linux(cli_opts_t *opts) if (!(opts->options & CLI_OPT_ARCH)) { codegen_x86_64_t codegen = { 0 }; codegen_linux_x86_64_init(&codegen, &arena, out); - codegen_linux_x86_64_emit_program(&codegen, ast); + codegen_linux_x86_64_emit_translation_unit(&codegen, ast); } else { if (strcmp(opts->arch, "x86_64") == 0) { codegen_x86_64_t codegen = { 0 }; codegen_linux_x86_64_init(&codegen, &arena, out); - codegen_linux_x86_64_emit_program(&codegen, ast); + codegen_linux_x86_64_emit_translation_unit(&codegen, ast); } else if (strcmp(opts->arch, "aarch64") == 0) { - codegen_linux_aarch64_emit_program(out, ast); + codegen_linux_aarch64_emit_translation_unit(out, ast); } else { fprintf(stderr, "error: architecture '%s' not supported\n", opts->arch); cli_print_usage(stderr, opts->compiler_path); diff --git a/src/parser.c b/src/parser.c index 3cae763..9332f6e 100644 --- a/src/parser.c +++ b/src/parser.c @@ -72,7 +72,7 @@ parser_init(parser_t *parser, lexer_t *lexer, arena_t *arena, char *file_path) } ast_node_t * -parser_parse_program(parser_t *parser) +parser_parse_translation_unit(parser_t *parser) { skip_line_feeds(parser->lexer); ast_node_t *fn = parser_parse_fn_definition(parser); @@ -80,7 +80,7 @@ parser_parse_program(parser_t *parser) return NULL; } - return ast_new_program(parser->arena, fn); + return ast_new_translation_unit(parser->arena, fn); } static ast_binary_op_kind_t diff --git a/src/parser.h b/src/parser.h index 5bcef1d..31c0dc3 100644 --- a/src/parser.h +++ b/src/parser.h @@ -33,6 +33,6 @@ void parser_init(parser_t *parser, lexer_t *lexer, arena_t *arena, char *file_path); ast_node_t * -parser_parse_program(parser_t *parser); +parser_parse_translation_unit(parser_t *parser); #endif /* PARSER_H */ diff --git a/src/pretty_print_ast.c b/src/pretty_print_ast.c index 1d5576d..db646c5 100644 --- a/src/pretty_print_ast.c +++ b/src/pretty_print_ast.c @@ -112,11 +112,11 @@ static pretty_print_node_t * ast_node_to_pretty_print_node(ast_node_t *ast, arena_t *arena) { switch (ast->kind) { - case AST_NODE_PROGRAM: { + case AST_NODE_TRANSLATION_UNIT: { pretty_print_node_t *node = pretty_print_node_new(arena); node->name = "Translation_Unit"; - pretty_print_node_t *fn_node = ast_node_to_pretty_print_node(ast->as_program.fn, arena); + pretty_print_node_t *fn_node = ast_node_to_pretty_print_node(ast->as_translation_unit.fn, arena); list_append(node->children, fn_node); return node; } diff --git a/tests/unit/parser_test.c b/tests/unit/parser_test.c index 8ad16b5..4e229be 100644 --- a/tests/unit/parser_test.c +++ b/tests/unit/parser_test.c @@ -27,7 +27,7 @@ #define ARENA_CAPACITY (1024 * 1024) static MunitResult -parse_program_test(const MunitParameter params[], void *user_data_or_fixture) +parse_translation_unit_test(const MunitParameter params[], void *user_data_or_fixture) { arena_t arena = arena_new(ARENA_CAPACITY); @@ -41,15 +41,15 @@ parse_program_test(const MunitParameter params[], void *user_data_or_fixture) parser_t parser; parser_init(&parser, &lexer, &arena, file_path); - ast_node_t *program_node = parser_parse_program(&parser); - assert_not_null(program_node); - assert_uint(program_node->kind, ==, AST_NODE_PROGRAM); + ast_node_t *translation_unit_node = parser_parse_translation_unit(&parser); + assert_not_null(translation_unit_node); + assert_uint(translation_unit_node->kind, ==, AST_NODE_TRANSLATION_UNIT); - ast_program_t program = program_node->as_program; - assert_not_null(program.fn); - assert_uint(program.fn->kind, ==, AST_NODE_FN_DEF); + ast_translation_unit_t translation_unit = translation_unit_node->as_translation_unit; + assert_not_null(translation_unit.fn); + assert_uint(translation_unit.fn->kind, ==, AST_NODE_FN_DEF); - ast_fn_definition_t fn = program.fn->as_fn_def; + ast_fn_definition_t fn = translation_unit.fn->as_fn_def; assert_memory_equal(fn.id.size, fn.id.chars, "main"); assert_memory_equal(fn.return_type.size, fn.return_type.chars, "u32"); @@ -77,8 +77,10 @@ parse_program_test(const MunitParameter params[], void *user_data_or_fixture) return MUNIT_OK; } -static MunitTest tests[] = { { "/parse_program", parse_program_test, NULL, NULL, MUNIT_TEST_OPTION_NONE, NULL }, - { NULL, NULL, NULL, NULL, MUNIT_TEST_OPTION_NONE, NULL } }; +static MunitTest tests[] = { + { "/parse_translation_unit", parse_translation_unit_test, NULL, NULL, MUNIT_TEST_OPTION_NONE, NULL }, + { NULL, NULL, NULL, NULL, MUNIT_TEST_OPTION_NONE, NULL } +}; static const MunitSuite suite = { "/parser", tests, NULL, 1, MUNIT_SUITE_OPTION_NONE }; -- 2.34.1