public inbox for ~johnnyrichard/olang-devel@lists.sr.ht
 help / color / mirror / code / Atom feed
* [PATCH olang 0/6] Suggestions in code style
@ 2024-10-10  1:33 Carlos Maniero
  2024-10-10  1:33 ` [PATCH olang v1 1/6] codestyle: change AlignAfterOpenBracket to BlockIndent Carlos Maniero
                   ` (5 more replies)
  0 siblings, 6 replies; 8+ messages in thread
From: Carlos Maniero @ 2024-10-10  1:33 UTC (permalink / raw)
  To: ~johnnyrichard/olang-devel; +Cc: Carlos Maniero

I split it into small changes so it is possible to be avaliated case by
case. Since this is a very opinionated and is more about preference than
anything, just let me know which changes you agree on and I send a new
patch.

Carlos Maniero (6):
  codestyle: change AlignAfterOpenBracket to BlockIndent
  codestyle: never BreakBeforeBraces
  codestyle: prevent extra empty lines at EOF
  codestyle: do not allow single line enums
  codestyle: add trailing comma on struct initializer
  codestyle: limit the code to 80 characters

 .clang-format                 |  27 +-
 src/arena.c                   |  15 +-
 src/arena.h                   |   3 +-
 src/ast.c                     | 122 ++++---
 src/ast.h                     | 132 ++++----
 src/checker.c                 |  28 +-
 src/checker.h                 |   3 +-
 src/cli.c                     |  55 +--
 src/cli.h                     |   9 +-
 src/codegen_linux_aarch64.c   |   9 +-
 src/codegen_linux_x86_64.c    | 615 ++++++++++++++++++++++++----------
 src/codegen_linux_x86_64.h    |   8 +-
 src/lexer.c                   | 164 +++++----
 src/lexer.h                   |  18 +-
 src/list.c                    |  18 +-
 src/list.h                    |   6 +-
 src/main.c                    |  73 ++--
 src/map.c                     |  53 +--
 src/map.h                     |   9 +-
 src/parser.c                  | 179 ++++++----
 src/parser.h                  |   3 +-
 src/pretty_print_ast.c        | 133 +++++---
 src/scope.c                   |  31 +-
 src/scope.h                   |   6 +-
 src/string_view.c             |  14 +-
 src/string_view.h             |   3 +-
 src/type.c                    |   6 +-
 src/type.h                    |  21 +-
 tests/unit/arena_test.c       |  35 +-
 tests/unit/list_test.c        |  45 ++-
 tests/unit/map_test.c         |  35 +-
 tests/unit/string_view_test.c |  55 ++-
 32 files changed, 1219 insertions(+), 714 deletions(-)


base-commit: d45df92d81f00059ecd1f6478bac7e4511d9fd8d
-- 
2.46.0


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH olang v1 1/6] codestyle: change AlignAfterOpenBracket to BlockIndent
  2024-10-10  1:33 [PATCH olang 0/6] Suggestions in code style Carlos Maniero
@ 2024-10-10  1:33 ` Carlos Maniero
  2024-10-10  1:33 ` [PATCH olang v1 2/6] codestyle: never BreakBeforeBraces Carlos Maniero
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 8+ messages in thread
From: Carlos Maniero @ 2024-10-10  1:33 UTC (permalink / raw)
  To: ~johnnyrichard/olang-devel; +Cc: Carlos Maniero

before:

my_call(ar1,
        arg2);

now:

my_call(
  ar1,
  arg2
);

Signed-off-by: Carlos Maniero <carlos@maniero.me>
---
 .clang-format              |   2 +-
 src/ast.c                  |  14 ++--
 src/ast.h                  |  14 ++--
 src/cli.c                  |  29 ++++---
 src/codegen_linux_x86_64.c | 151 ++++++++++++++++++++++---------------
 src/main.c                 |  24 +++---
 src/parser.c               |  16 ++--
 src/pretty_print_ast.c     |  11 +--
 src/scope.c                |   1 -
 9 files changed, 155 insertions(+), 107 deletions(-)

diff --git a/.clang-format b/.clang-format
index b76afee..5d4dd36 100644
--- a/.clang-format
+++ b/.clang-format
@@ -2,7 +2,7 @@
 Language:        Cpp
 # BasedOnStyle:  Mozilla
 AccessModifierOffset: -2
-AlignAfterOpenBracket: Align
+AlignAfterOpenBracket: BlockIndent
 AlignArrayOfStructures: None
 AlignConsecutiveAssignments:
   Enabled:         false
diff --git a/src/ast.c b/src/ast.c
index 5a36ccb..797f5fd 100644
--- a/src/ast.c
+++ b/src/ast.c
@@ -40,12 +40,14 @@ ast_new_translation_unit(arena_t *arena)
 }
 
 ast_node_t *
-ast_new_node_fn_def(arena_t *arena,
-                    token_loc_t loc,
-                    string_view_t id,
-                    list_t *params,
-                    type_t *return_type,
-                    ast_node_t *block)
+ast_new_node_fn_def(
+    arena_t *arena,
+    token_loc_t loc,
+    string_view_t id,
+    list_t *params,
+    type_t *return_type,
+    ast_node_t *block
+)
 {
     assert(arena);
     assert(params);
diff --git a/src/ast.h b/src/ast.h
index ee94f57..44caf68 100644
--- a/src/ast.h
+++ b/src/ast.h
@@ -221,12 +221,14 @@ ast_node_t *
 ast_new_translation_unit(arena_t *arena);
 
 ast_node_t *
-ast_new_node_fn_def(arena_t *arena,
-                    token_loc_t loc,
-                    string_view_t id,
-                    list_t *params,
-                    type_t *return_type,
-                    ast_node_t *block);
+ast_new_node_fn_def(
+    arena_t *arena,
+    token_loc_t loc,
+    string_view_t id,
+    list_t *params,
+    type_t *return_type,
+    ast_node_t *block
+);
 
 ast_node_t *
 ast_new_node_fn_call(arena_t *arena, token_loc_t loc, string_view_t id, list_t *args);
diff --git a/src/cli.c b/src/cli.c
index 9d0f875..2faf6ce 100644
--- a/src/cli.c
+++ b/src/cli.c
@@ -107,7 +107,11 @@ cli_opts_parse_arch(cli_opts_t *opts, cli_args_t *args)
     char *arch = cli_args_shift(args);
 
     if (arch == NULL) {
-        fprintf(stderr, "error: missing architecture for arg '--arch': available options (x86_64 | aarch64)\n");
+        fprintf(
+            stderr,
+            "error: missing architecture for arg '--arch': "
+            "available options (x86_64 | aarch64)\n"
+        );
         cli_print_usage(stderr, opts->compiler_path);
         exit(EXIT_FAILURE);
     }
@@ -137,14 +141,17 @@ cli_opts_parse_sysroot(cli_opts_t *opts, cli_args_t *args)
 void
 cli_print_usage(FILE *stream, char *compiler_path)
 {
-    fprintf(stream,
-            "Usage: %s [options] file...\n"
-            "Options:\n"
-            "  --dump-tokens    Display lexer token stream\n"
-            "  --dump-ast       Display ast tree to stdout\n"
-            "  --arch <arch>    Binary arch: default to x86_64 (x86_64 | aarch64)\n"
-            "  --sysroot <dir>  System root dir where the GNU Assembler and GNU Linker are located: default to '/'\n"
-            "  -o <file>        Compile program into a binary file\n"
-            "  --save-temps     Keep temp files used to compile program\n",
-            compiler_path);
+    fprintf(
+        stream,
+        "Usage: %s [options] file...\n"
+        "Options:\n"
+        "  --dump-tokens    Display lexer token stream\n"
+        "  --dump-ast       Display ast tree to stdout\n"
+        "  --arch <arch>    Binary arch: default to x86_64 (x86_64 | aarch64)\n"
+        "  --sysroot <dir>  System root dir where the GNU Assembler and GNU "
+        "Linker are located: default to '/'\n"
+        "  -o <file>        Compile program into a binary file\n"
+        "  --save-temps     Keep temp files used to compile program\n",
+        compiler_path
+    );
 }
diff --git a/src/codegen_linux_x86_64.c b/src/codegen_linux_x86_64.c
index ae28aa5..9a8d76e 100644
--- a/src/codegen_linux_x86_64.c
+++ b/src/codegen_linux_x86_64.c
@@ -211,10 +211,12 @@ codegen_linux_x86_64_emit_expression(codegen_x86_64_t *codegen, ast_node_t *expr
                     size_in_bytes_t expr_bytes = bytes_max(rhs_bytes, lhs_bytes);
 
                     fprintf(codegen->out, "    pop %%rcx\n");
-                    fprintf(codegen->out,
-                            "    add %s, %s\n",
-                            get_reg_for(REG_COUNTER, expr_bytes),
-                            get_reg_for(REG_ACCUMULATOR, expr_bytes));
+                    fprintf(
+                        codegen->out,
+                        "    add %s, %s\n",
+                        get_reg_for(REG_COUNTER, expr_bytes),
+                        get_reg_for(REG_ACCUMULATOR, expr_bytes)
+                    );
 
                     return expr_bytes;
                 }
@@ -262,10 +264,12 @@ codegen_linux_x86_64_emit_expression(codegen_x86_64_t *codegen, ast_node_t *expr
                     fprintf(codegen->out, "    pop %%rcx\n");
                     fprintf(codegen->out, "    xor %%rdx, %%rdx\n");
                     fprintf(codegen->out, "    div %s\n", get_reg_for(REG_COUNTER, expr_bytes));
-                    fprintf(codegen->out,
-                            "    mov %s, %s\n",
-                            get_reg_for(REG_DATA, expr_bytes),
-                            get_reg_for(REG_ACCUMULATOR, expr_bytes));
+                    fprintf(
+                        codegen->out,
+                        "    mov %s, %s\n",
+                        get_reg_for(REG_DATA, expr_bytes),
+                        get_reg_for(REG_ACCUMULATOR, expr_bytes)
+                    );
 
                     return expr_bytes;
                 }
@@ -280,10 +284,12 @@ codegen_linux_x86_64_emit_expression(codegen_x86_64_t *codegen, ast_node_t *expr
                     size_in_bytes_t expr_bytes = bytes_max(rhs_bytes, lhs_bytes);
 
                     fprintf(codegen->out, "    pop %%rcx\n");
-                    fprintf(codegen->out,
-                            "    sub %s, %s\n",
-                            get_reg_for(REG_COUNTER, expr_bytes),
-                            get_reg_for(REG_ACCUMULATOR, expr_bytes));
+                    fprintf(
+                        codegen->out,
+                        "    sub %s, %s\n",
+                        get_reg_for(REG_COUNTER, expr_bytes),
+                        get_reg_for(REG_ACCUMULATOR, expr_bytes)
+                    );
 
                     return expr_bytes;
                 }
@@ -298,10 +304,12 @@ codegen_linux_x86_64_emit_expression(codegen_x86_64_t *codegen, ast_node_t *expr
                     size_in_bytes_t expr_bytes = bytes_max(rhs_bytes, lhs_bytes);
 
                     fprintf(codegen->out, "    pop %%rcx\n");
-                    fprintf(codegen->out,
-                            "    cmp %s, %s\n",
-                            get_reg_for(REG_COUNTER, expr_bytes),
-                            get_reg_for(REG_ACCUMULATOR, expr_bytes));
+                    fprintf(
+                        codegen->out,
+                        "    cmp %s, %s\n",
+                        get_reg_for(REG_COUNTER, expr_bytes),
+                        get_reg_for(REG_ACCUMULATOR, expr_bytes)
+                    );
                     fprintf(codegen->out, "    sete %%al\n");
                     fprintf(codegen->out, "    movzb %%al, %s\n", get_reg_for(REG_ACCUMULATOR, expr_bytes));
 
@@ -318,10 +326,12 @@ codegen_linux_x86_64_emit_expression(codegen_x86_64_t *codegen, ast_node_t *expr
                     size_in_bytes_t expr_bytes = bytes_max(rhs_bytes, lhs_bytes);
 
                     fprintf(codegen->out, "    pop %%rcx\n");
-                    fprintf(codegen->out,
-                            "    cmp %s, %s\n",
-                            get_reg_for(REG_COUNTER, expr_bytes),
-                            get_reg_for(REG_ACCUMULATOR, expr_bytes));
+                    fprintf(
+                        codegen->out,
+                        "    cmp %s, %s\n",
+                        get_reg_for(REG_COUNTER, expr_bytes),
+                        get_reg_for(REG_ACCUMULATOR, expr_bytes)
+                    );
                     fprintf(codegen->out, "    setl %%al\n");
                     fprintf(codegen->out, "    movzb %%al, %s\n", get_reg_for(REG_ACCUMULATOR, expr_bytes));
 
@@ -338,10 +348,12 @@ codegen_linux_x86_64_emit_expression(codegen_x86_64_t *codegen, ast_node_t *expr
                     size_in_bytes_t expr_bytes = bytes_max(rhs_bytes, lhs_bytes);
 
                     fprintf(codegen->out, "    pop %%rcx\n");
-                    fprintf(codegen->out,
-                            "    cmp %s, %s\n",
-                            get_reg_for(REG_COUNTER, expr_bytes),
-                            get_reg_for(REG_ACCUMULATOR, expr_bytes));
+                    fprintf(
+                        codegen->out,
+                        "    cmp %s, %s\n",
+                        get_reg_for(REG_COUNTER, expr_bytes),
+                        get_reg_for(REG_ACCUMULATOR, expr_bytes)
+                    );
                     fprintf(codegen->out, "    setg %%al\n");
                     fprintf(codegen->out, "    movzb %%al, %s\n", get_reg_for(REG_ACCUMULATOR, expr_bytes));
 
@@ -358,10 +370,12 @@ codegen_linux_x86_64_emit_expression(codegen_x86_64_t *codegen, ast_node_t *expr
                     size_in_bytes_t expr_bytes = bytes_max(rhs_bytes, lhs_bytes);
 
                     fprintf(codegen->out, "    pop %%rcx\n");
-                    fprintf(codegen->out,
-                            "    cmp %s, %s\n",
-                            get_reg_for(REG_COUNTER, expr_bytes),
-                            get_reg_for(REG_ACCUMULATOR, expr_bytes));
+                    fprintf(
+                        codegen->out,
+                        "    cmp %s, %s\n",
+                        get_reg_for(REG_COUNTER, expr_bytes),
+                        get_reg_for(REG_ACCUMULATOR, expr_bytes)
+                    );
                     fprintf(codegen->out, "    setne %%al\n");
                     fprintf(codegen->out, "    movzb %%al, %s\n", get_reg_for(REG_ACCUMULATOR, expr_bytes));
 
@@ -378,10 +392,12 @@ codegen_linux_x86_64_emit_expression(codegen_x86_64_t *codegen, ast_node_t *expr
                     size_in_bytes_t expr_bytes = bytes_max(rhs_bytes, lhs_bytes);
 
                     fprintf(codegen->out, "    pop %%rcx\n");
-                    fprintf(codegen->out,
-                            "    cmp %s, %s\n",
-                            get_reg_for(REG_COUNTER, expr_bytes),
-                            get_reg_for(REG_ACCUMULATOR, expr_bytes));
+                    fprintf(
+                        codegen->out,
+                        "    cmp %s, %s\n",
+                        get_reg_for(REG_COUNTER, expr_bytes),
+                        get_reg_for(REG_ACCUMULATOR, expr_bytes)
+                    );
                     fprintf(codegen->out, "    setle %%al\n");
                     fprintf(codegen->out, "    movzb %%al, %s\n", get_reg_for(REG_ACCUMULATOR, expr_bytes));
 
@@ -398,10 +414,12 @@ codegen_linux_x86_64_emit_expression(codegen_x86_64_t *codegen, ast_node_t *expr
                     size_in_bytes_t expr_bytes = bytes_max(rhs_bytes, lhs_bytes);
 
                     fprintf(codegen->out, "    pop %%rcx\n");
-                    fprintf(codegen->out,
-                            "    cmp %s, %s\n",
-                            get_reg_for(REG_COUNTER, expr_bytes),
-                            get_reg_for(REG_ACCUMULATOR, expr_bytes));
+                    fprintf(
+                        codegen->out,
+                        "    cmp %s, %s\n",
+                        get_reg_for(REG_COUNTER, expr_bytes),
+                        get_reg_for(REG_ACCUMULATOR, expr_bytes)
+                    );
                     fprintf(codegen->out, "    setge %%al\n");
                     fprintf(codegen->out, "    movzb %%al, %s\n", get_reg_for(REG_ACCUMULATOR, expr_bytes));
 
@@ -444,10 +462,12 @@ codegen_linux_x86_64_emit_expression(codegen_x86_64_t *codegen, ast_node_t *expr
                     size_in_bytes_t expr_bytes = bytes_max(rhs_bytes, lhs_bytes);
 
                     fprintf(codegen->out, "    pop %%rcx\n");
-                    fprintf(codegen->out,
-                            "    xor %s, %s\n",
-                            get_reg_for(REG_COUNTER, expr_bytes),
-                            get_reg_for(REG_ACCUMULATOR, expr_bytes));
+                    fprintf(
+                        codegen->out,
+                        "    xor %s, %s\n",
+                        get_reg_for(REG_COUNTER, expr_bytes),
+                        get_reg_for(REG_ACCUMULATOR, expr_bytes)
+                    );
 
                     return expr_bytes;
                 }
@@ -462,10 +482,12 @@ codegen_linux_x86_64_emit_expression(codegen_x86_64_t *codegen, ast_node_t *expr
                     size_in_bytes_t expr_bytes = bytes_max(rhs_bytes, lhs_bytes);
 
                     fprintf(codegen->out, "    pop %%rcx\n");
-                    fprintf(codegen->out,
-                            "    and %s, %s\n",
-                            get_reg_for(REG_COUNTER, expr_bytes),
-                            get_reg_for(REG_ACCUMULATOR, expr_bytes));
+                    fprintf(
+                        codegen->out,
+                        "    and %s, %s\n",
+                        get_reg_for(REG_COUNTER, expr_bytes),
+                        get_reg_for(REG_ACCUMULATOR, expr_bytes)
+                    );
 
                     return expr_bytes;
                 }
@@ -480,10 +502,12 @@ codegen_linux_x86_64_emit_expression(codegen_x86_64_t *codegen, ast_node_t *expr
                     size_in_bytes_t expr_bytes = bytes_max(rhs_bytes, lhs_bytes);
 
                     fprintf(codegen->out, "    pop %%rcx\n");
-                    fprintf(codegen->out,
-                            "    or %s, %s\n",
-                            get_reg_for(REG_COUNTER, expr_bytes),
-                            get_reg_for(REG_ACCUMULATOR, expr_bytes));
+                    fprintf(
+                        codegen->out,
+                        "    or %s, %s\n",
+                        get_reg_for(REG_COUNTER, expr_bytes),
+                        get_reg_for(REG_ACCUMULATOR, expr_bytes)
+                    );
 
                     return expr_bytes;
                 }
@@ -590,10 +614,12 @@ codegen_linux_x86_64_emit_block(codegen_x86_64_t *codegen, ast_block_t *block)
 
                 size_t type_size = type_to_bytes(symbol->type);
 
-                fprintf(codegen->out,
-                        "    mov %s, -%ld(%%rbp)\n",
-                        get_reg_for(REG_ACCUMULATOR, type_size),
-                        codegen->base_offset);
+                fprintf(
+                    codegen->out,
+                    "    mov %s, -%ld(%%rbp)\n",
+                    get_reg_for(REG_ACCUMULATOR, type_size),
+                    codegen->base_offset
+                );
                 codegen->base_offset += type_size;
 
                 break;
@@ -647,7 +673,8 @@ codegen_linux_x86_64_emit_block(codegen_x86_64_t *codegen, ast_block_t *block)
                 break;
             }
             default: {
-                // FIXME: improve error: replace the node->kind to a string representation
+                // FIXME: improve error: replace the node->kind to a string
+                // representation
                 fprintf(stderr, "node kind %d not supported\n", node->kind);
                 assert(0 && "unsupported block statement");
                 break;
@@ -704,7 +731,10 @@ type_to_bytes(type_t *type)
             return 8;
         }
         case TYPE_UNKNOWN: {
-            assert(0 && "cannot calculate size of an unknown type: probably a parser issue.");
+            assert(
+                0 && "cannot calculate size of an unknown type: probably a "
+                     "parser issue."
+            );
         }
     }
 
@@ -770,11 +800,13 @@ codegen_linux_x86_64_emit_function(codegen_x86_64_t *codegen, ast_fn_definition_
 
         codegen_linux_x86_64_put_stack_offset(codegen, symbol, codegen->base_offset);
 
-        fprintf(codegen->out,
-                "    mov %s, -%ld(%%rbp)\n",
-                // FIXME: Type may not be an as_primitive
-                get_reg_for(x86_call_args[i], symbol->type->as_primitive.size),
-                offset);
+        fprintf(
+            codegen->out,
+            "    mov %s, -%ld(%%rbp)\n",
+            // FIXME: Type may not be an as_primitive
+            get_reg_for(x86_call_args[i], symbol->type->as_primitive.size),
+            offset
+        );
 
         // FIXME: add offset according to the param size
         codegen->base_offset += 8;
@@ -796,7 +828,6 @@ codegen_linux_x86_64_emit_function(codegen_x86_64_t *codegen, ast_fn_definition_
 static void
 codegen_linux_x86_64_put_stack_offset(codegen_x86_64_t *codegen, symbol_t *symbol, size_t offset)
 {
-
     size_t *stack_offset = arena_alloc(codegen->arena, sizeof(size_t));
     *stack_offset = offset;
 
diff --git a/src/main.c b/src/main.c
index d1c76e3..d7738bd 100644
--- a/src/main.c
+++ b/src/main.c
@@ -179,11 +179,13 @@ handle_codegen_linux(cli_opts_t *opts)
         exit(exit_code);
     }
 
-    sprintf(command,
-            "%s/bin/ld " SV_FMT ".o -o " SV_FMT "",
-            opts->sysroot,
-            SV_ARG(opts->output_bin),
-            SV_ARG(opts->output_bin));
+    sprintf(
+        command,
+        "%s/bin/ld " SV_FMT ".o -o " SV_FMT "",
+        opts->sysroot,
+        SV_ARG(opts->output_bin),
+        SV_ARG(opts->output_bin)
+    );
 
     exit_code = system(command);
 
@@ -244,9 +246,11 @@ read_entire_file(char *filepath, arena_t *arena)
 static void
 print_token(token_t *token)
 {
-    printf("%s:%lu:%lu: <%s>\n",
-           token->loc.src.filepath,
-           token_loc_to_lineno(token->loc),
-           token_loc_to_colno(token->loc),
-           token_kind_to_cstr(token->kind));
+    printf(
+        "%s:%lu:%lu: <%s>\n",
+        token->loc.src.filepath,
+        token_loc_to_lineno(token->loc),
+        token_loc_to_colno(token->loc),
+        token_kind_to_cstr(token->kind)
+    );
 }
diff --git a/src/parser.c b/src/parser.c
index f712bfc..9d3d6e0 100644
--- a/src/parser.c
+++ b/src/parser.c
@@ -750,13 +750,15 @@ static bool
 expected_token(token_t *token, token_kind_t expected_kind)
 {
     if (token->kind != expected_kind) {
-        fprintf(stderr,
-                "%s:%lu:%lu: syntax error: got '" SV_FMT "' token but expect '%s'\n",
-                token->loc.src.filepath,
-                token_loc_to_lineno(token->loc),
-                token_loc_to_colno(token->loc),
-                SV_ARG(token->value),
-                token_kind_to_cstr(expected_kind));
+        fprintf(
+            stderr,
+            "%s:%lu:%lu: syntax error: got '" SV_FMT "' token but expect '%s'\n",
+            token->loc.src.filepath,
+            token_loc_to_lineno(token->loc),
+            token_loc_to_colno(token->loc),
+            SV_ARG(token->value),
+            token_kind_to_cstr(expected_kind)
+        );
 
         fprintf(stderr, SV_FMT "\n", SV_ARG(token_loc_to_line(token->loc)));
         fprintf(stderr, "%*s\n", (int)token_loc_to_colno(token->loc), "^");
diff --git a/src/pretty_print_ast.c b/src/pretty_print_ast.c
index 3a42412..f5cd571 100644
--- a/src/pretty_print_ast.c
+++ b/src/pretty_print_ast.c
@@ -57,7 +57,6 @@ pretty_print_print_ident(uint64_t *prefix, size_t level, bool lst_children)
     }
 
     for (size_t i = 0; i < level; ++i) {
-
         if (!PP_IS_BIT_SET(*prefix, i)) {
             printf("  ");
             continue;
@@ -145,10 +144,12 @@ ast_node_to_pretty_print_node(ast_node_t *ast, arena_t *arena)
             ast_fn_definition_t fn_def = ast->as_fn_def;
 
             char name[256];
-            sprintf(name,
-                    "Function_Definition <name:" SV_FMT "> <return:" SV_FMT ">",
-                    SV_ARG(fn_def.id),
-                    SV_ARG(fn_def.return_type->id));
+            sprintf(
+                name,
+                "Function_Definition <name:" SV_FMT "> <return:" SV_FMT ">",
+                SV_ARG(fn_def.id),
+                SV_ARG(fn_def.return_type->id)
+            );
             node->name = (char *)arena_alloc(arena, sizeof(char) * (strlen(name) + 1));
             strcpy(node->name, name);
 
diff --git a/src/scope.c b/src/scope.c
index e483fbe..ff9067c 100644
--- a/src/scope.c
+++ b/src/scope.c
@@ -67,7 +67,6 @@ scope_lookup(scope_t *scope, string_view_t id)
 {
     assert(scope);
     while (scope != NULL) {
-
         char cstr_id[id.size + 1];
         cstr_id[id.size] = 0;
         memcpy(cstr_id, id.chars, id.size);
-- 
2.46.0


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH olang v1 2/6] codestyle: never BreakBeforeBraces
  2024-10-10  1:33 [PATCH olang 0/6] Suggestions in code style Carlos Maniero
  2024-10-10  1:33 ` [PATCH olang v1 1/6] codestyle: change AlignAfterOpenBracket to BlockIndent Carlos Maniero
@ 2024-10-10  1:33 ` Carlos Maniero
  2024-10-10  1:33 ` [PATCH olang v1 3/6] codestyle: prevent extra empty lines at EOF Carlos Maniero
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 8+ messages in thread
From: Carlos Maniero @ 2024-10-10  1:33 UTC (permalink / raw)
  To: ~johnnyrichard/olang-devel; +Cc: Carlos Maniero

Before we had this standard:

struct
{
}

void main() # This breaks
{
  if (true) { # This does not
  }
}

Now:
struct {
}

void main() {
  if (true) { # This does not
  }
}

Signed-off-by: Carlos Maniero <carlos@maniero.me>
---
 .clang-format                 | 18 ++++-----
 src/arena.c                   | 15 +++-----
 src/arena.h                   |  3 +-
 src/ast.c                     | 42 +++++++-------------
 src/ast.h                     | 68 +++++++++++----------------------
 src/checker.c                 | 15 +++-----
 src/checker.h                 |  3 +-
 src/cli.c                     | 18 +++------
 src/cli.h                     |  9 ++---
 src/codegen_linux_aarch64.c   |  9 ++---
 src/codegen_linux_x86_64.c    | 42 +++++++-------------
 src/codegen_linux_x86_64.h    |  3 +-
 src/lexer.c                   | 54 +++++++++-----------------
 src/lexer.h                   | 18 +++------
 src/list.c                    | 18 +++------
 src/list.h                    |  6 +--
 src/main.c                    | 18 +++------
 src/map.c                     | 24 ++++--------
 src/map.h                     |  9 ++---
 src/parser.c                  | 72 ++++++++++++-----------------------
 src/parser.h                  |  3 +-
 src/pretty_print_ast.c        | 24 ++++--------
 src/scope.c                   | 18 +++------
 src/scope.h                   |  6 +--
 src/string_view.c             |  9 ++---
 src/string_view.h             |  3 +-
 src/type.c                    |  6 +--
 src/type.h                    | 30 ++++-----------
 tests/unit/arena_test.c       |  9 ++---
 tests/unit/list_test.c        | 12 ++----
 tests/unit/map_test.c         | 12 ++----
 tests/unit/string_view_test.c |  9 ++---
 32 files changed, 201 insertions(+), 404 deletions(-)

diff --git a/.clang-format b/.clang-format
index 5d4dd36..68c0e5b 100644
--- a/.clang-format
+++ b/.clang-format
@@ -50,26 +50,26 @@ BinPackArguments: false
 BinPackParameters: false
 BraceWrapping:
   AfterCaseLabel:  false
-  AfterClass:      true
+  AfterClass:      false
   AfterControlStatement: Never
-  AfterEnum:       true
-  AfterFunction:   true
+  AfterEnum:       false
+  AfterFunction:   false
   AfterNamespace:  false
   AfterObjCDeclaration: false
-  AfterStruct:     true
-  AfterUnion:      true
-  AfterExternBlock: true
+  AfterStruct:     false
+  AfterUnion:      false
+  AfterExternBlock: false
   BeforeCatch:     false
   BeforeElse:      false
   BeforeLambdaBody: false
   BeforeWhile:     false
   IndentBraces:    false
-  SplitEmptyFunction: true
+  SplitEmptyFunction: false
   SplitEmptyRecord: false
-  SplitEmptyNamespace: true
+  SplitEmptyNamespace: false
 BreakBeforeBinaryOperators: None
 BreakBeforeConceptDeclarations: Always
-BreakBeforeBraces: Mozilla
+BreakBeforeBraces: Custom
 BreakBeforeInheritanceComma: false
 BreakInheritanceList: BeforeComma
 BreakBeforeTernaryOperators: true
diff --git a/src/arena.c b/src/arena.c
index ad2e535..12045fe 100644
--- a/src/arena.c
+++ b/src/arena.c
@@ -19,8 +19,7 @@
 #include <stdlib.h>
 
 arena_t
-arena_new(size_t size)
-{
+arena_new(size_t size) {
     arena_t arena;
     arena.offset = 0;
     arena.region = malloc(sizeof(uint8_t) * size);
@@ -32,8 +31,7 @@ static uint8_t
 arena_padding(size_t bytes);
 
 void *
-arena_alloc(arena_t *arena, size_t bytes)
-{
+arena_alloc(arena_t *arena, size_t bytes) {
     if ((arena->offset + bytes) > arena->size) {
         return NULL;
     }
@@ -44,20 +42,17 @@ arena_alloc(arena_t *arena, size_t bytes)
 }
 
 void
-arena_release(arena_t *arena)
-{
+arena_release(arena_t *arena) {
     arena->offset = 0;
 }
 
 void
-arena_free(arena_t *arena)
-{
+arena_free(arena_t *arena) {
     arena->size = 0;
     free(arena->region);
 }
 
 static uint8_t
-arena_padding(size_t bytes)
-{
+arena_padding(size_t bytes) {
     return (ARENA_ALIGNMENT_BYTES - bytes) & ARENA_ALIGNMENT_BYTES_MASK;
 }
diff --git a/src/arena.h b/src/arena.h
index 03fd803..168a39f 100644
--- a/src/arena.h
+++ b/src/arena.h
@@ -22,8 +22,7 @@
 #define ARENA_ALIGNMENT_BYTES 16
 #define ARENA_ALIGNMENT_BYTES_MASK (ARENA_ALIGNMENT_BYTES - 1)
 
-typedef struct arena
-{
+typedef struct arena {
     size_t offset;
     size_t size;
     uint8_t *region;
diff --git a/src/ast.c b/src/ast.c
index 797f5fd..1a23864 100644
--- a/src/ast.c
+++ b/src/ast.c
@@ -23,8 +23,7 @@
 #include "string_view.h"
 
 ast_node_t *
-ast_new_translation_unit(arena_t *arena)
-{
+ast_new_translation_unit(arena_t *arena) {
     ast_node_t *node = (ast_node_t *)arena_alloc(arena, sizeof(ast_node_t));
     assert(node);
 
@@ -47,8 +46,7 @@ ast_new_node_fn_def(
     list_t *params,
     type_t *return_type,
     ast_node_t *block
-)
-{
+) {
     assert(arena);
     assert(params);
     assert(block);
@@ -69,8 +67,7 @@ ast_new_node_fn_def(
 }
 
 ast_node_t *
-ast_new_node_fn_call(arena_t *arena, token_loc_t loc, string_view_t id, list_t *args)
-{
+ast_new_node_fn_call(arena_t *arena, token_loc_t loc, string_view_t id, list_t *args) {
     assert(arena);
     assert(args);
 
@@ -88,8 +85,7 @@ ast_new_node_fn_call(arena_t *arena, token_loc_t loc, string_view_t id, list_t *
 }
 
 ast_node_t *
-ast_new_node_var_def(arena_t *arena, token_loc_t loc, string_view_t id, type_t *type, ast_node_t *value)
-{
+ast_new_node_var_def(arena_t *arena, token_loc_t loc, string_view_t id, type_t *type, ast_node_t *value) {
     ast_node_t *node_var_def = (ast_node_t *)arena_alloc(arena, sizeof(ast_node_t));
     assert(node_var_def);
 
@@ -105,8 +101,7 @@ ast_new_node_var_def(arena_t *arena, token_loc_t loc, string_view_t id, type_t *
 }
 
 ast_node_t *
-ast_new_node_bin_op(arena_t *arena, token_loc_t loc, ast_binary_op_kind_t kind, ast_node_t *lhs, ast_node_t *rhs)
-{
+ast_new_node_bin_op(arena_t *arena, token_loc_t loc, ast_binary_op_kind_t kind, ast_node_t *lhs, ast_node_t *rhs) {
     ast_node_t *node_bin_op = (ast_node_t *)arena_alloc(arena, sizeof(ast_node_t));
     assert(node_bin_op);
 
@@ -120,8 +115,7 @@ ast_new_node_bin_op(arena_t *arena, token_loc_t loc, ast_binary_op_kind_t kind,
 }
 
 ast_node_t *
-ast_new_node_unary_op(arena_t *arena, token_loc_t loc, ast_unary_op_kind_t kind, ast_node_t *expr)
-{
+ast_new_node_unary_op(arena_t *arena, token_loc_t loc, ast_unary_op_kind_t kind, ast_node_t *expr) {
     ast_node_t *node_unary_op = (ast_node_t *)arena_alloc(arena, sizeof(ast_node_t));
     assert(node_unary_op);
 
@@ -134,8 +128,7 @@ ast_new_node_unary_op(arena_t *arena, token_loc_t loc, ast_unary_op_kind_t kind,
 }
 
 ast_node_t *
-ast_new_node_literal_u32(arena_t *arena, token_loc_t loc, uint32_t value)
-{
+ast_new_node_literal_u32(arena_t *arena, token_loc_t loc, uint32_t value) {
     ast_node_t *node_literal = (ast_node_t *)arena_alloc(arena, sizeof(ast_node_t));
     assert(node_literal);
 
@@ -148,8 +141,7 @@ ast_new_node_literal_u32(arena_t *arena, token_loc_t loc, uint32_t value)
 }
 
 ast_node_t *
-ast_new_node_ref(arena_t *arena, token_loc_t loc, string_view_t id)
-{
+ast_new_node_ref(arena_t *arena, token_loc_t loc, string_view_t id) {
     ast_node_t *node_ref = (ast_node_t *)arena_alloc(arena, sizeof(ast_node_t));
     assert(node_ref);
 
@@ -161,8 +153,7 @@ ast_new_node_ref(arena_t *arena, token_loc_t loc, string_view_t id)
 }
 
 ast_node_t *
-ast_new_node_var_assign_stmt(arena_t *arena, token_loc_t loc, ast_node_t *ref, ast_node_t *expr)
-{
+ast_new_node_var_assign_stmt(arena_t *arena, token_loc_t loc, ast_node_t *ref, ast_node_t *expr) {
     ast_node_t *node_var_assign_stmt = (ast_node_t *)arena_alloc(arena, sizeof(ast_node_t));
     assert(node_var_assign_stmt);
 
@@ -175,8 +166,7 @@ ast_new_node_var_assign_stmt(arena_t *arena, token_loc_t loc, ast_node_t *ref, a
 }
 
 ast_node_t *
-ast_new_node_return_stmt(arena_t *arena, token_loc_t loc, ast_node_t *expr)
-{
+ast_new_node_return_stmt(arena_t *arena, token_loc_t loc, ast_node_t *expr) {
     ast_node_t *node_return_stmt = (ast_node_t *)arena_alloc(arena, sizeof(ast_node_t));
     assert(node_return_stmt);
 
@@ -188,8 +178,7 @@ ast_new_node_return_stmt(arena_t *arena, token_loc_t loc, ast_node_t *expr)
 }
 
 ast_node_t *
-ast_new_node_if_stmt(arena_t *arena, token_loc_t loc, ast_node_t *cond, ast_node_t *then, ast_node_t *_else)
-{
+ast_new_node_if_stmt(arena_t *arena, token_loc_t loc, ast_node_t *cond, ast_node_t *then, ast_node_t *_else) {
     ast_node_t *node_if_stmt = arena_alloc(arena, sizeof(ast_node_t));
     assert(node_if_stmt);
 
@@ -203,8 +192,7 @@ ast_new_node_if_stmt(arena_t *arena, token_loc_t loc, ast_node_t *cond, ast_node
 }
 
 ast_node_t *
-ast_new_node_while_stmt(arena_t *arena, token_loc_t loc, ast_node_t *cond, ast_node_t *then)
-{
+ast_new_node_while_stmt(arena_t *arena, token_loc_t loc, ast_node_t *cond, ast_node_t *then) {
     ast_node_t *node_while_stmt = arena_alloc(arena, sizeof(ast_node_t));
     assert(node_while_stmt);
 
@@ -217,8 +205,7 @@ ast_new_node_while_stmt(arena_t *arena, token_loc_t loc, ast_node_t *cond, ast_n
 }
 
 ast_node_t *
-ast_new_node_block(arena_t *arena)
-{
+ast_new_node_block(arena_t *arena) {
     ast_node_t *node_block = (ast_node_t *)arena_alloc(arena, sizeof(ast_node_t));
     assert(node_block);
 
@@ -233,8 +220,7 @@ ast_new_node_block(arena_t *arena)
 }
 
 ast_fn_param_t *
-ast_new_fn_param(arena_t *arena, string_view_t id, type_t *type)
-{
+ast_new_fn_param(arena_t *arena, string_view_t id, type_t *type) {
     ast_fn_param_t *fn_param = (ast_fn_param_t *)arena_alloc(arena, sizeof(ast_fn_param_t));
     assert(fn_param);
 
diff --git a/src/ast.h b/src/ast.h
index 44caf68..b220708 100644
--- a/src/ast.h
+++ b/src/ast.h
@@ -28,8 +28,7 @@
 
 typedef union ast_node ast_node_t;
 
-typedef enum
-{
+typedef enum {
     AST_NODE_TRANSLATION_UNIT,
     AST_NODE_BLOCK,
     AST_NODE_FN_DEF,
@@ -46,32 +45,27 @@ typedef enum
     AST_NODE_UNKNOWN
 } ast_node_kind_t;
 
-typedef struct ast_node_meta
-{
+typedef struct ast_node_meta {
     ast_node_kind_t kind;
     token_loc_t loc;
 } ast_node_meta_t;
 
-typedef struct ast_block
-{
+typedef struct ast_block {
     ast_node_meta_t meta;
     list_t *nodes;
 } ast_block_t;
 
-typedef struct ast_translation_unit
-{
+typedef struct ast_translation_unit {
     ast_node_meta_t meta;
     list_t *decls;
 } ast_translation_unit_t;
 
-typedef struct ast_fn_param
-{
+typedef struct ast_fn_param {
     string_view_t id;
     type_t *type;
 } ast_fn_param_t;
 
-typedef struct ast_fn_definition
-{
+typedef struct ast_fn_definition {
     ast_node_meta_t meta;
     string_view_t id;
     list_t *params;
@@ -80,16 +74,14 @@ typedef struct ast_fn_definition
     scope_t *scope;
 } ast_fn_definition_t;
 
-typedef struct ast_fn_call
-{
+typedef struct ast_fn_call {
     ast_node_meta_t meta;
     string_view_t id;
     list_t *args;
     scope_t *scope;
 } ast_fn_call_t;
 
-typedef struct ast_var_definition
-{
+typedef struct ast_var_definition {
     ast_node_meta_t meta;
     string_view_t id;
     type_t *type;
@@ -97,30 +89,23 @@ typedef struct ast_var_definition
     scope_t *scope;
 } ast_var_definition_t;
 
-typedef enum
-{
-    AST_LITERAL_U32
-} ast_literal_kind_t;
+typedef enum { AST_LITERAL_U32 } ast_literal_kind_t;
 
-typedef struct ast_literal
-{
+typedef struct ast_literal {
     ast_node_meta_t meta;
     ast_literal_kind_t kind;
-    union
-    {
+    union {
         uint32_t as_u32;
     };
 } ast_literal_t;
 
-typedef struct ast_ref
-{
+typedef struct ast_ref {
     ast_node_meta_t meta;
     string_view_t id;
     scope_t *scope;
 } ast_ref_t;
 
-typedef enum ast_binary_op_kind
-{
+typedef enum ast_binary_op_kind {
     AST_BINOP_ADDITION,
     AST_BINOP_SUBTRACTION,
     AST_BINOP_MULTIPLICATION,
@@ -141,16 +126,14 @@ typedef enum ast_binary_op_kind
     AST_BINOP_LOGICAL_OR,
 } ast_binary_op_kind_t;
 
-typedef struct ast_binary_op
-{
+typedef struct ast_binary_op {
     ast_node_meta_t meta;
     ast_binary_op_kind_t kind;
     ast_node_t *lhs;
     ast_node_t *rhs;
 } ast_binary_op_t;
 
-typedef enum ast_unary_op_kind
-{
+typedef enum ast_unary_op_kind {
     AST_UNARY_BITWISE_NOT,
     AST_UNARY_LOGICAL_NOT,
     AST_UNARY_NEGATIVE,
@@ -159,46 +142,39 @@ typedef enum ast_unary_op_kind
     AST_UNARY_ADDRESSOF,
 } ast_unary_op_kind_t;
 
-typedef struct ast_unary_op
-{
+typedef struct ast_unary_op {
     ast_node_meta_t meta;
     ast_unary_op_kind_t kind;
     ast_node_t *expr;
 } ast_unary_op_t;
 
-typedef struct ast_var_assign_stmt
-{
+typedef struct ast_var_assign_stmt {
     ast_node_meta_t meta;
     ast_node_t *ref;
     ast_node_t *expr;
 } ast_var_assign_stmt_t;
 
-typedef struct ast_return_stmt
-{
+typedef struct ast_return_stmt {
     ast_node_meta_t meta;
     ast_node_t *expr;
 } ast_return_stmt_t;
 
-typedef struct ast_if_stmt
-{
+typedef struct ast_if_stmt {
     ast_node_meta_t meta;
     ast_node_t *cond;
     ast_node_t *then;
     ast_node_t *_else;
 } ast_if_stmt_t;
 
-typedef struct ast_while_stmt
-{
+typedef struct ast_while_stmt {
     ast_node_meta_t meta;
     ast_node_t *cond;
     ast_node_t *then;
 } ast_while_stmt_t;
 
-typedef union ast_node
-{
+typedef union ast_node {
     // inlined ast_node_meta_t struct.
-    struct
-    {
+    struct {
         ast_node_kind_t kind;
         token_loc_t loc;
     };
diff --git a/src/checker.c b/src/checker.c
index 62d612f..1613c04 100644
--- a/src/checker.c
+++ b/src/checker.c
@@ -24,8 +24,7 @@ static void
 populate_scope(checker_t *checker, scope_t *scope, ast_node_t *ast);
 
 checker_t *
-checker_new(arena_t *arena)
-{
+checker_new(arena_t *arena) {
     assert(arena);
 
     checker_t *checker = (checker_t *)arena_alloc(arena, sizeof(checker_t));
@@ -38,8 +37,7 @@ checker_new(arena_t *arena)
 }
 
 static type_t
-type_from_id(string_view_t id)
-{
+type_from_id(string_view_t id) {
     type_t type = { 0 };
     type.id = id;
     if (string_view_eq_to_cstr(id, "u8")) {
@@ -75,8 +73,7 @@ type_from_id(string_view_t id)
  * transform unknown types into actual types
  */
 static void
-type_resolve(type_t *type)
-{
+type_resolve(type_t *type) {
     switch (type->kind) {
         case TYPE_UNKNOWN:
             *type = type_from_id(type->as_unknown.id);
@@ -89,8 +86,7 @@ type_resolve(type_t *type)
 }
 
 void
-checker_check(checker_t *checker, ast_node_t *ast)
-{
+checker_check(checker_t *checker, ast_node_t *ast) {
     assert(checker);
     assert(ast);
 
@@ -101,8 +97,7 @@ checker_check(checker_t *checker, ast_node_t *ast)
 }
 
 static void
-populate_scope(checker_t *checker, scope_t *scope, ast_node_t *ast)
-{
+populate_scope(checker_t *checker, scope_t *scope, ast_node_t *ast) {
     switch (ast->kind) {
         case AST_NODE_TRANSLATION_UNIT: {
             list_item_t *item = list_head(ast->as_translation_unit.decls);
diff --git a/src/checker.h b/src/checker.h
index 681f405..ee517d9 100644
--- a/src/checker.h
+++ b/src/checker.h
@@ -20,8 +20,7 @@
 #include "arena.h"
 #include "ast.h"
 
-typedef struct checker
-{
+typedef struct checker {
     arena_t *arena;
 } checker_t;
 
diff --git a/src/cli.c b/src/cli.c
index 2faf6ce..d57945a 100644
--- a/src/cli.c
+++ b/src/cli.c
@@ -33,8 +33,7 @@ static void
 cli_opts_parse_sysroot(cli_opts_t *opts, cli_args_t *args);
 
 cli_opts_t
-cli_parse_args(int argc, char **argv)
-{
+cli_parse_args(int argc, char **argv) {
     cli_args_t args = { .argc = argc, .argv = argv };
     cli_opts_t opts = { 0 };
 
@@ -72,8 +71,7 @@ cli_parse_args(int argc, char **argv)
 }
 
 static char *
-cli_args_shift(cli_args_t *args)
-{
+cli_args_shift(cli_args_t *args) {
     if (args->argc == 0)
         return NULL;
     --(args->argc);
@@ -81,8 +79,7 @@ cli_args_shift(cli_args_t *args)
 }
 
 static void
-cli_opts_parse_output(cli_opts_t *opts, cli_args_t *args)
-{
+cli_opts_parse_output(cli_opts_t *opts, cli_args_t *args) {
     assert(opts && "opts is required");
     assert(args && "args is required");
 
@@ -99,8 +96,7 @@ cli_opts_parse_output(cli_opts_t *opts, cli_args_t *args)
 }
 
 static void
-cli_opts_parse_arch(cli_opts_t *opts, cli_args_t *args)
-{
+cli_opts_parse_arch(cli_opts_t *opts, cli_args_t *args) {
     assert(opts && "opts is required");
     assert(args && "args is required");
 
@@ -121,8 +117,7 @@ cli_opts_parse_arch(cli_opts_t *opts, cli_args_t *args)
 }
 
 static void
-cli_opts_parse_sysroot(cli_opts_t *opts, cli_args_t *args)
-{
+cli_opts_parse_sysroot(cli_opts_t *opts, cli_args_t *args) {
     assert(opts && "opts is required");
     assert(args && "args is required");
 
@@ -139,8 +134,7 @@ cli_opts_parse_sysroot(cli_opts_t *opts, cli_args_t *args)
 }
 
 void
-cli_print_usage(FILE *stream, char *compiler_path)
-{
+cli_print_usage(FILE *stream, char *compiler_path) {
     fprintf(
         stream,
         "Usage: %s [options] file...\n"
diff --git a/src/cli.h b/src/cli.h
index 1a93443..0a294a4 100644
--- a/src/cli.h
+++ b/src/cli.h
@@ -20,14 +20,12 @@
 #include <stdint.h>
 #include <stdio.h>
 
-typedef struct cli_args
-{
+typedef struct cli_args {
     int argc;
     char **argv;
 } cli_args_t;
 
-typedef struct cli_opts
-{
+typedef struct cli_opts {
     uint32_t options;
     char *arch;
     char *sysroot;
@@ -36,8 +34,7 @@ typedef struct cli_opts
     string_view_t output_bin;
 } cli_opts_t;
 
-typedef enum
-{
+typedef enum {
     CLI_OPT_DUMP_TOKENS = 1 << 0,
     CLI_OPT_OUTPUT = 1 << 1,
     CLI_OPT_SAVE_TEMPS = 1 << 2,
diff --git a/src/codegen_linux_aarch64.c b/src/codegen_linux_aarch64.c
index d8187ab..e37bd36 100644
--- a/src/codegen_linux_aarch64.c
+++ b/src/codegen_linux_aarch64.c
@@ -42,8 +42,7 @@ static void
 codegen_linux_aarch64_emit_function(FILE *out, ast_fn_definition_t *fn);
 
 void
-codegen_linux_aarch64_emit_translation_unit(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_TRANSLATION_UNIT);
@@ -72,8 +71,7 @@ codegen_linux_aarch64_emit_translation_unit(FILE *out, ast_node_t *node)
 }
 
 static void
-codegen_linux_aarch64_emit_start_entrypoint(FILE *out)
-{
+codegen_linux_aarch64_emit_start_entrypoint(FILE *out) {
     fprintf(out, ".text\n");
     fprintf(out, ".globl _start\n\n");
 
@@ -84,8 +82,7 @@ codegen_linux_aarch64_emit_start_entrypoint(FILE *out)
 }
 
 static void
-codegen_linux_aarch64_emit_function(FILE *out, ast_fn_definition_t *fn)
-{
+codegen_linux_aarch64_emit_function(FILE *out, ast_fn_definition_t *fn) {
     ast_node_t *block_node = fn->block;
     assert(block_node->kind == AST_NODE_BLOCK);
     ast_block_t block = block_node->as_block;
diff --git a/src/codegen_linux_x86_64.c b/src/codegen_linux_x86_64.c
index 9a8d76e..c0b7326 100644
--- a/src/codegen_linux_x86_64.c
+++ b/src/codegen_linux_x86_64.c
@@ -33,8 +33,7 @@
 
 #define bytes_max(a, b) ((a) > (b) ? (a) : (b))
 
-typedef enum x86_64_register_type
-{
+typedef enum x86_64_register_type {
     REG_ACCUMULATOR,
     REG_BASE,
     REG_COUNTER,
@@ -82,8 +81,7 @@ static char *
 get_reg_for(x86_64_register_type_t type, size_t bytes);
 
 void
-codegen_linux_x86_64_init(codegen_x86_64_t *codegen, arena_t *arena, FILE *out)
-{
+codegen_linux_x86_64_init(codegen_x86_64_t *codegen, arena_t *arena, FILE *out) {
     assert(codegen);
     assert(arena);
     assert(codegen);
@@ -94,8 +92,7 @@ codegen_linux_x86_64_init(codegen_x86_64_t *codegen, arena_t *arena, FILE *out)
 }
 
 void
-codegen_linux_x86_64_emit_translation_unit(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);
 
@@ -125,8 +122,7 @@ codegen_linux_x86_64_emit_translation_unit(codegen_x86_64_t *codegen, ast_node_t
 }
 
 static void
-codegen_linux_x86_64_emit_start_entrypoint(codegen_x86_64_t *codegen)
-{
+codegen_linux_x86_64_emit_start_entrypoint(codegen_x86_64_t *codegen) {
     fprintf(codegen->out, ".text\n");
     fprintf(codegen->out, ".globl _start\n\n");
 
@@ -138,16 +134,14 @@ codegen_linux_x86_64_emit_start_entrypoint(codegen_x86_64_t *codegen)
 }
 
 static size_t
-codegen_linux_x86_64_get_next_label(codegen_x86_64_t *codegen)
-{
+codegen_linux_x86_64_get_next_label(codegen_x86_64_t *codegen) {
     return ++codegen->label_index;
 }
 
 typedef size_t size_in_bytes_t;
 
 static size_in_bytes_t
-codegen_linux_x86_64_emit_expression(codegen_x86_64_t *codegen, ast_node_t *expr_node)
-{
+codegen_linux_x86_64_emit_expression(codegen_x86_64_t *codegen, ast_node_t *expr_node) {
     switch (expr_node->kind) {
         case AST_NODE_LITERAL: {
             ast_literal_t literal_u32 = expr_node->as_literal;
@@ -577,8 +571,7 @@ codegen_linux_x86_64_emit_expression(codegen_x86_64_t *codegen, ast_node_t *expr
     }
 }
 static void
-codegen_linux_x86_64_emit_block(codegen_x86_64_t *codegen, ast_block_t *block)
-{
+codegen_linux_x86_64_emit_block(codegen_x86_64_t *codegen, ast_block_t *block) {
     size_t block_offset = codegen->base_offset;
     size_t nodes_len = list_size(block->nodes);
 
@@ -686,8 +679,7 @@ codegen_linux_x86_64_emit_block(codegen_x86_64_t *codegen, ast_block_t *block)
 }
 
 static void
-codegen_linux_x86_64_emit_if(codegen_x86_64_t *codegen, ast_if_stmt_t if_stmt)
-{
+codegen_linux_x86_64_emit_if(codegen_x86_64_t *codegen, ast_if_stmt_t if_stmt) {
     ast_node_t *cond = if_stmt.cond;
     ast_node_t *then = if_stmt.then;
     ast_node_t *_else = if_stmt._else;
@@ -721,8 +713,7 @@ codegen_linux_x86_64_emit_if(codegen_x86_64_t *codegen, ast_if_stmt_t if_stmt)
 }
 
 static size_t
-type_to_bytes(type_t *type)
-{
+type_to_bytes(type_t *type) {
     switch (type->kind) {
         case TYPE_PRIMITIVE: {
             return type->as_primitive.size;
@@ -742,8 +733,7 @@ type_to_bytes(type_t *type)
 }
 
 static size_t
-calculate_fn_local_size(scope_t *scope)
-{
+calculate_fn_local_size(scope_t *scope) {
     assert(scope);
 
     // The local_size starts with 8 bytes since the first 8 bytes from the
@@ -777,8 +767,7 @@ calculate_fn_local_size(scope_t *scope)
 }
 
 static void
-codegen_linux_x86_64_emit_function(codegen_x86_64_t *codegen, ast_fn_definition_t *fn_def)
-{
+codegen_linux_x86_64_emit_function(codegen_x86_64_t *codegen, ast_fn_definition_t *fn_def) {
     codegen->base_offset = X86_CALL_EIP_STACK_OFFSET;
 
     ast_node_t *block_node = fn_def->block;
@@ -826,8 +815,7 @@ codegen_linux_x86_64_emit_function(codegen_x86_64_t *codegen, ast_fn_definition_
 }
 
 static void
-codegen_linux_x86_64_put_stack_offset(codegen_x86_64_t *codegen, symbol_t *symbol, size_t offset)
-{
+codegen_linux_x86_64_put_stack_offset(codegen_x86_64_t *codegen, symbol_t *symbol, size_t offset) {
     size_t *stack_offset = arena_alloc(codegen->arena, sizeof(size_t));
     *stack_offset = offset;
 
@@ -838,8 +826,7 @@ codegen_linux_x86_64_put_stack_offset(codegen_x86_64_t *codegen, symbol_t *symbo
 }
 
 static size_t
-codegen_linux_x86_64_get_stack_offset(codegen_x86_64_t *codegen, symbol_t *symbol)
-{
+codegen_linux_x86_64_get_stack_offset(codegen_x86_64_t *codegen, symbol_t *symbol) {
     char symbol_ptr[PTR_HEX_CSTR_SIZE];
     sprintf(symbol_ptr, "%lx", (uintptr_t)symbol);
 
@@ -847,8 +834,7 @@ codegen_linux_x86_64_get_stack_offset(codegen_x86_64_t *codegen, symbol_t *symbo
 }
 
 static char *
-get_reg_for(x86_64_register_type_t type, size_t bytes)
-{
+get_reg_for(x86_64_register_type_t type, size_t bytes) {
     switch (type) {
         case REG_ACCUMULATOR: {
             if (bytes <= 1) {
diff --git a/src/codegen_linux_x86_64.h b/src/codegen_linux_x86_64.h
index a4137de..3c5a10e 100644
--- a/src/codegen_linux_x86_64.h
+++ b/src/codegen_linux_x86_64.h
@@ -22,8 +22,7 @@
 #include "map.h"
 #include <stdio.h>
 
-typedef struct codegen_x86_64
-{
+typedef struct codegen_x86_64 {
     arena_t *arena;
     size_t base_offset;
     size_t label_index;
diff --git a/src/lexer.c b/src/lexer.c
index 9e012bd..352f979 100644
--- a/src/lexer.c
+++ b/src/lexer.c
@@ -22,8 +22,7 @@
 #include <stdio.h>
 
 void
-lexer_init(lexer_t *lexer, source_code_t src)
-{
+lexer_init(lexer_t *lexer, source_code_t src) {
     assert(lexer);
     lexer->src = src;
     lexer->cur.offset = 0;
@@ -59,8 +58,7 @@ static token_kind_t
 lexer_str_to_token_kind(string_view_t text);
 
 void
-lexer_next_token(lexer_t *lexer, token_t *token)
-{
+lexer_next_token(lexer_t *lexer, token_t *token) {
     if (lexer_is_eof(lexer)) {
         lexer_init_eof_token(lexer, token);
         return;
@@ -329,15 +327,13 @@ static char *token_kind_str_table[] = {
 };
 
 char *
-token_kind_to_cstr(token_kind_t kind)
-{
+token_kind_to_cstr(token_kind_t kind) {
     assert(kind < sizeof(token_kind_str_table));
     return token_kind_str_table[kind];
 }
 
 bool
-token_kind_is_binary_op(token_kind_t kind)
-{
+token_kind_is_binary_op(token_kind_t kind) {
     switch (kind) {
         case TOKEN_PLUS:
         case TOKEN_DASH:
@@ -364,14 +360,12 @@ token_kind_is_binary_op(token_kind_t kind)
 }
 
 static char
-lexer_current_char(lexer_t *lexer)
-{
+lexer_current_char(lexer_t *lexer) {
     return lexer->src.code.chars[lexer->cur.offset];
 }
 
 static void
-lexer_skip_char(lexer_t *lexer)
-{
+lexer_skip_char(lexer_t *lexer) {
     assert(lexer->cur.offset < lexer->src.code.size);
     if (lexer_current_char(lexer) == '\n') {
         lexer->cur.row++;
@@ -382,47 +376,40 @@ lexer_skip_char(lexer_t *lexer)
 }
 
 static bool
-lexer_is_eof(lexer_t *lexer)
-{
+lexer_is_eof(lexer_t *lexer) {
     return lexer->cur.offset >= lexer->src.code.size;
 }
 
 static bool
-lexer_is_not_eof(lexer_t *lexer)
-{
+lexer_is_not_eof(lexer_t *lexer) {
     return !lexer_is_eof(lexer);
 }
 
 static bool
-_isspace(char c)
-{
+_isspace(char c) {
     return c != '\n' && isspace(c);
 }
 
 static void
-lexer_init_char_value_token(lexer_t *lexer, token_t *token, token_kind_t kind)
-{
+lexer_init_char_value_token(lexer_t *lexer, token_t *token, token_kind_t kind) {
     string_view_t str = { .chars = lexer->src.code.chars + lexer->cur.offset, .size = 1 };
     *token = (token_t){ .kind = kind, .value = str, .loc = (token_loc_t){ .src = lexer->src, .cur = lexer->cur } };
 }
 
 static void
-lexer_init_str_value_token(lexer_t *lexer, token_t *token, token_kind_t kind, lexer_cursor_t cur)
-{
+lexer_init_str_value_token(lexer_t *lexer, token_t *token, token_kind_t kind, lexer_cursor_t cur) {
     string_view_t str = { .chars = lexer->src.code.chars + cur.offset, .size = lexer->cur.offset - cur.offset };
     *token = (token_t){ .kind = kind, .value = str, .loc = (token_loc_t){ .src = lexer->src, .cur = cur } };
 }
 
 static void
-lexer_init_eof_token(lexer_t *lexer, token_t *token)
-{
+lexer_init_eof_token(lexer_t *lexer, token_t *token) {
     string_view_t str = { 0 };
     *token = (token_t){ .kind = TOKEN_EOF, .value = str, .loc = (token_loc_t){ .src = lexer->src, .cur = lexer->cur } };
 }
 
 static token_kind_t
-lexer_str_to_token_kind(string_view_t text)
-{
+lexer_str_to_token_kind(string_view_t text) {
     if (string_view_eq_to_cstr(text, "if")) {
         return TOKEN_IF;
     }
@@ -451,14 +438,12 @@ lexer_str_to_token_kind(string_view_t text)
 }
 
 void
-lexer_peek_next(lexer_t *lexer, token_t *token)
-{
+lexer_peek_next(lexer_t *lexer, token_t *token) {
     lexer_lookahead(lexer, token, 1);
 }
 
 void
-lexer_lookahead(lexer_t *lexer, token_t *token, size_t n)
-{
+lexer_lookahead(lexer_t *lexer, token_t *token, size_t n) {
     lexer_cursor_t previous_cur = lexer->cur;
 
     for (size_t i = 0; i < n; ++i) {
@@ -469,8 +454,7 @@ lexer_lookahead(lexer_t *lexer, token_t *token, size_t n)
 }
 
 string_view_t
-token_loc_to_line(token_loc_t loc)
-{
+token_loc_to_line(token_loc_t loc) {
     size_t offset = loc.cur.bol;
     string_view_t line = { .chars = loc.src.code.chars + offset, .size = 0 };
 
@@ -482,13 +466,11 @@ token_loc_to_line(token_loc_t loc)
 }
 
 size_t
-token_loc_to_lineno(token_loc_t loc)
-{
+token_loc_to_lineno(token_loc_t loc) {
     return loc.cur.row + 1;
 }
 
 size_t
-token_loc_to_colno(token_loc_t loc)
-{
+token_loc_to_colno(token_loc_t loc) {
     return loc.cur.offset - loc.cur.bol + 1;
 }
diff --git a/src/lexer.h b/src/lexer.h
index 774f619..beb5486 100644
--- a/src/lexer.h
+++ b/src/lexer.h
@@ -21,27 +21,23 @@
 #include <stdint.h>
 #include <stdio.h>
 
-typedef struct source_code
-{
+typedef struct source_code {
     char *filepath;
     string_view_t code;
 } source_code_t;
 
-typedef struct lexer_cursor
-{
+typedef struct lexer_cursor {
     size_t offset;
     size_t row;
     size_t bol;
 } lexer_cursor_t;
 
-typedef struct lexer
-{
+typedef struct lexer {
     source_code_t src;
     lexer_cursor_t cur;
 } lexer_t;
 
-typedef enum token_kind
-{
+typedef enum token_kind {
     TOKEN_UNKNOWN,
     TOKEN_ID,
     TOKEN_NUMBER,
@@ -92,14 +88,12 @@ typedef enum token_kind
     TOKEN_EOF
 } token_kind_t;
 
-typedef struct token_loc
-{
+typedef struct token_loc {
     source_code_t src;
     lexer_cursor_t cur;
 } token_loc_t;
 
-typedef struct token
-{
+typedef struct token {
     token_kind_t kind;
     string_view_t value;
     token_loc_t loc;
diff --git a/src/list.c b/src/list.c
index a3dd3fe..fcdaa4f 100644
--- a/src/list.c
+++ b/src/list.c
@@ -18,8 +18,7 @@
 #include <assert.h>
 
 void
-list_init(list_t *list, arena_t *arena)
-{
+list_init(list_t *list, arena_t *arena) {
     assert(list != NULL);
     list->size = 0;
     list->arena = arena;
@@ -27,8 +26,7 @@ list_init(list_t *list, arena_t *arena)
 }
 
 void
-list_append(list_t *list, void *value)
-{
+list_append(list_t *list, void *value) {
     assert(list != NULL);
     list_item_t *item = arena_alloc(list->arena, sizeof(list_item_t));
     item->value = value;
@@ -46,8 +44,7 @@ list_append(list_t *list, void *value)
 }
 
 list_item_t *
-list_get(list_t *list, size_t index)
-{
+list_get(list_t *list, size_t index) {
     assert(list != NULL);
     assert(index < list->size);
 
@@ -63,22 +60,19 @@ list_get(list_t *list, size_t index)
 }
 
 list_item_t *
-list_head(list_t *list)
-{
+list_head(list_t *list) {
     assert(list != NULL);
     return list->head;
 }
 
 list_item_t *
-list_next(list_item_t *item)
-{
+list_next(list_item_t *item) {
     assert(item != NULL);
     return item->next;
 }
 
 size_t
-list_size(list_t *list)
-{
+list_size(list_t *list) {
     assert(list != NULL);
     return list->size;
 }
diff --git a/src/list.h b/src/list.h
index 901d27e..3b709d2 100644
--- a/src/list.h
+++ b/src/list.h
@@ -18,14 +18,12 @@
 #define LIST_H
 #include "arena.h"
 
-typedef struct list_item
-{
+typedef struct list_item {
     void *value;
     struct list_item *next;
 } list_item_t;
 
-typedef struct list
-{
+typedef struct list {
     size_t size;
     arena_t *arena;
     list_item_t *head;
diff --git a/src/main.c b/src/main.c
index d7738bd..bb0e451 100644
--- a/src/main.c
+++ b/src/main.c
@@ -50,8 +50,7 @@ source_code_t
 read_entire_file(char *filepath, arena_t *arena);
 
 int
-main(int argc, char **argv)
-{
+main(int argc, char **argv) {
     cli_opts_t opts = cli_parse_args(argc, argv);
 
     if (opts.options & CLI_OPT_DUMP_TOKENS) {
@@ -73,8 +72,7 @@ main(int argc, char **argv)
 }
 
 void
-handle_dump_tokens(cli_opts_t *opts)
-{
+handle_dump_tokens(cli_opts_t *opts) {
     if (opts->filepath == NULL) {
         cli_print_usage(stderr, opts->compiler_path);
         exit(EXIT_FAILURE);
@@ -98,8 +96,7 @@ handle_dump_tokens(cli_opts_t *opts)
 }
 
 void
-handle_dump_ast(cli_opts_t *opts)
-{
+handle_dump_ast(cli_opts_t *opts) {
     if (opts->filepath == NULL) {
         cli_print_usage(stderr, opts->compiler_path);
         exit(EXIT_FAILURE);
@@ -120,8 +117,7 @@ handle_dump_ast(cli_opts_t *opts)
 }
 
 void
-handle_codegen_linux(cli_opts_t *opts)
-{
+handle_codegen_linux(cli_opts_t *opts) {
     if (opts->filepath == NULL) {
         cli_print_usage(stderr, opts->compiler_path);
         exit(EXIT_FAILURE);
@@ -207,8 +203,7 @@ handle_codegen_linux(cli_opts_t *opts)
 }
 
 source_code_t
-read_entire_file(char *filepath, arena_t *arena)
-{
+read_entire_file(char *filepath, arena_t *arena) {
     FILE *stream = fopen(filepath, "rb");
 
     if (stream == NULL) {
@@ -244,8 +239,7 @@ read_entire_file(char *filepath, arena_t *arena)
 }
 
 static void
-print_token(token_t *token)
-{
+print_token(token_t *token) {
     printf(
         "%s:%lu:%lu: <%s>\n",
         token->loc.src.filepath,
diff --git a/src/map.c b/src/map.c
index a6bc3a3..9109eaa 100644
--- a/src/map.c
+++ b/src/map.c
@@ -38,8 +38,7 @@ static uint32_t
 map_get_index(map_t *map, uint32_t hash);
 
 map_t *
-map_new(arena_t *arena)
-{
+map_new(arena_t *arena) {
     map_t *map = (map_t *)arena_alloc(arena, sizeof(map_t));
     if (map == NULL) {
         fprintf(stderr, "[FATAL] Out of memory: map_new: %s\n", strerror(errno));
@@ -51,8 +50,7 @@ map_new(arena_t *arena)
 }
 
 static void
-map_init(map_t *map)
-{
+map_init(map_t *map) {
     assert(map);
     map->entries = (map_entry_t *)arena_alloc(map->arena, MAP_INITIAL_CAPACITY * sizeof(map_entry_t));
     assert(map->entries != NULL);
@@ -65,8 +63,7 @@ map_init(map_t *map)
 }
 
 static uint32_t
-u32_fnv1a_hash(const char *s)
-{
+u32_fnv1a_hash(const char *s) {
     uint32_t hash = U32_FNV1A_OFFSET_BASIS;
     size_t len = strlen(s);
     for (size_t i = 0; i < len; ++i) {
@@ -77,8 +74,7 @@ u32_fnv1a_hash(const char *s)
 }
 
 bool
-map_put(map_t *map, char *key, void *value)
-{
+map_put(map_t *map, char *key, void *value) {
     assert(map && key);
     map->size++;
 
@@ -108,8 +104,7 @@ map_put(map_t *map, char *key, void *value)
 }
 
 void *
-map_get(map_t *map, char *key)
-{
+map_get(map_t *map, char *key) {
     uint32_t hash = u32_fnv1a_hash(key);
     map_entry_t *entry = map->entries + map_get_index(map, hash);
     while (entry != NULL) {
@@ -122,15 +117,13 @@ map_get(map_t *map, char *key)
 }
 
 static uint32_t
-map_get_index(map_t *map, uint32_t hash)
-{
+map_get_index(map_t *map, uint32_t hash) {
     uint32_t capacity_mask = map->capacity - 1;
     return hash & capacity_mask;
 }
 
 void
-map_get_kvs(map_t *map, map_kv_t **kvs)
-{
+map_get_kvs(map_t *map, map_kv_t **kvs) {
     size_t index = 0;
 
     for (size_t j = 0; j < map->capacity; ++j) {
@@ -144,8 +137,7 @@ map_get_kvs(map_t *map, map_kv_t **kvs)
 }
 
 static char *
-_strdup(const char *s, arena_t *arena)
-{
+_strdup(const char *s, arena_t *arena) {
     size_t slen = strlen(s);
     char *result = arena_alloc(arena, slen + 1);
     if (result == NULL) {
diff --git a/src/map.h b/src/map.h
index 6f8681c..fd26ea2 100644
--- a/src/map.h
+++ b/src/map.h
@@ -32,22 +32,19 @@ typedef struct map map_t;
 typedef struct map_bucket map_bucket_t;
 typedef struct map_entry map_entry_t;
 
-typedef struct map
-{
+typedef struct map {
     arena_t *arena;
     map_entry_t *entries;
     size_t capacity;
     size_t size;
 } map_t;
 
-typedef struct map_kv
-{
+typedef struct map_kv {
     char *key;
     void *value;
 } map_kv_t;
 
-typedef struct map_entry
-{
+typedef struct map_entry {
     char *key;
     void *value;
     uint32_t hash;
diff --git a/src/parser.c b/src/parser.c
index 9d3d6e0..385d1a5 100644
--- a/src/parser.c
+++ b/src/parser.c
@@ -77,8 +77,7 @@ static void
 peek_next_non_lf_token(lexer_t *lexer, token_t *token);
 
 void
-parser_init(parser_t *parser, lexer_t *lexer, arena_t *arena)
-{
+parser_init(parser_t *parser, lexer_t *lexer, arena_t *arena) {
     assert(parser && "parser is required");
     assert(lexer && "lexer is required");
     parser->lexer = lexer;
@@ -86,8 +85,7 @@ parser_init(parser_t *parser, lexer_t *lexer, arena_t *arena)
 }
 
 ast_node_t *
-parser_parse_translation_unit(parser_t *parser)
-{
+parser_parse_translation_unit(parser_t *parser) {
     token_t token;
     ast_node_t *translation_unit_node = ast_new_translation_unit(parser->arena);
 
@@ -111,8 +109,7 @@ parser_parse_translation_unit(parser_t *parser)
 }
 
 static ast_binary_op_kind_t
-token_kind_to_binary_op_kind(token_kind_t kind)
-{
+token_kind_to_binary_op_kind(token_kind_t kind) {
     switch (kind) {
         case TOKEN_PLUS:
             return AST_BINOP_ADDITION;
@@ -157,8 +154,7 @@ token_kind_to_binary_op_kind(token_kind_t kind)
     }
 }
 
-typedef enum
-{
+typedef enum {
     BINOP_MIN_PREC,
     BINOP_LOGICAL_OR_PREC,
     BINOP_LOGICAL_AND_PREC,
@@ -173,8 +169,7 @@ typedef enum
 } binary_op_precedence_t;
 
 static binary_op_precedence_t
-get_binary_op_precedence(token_kind_t kind)
-{
+get_binary_op_precedence(token_kind_t kind) {
     switch (kind) {
         case TOKEN_PLUS:
         case TOKEN_DASH:
@@ -210,8 +205,7 @@ get_binary_op_precedence(token_kind_t kind)
 }
 
 static ast_unary_op_kind_t
-token_kind_to_unary_op_kind(token_kind_t token_kind)
-{
+token_kind_to_unary_op_kind(token_kind_t token_kind) {
     switch (token_kind) {
         case TOKEN_AND:
             return AST_UNARY_ADDRESSOF;
@@ -231,8 +225,7 @@ token_kind_to_unary_op_kind(token_kind_t token_kind)
 }
 
 static ast_node_t *
-parser_parse_expr_1(parser_t *parser, ast_node_t *lhs, size_t prev_precedence)
-{
+parser_parse_expr_1(parser_t *parser, ast_node_t *lhs, size_t prev_precedence) {
     token_t lookahead_token;
     lexer_peek_next(parser->lexer, &lookahead_token);
 
@@ -264,8 +257,7 @@ parser_parse_expr_1(parser_t *parser, ast_node_t *lhs, size_t prev_precedence)
 }
 
 static ast_node_t *
-parser_parse_expr(parser_t *parser)
-{
+parser_parse_expr(parser_t *parser) {
     ast_node_t *lhs = parser_parse_factor(parser);
     if (lhs == NULL) {
         return NULL;
@@ -275,8 +267,7 @@ parser_parse_expr(parser_t *parser)
 }
 
 static ast_node_t *
-parser_parse_factor(parser_t *parser)
-{
+parser_parse_factor(parser_t *parser) {
     token_t token;
     lexer_next_token(parser->lexer, &token);
 
@@ -331,8 +322,7 @@ parser_parse_factor(parser_t *parser)
 }
 
 static list_t *
-parser_parse_fn_args(parser_t *parser)
-{
+parser_parse_fn_args(parser_t *parser) {
     if (!skip_expected_token(parser, TOKEN_OPAREN)) {
         return NULL;
     }
@@ -373,8 +363,7 @@ parser_parse_fn_args(parser_t *parser)
 }
 
 static list_t *
-parser_parse_fn_params(parser_t *parser)
-{
+parser_parse_fn_params(parser_t *parser) {
     if (!skip_expected_token(parser, TOKEN_OPAREN)) {
         return NULL;
     }
@@ -425,8 +414,7 @@ parser_parse_fn_params(parser_t *parser)
 }
 
 ast_node_t *
-parser_parse_fn_definition(parser_t *parser)
-{
+parser_parse_fn_definition(parser_t *parser) {
     if (!skip_expected_token(parser, TOKEN_FN)) {
         return NULL;
     }
@@ -463,8 +451,7 @@ parser_parse_fn_definition(parser_t *parser)
 }
 
 static type_t *
-parser_parse_type(parser_t *parser)
-{
+parser_parse_type(parser_t *parser) {
     skip_line_feeds(parser->lexer);
 
     if (!skip_expected_token(parser, TOKEN_COLON)) {
@@ -500,8 +487,7 @@ parser_parse_type(parser_t *parser)
 }
 
 static ast_node_t *
-parser_parse_block(parser_t *parser)
-{
+parser_parse_block(parser_t *parser) {
     if (!skip_expected_token(parser, TOKEN_OCURLY)) {
         return NULL;
     }
@@ -576,8 +562,7 @@ EndLoop:
 }
 
 static ast_node_t *
-parser_parse_return_stmt(parser_t *parser)
-{
+parser_parse_return_stmt(parser_t *parser) {
     token_t token_ret;
 
     if (!expected_next_token(parser, &token_ret, TOKEN_RETURN)) {
@@ -596,8 +581,7 @@ parser_parse_return_stmt(parser_t *parser)
 }
 
 static ast_node_t *
-parser_parse_if_stmt(parser_t *parser)
-{
+parser_parse_if_stmt(parser_t *parser) {
     token_t token_if;
     if (!expected_next_token(parser, &token_if, TOKEN_IF)) {
         return NULL;
@@ -648,8 +632,7 @@ parser_parse_if_stmt(parser_t *parser)
 }
 
 static ast_node_t *
-parser_parse_while_stmt(parser_t *parser)
-{
+parser_parse_while_stmt(parser_t *parser) {
     token_t token_while;
     if (!expected_next_token(parser, &token_while, TOKEN_WHILE)) {
         return NULL;
@@ -680,8 +663,7 @@ parser_parse_while_stmt(parser_t *parser)
 }
 
 static ast_node_t *
-parser_parse_var_def(parser_t *parser)
-{
+parser_parse_var_def(parser_t *parser) {
     if (!skip_expected_token(parser, TOKEN_VAR)) {
         return NULL;
     }
@@ -712,8 +694,7 @@ parser_parse_var_def(parser_t *parser)
 }
 
 static ast_node_t *
-parser_parse_var_assign_stmt(parser_t *parser)
-{
+parser_parse_var_assign_stmt(parser_t *parser) {
     token_t token_id;
 
     if (!expected_next_token(parser, &token_id, TOKEN_ID)) {
@@ -733,22 +714,19 @@ parser_parse_var_assign_stmt(parser_t *parser)
 }
 
 static bool
-skip_expected_token(parser_t *parser, token_kind_t expected_kind)
-{
+skip_expected_token(parser_t *parser, token_kind_t expected_kind) {
     token_t token;
     return expected_next_token(parser, &token, expected_kind);
 }
 
 static bool
-expected_next_token(parser_t *parser, token_t *token, token_kind_t expected_kind)
-{
+expected_next_token(parser_t *parser, token_t *token, token_kind_t expected_kind) {
     lexer_next_token(parser->lexer, token);
     return expected_token(token, expected_kind);
 }
 
 static bool
-expected_token(token_t *token, token_kind_t expected_kind)
-{
+expected_token(token_t *token, token_kind_t expected_kind) {
     if (token->kind != expected_kind) {
         fprintf(
             stderr,
@@ -769,8 +747,7 @@ expected_token(token_t *token, token_kind_t expected_kind)
 }
 
 static void
-skip_line_feeds(lexer_t *lexer)
-{
+skip_line_feeds(lexer_t *lexer) {
     token_t token;
     lexer_peek_next(lexer, &token);
 
@@ -781,8 +758,7 @@ skip_line_feeds(lexer_t *lexer)
 }
 
 static void
-peek_next_non_lf_token(lexer_t *lexer, token_t *token)
-{
+peek_next_non_lf_token(lexer_t *lexer, token_t *token) {
     lexer_cursor_t cur = lexer->cur;
 
     skip_line_feeds(lexer);
diff --git a/src/parser.h b/src/parser.h
index 7db2b74..7726788 100644
--- a/src/parser.h
+++ b/src/parser.h
@@ -21,8 +21,7 @@
 #include "ast.h"
 #include "lexer.h"
 
-typedef struct parser
-{
+typedef struct parser {
     lexer_t *lexer;
     arena_t *arena;
 } parser_t;
diff --git a/src/pretty_print_ast.c b/src/pretty_print_ast.c
index f5cd571..38199ed 100644
--- a/src/pretty_print_ast.c
+++ b/src/pretty_print_ast.c
@@ -31,23 +31,20 @@
 #define PP_IS_BIT_SET(data, index) ((data) & 1 << index)
 // clang-format on
 
-typedef struct pretty_print_node
-{
+typedef struct pretty_print_node {
     char *name;
     list_t *children;
 } pretty_print_node_t;
 
 static bool
-stdout_supports_color()
-{
+stdout_supports_color() {
     struct stat st;
     fstat(STDOUT_FILENO, &st);
     return S_ISCHR(st.st_mode);
 }
 
 static void
-pretty_print_print_ident(uint64_t *prefix, size_t level, bool lst_children)
-{
+pretty_print_print_ident(uint64_t *prefix, size_t level, bool lst_children) {
     assert(level < 64);
 
     bool support_color = stdout_supports_color();
@@ -79,8 +76,7 @@ pretty_print_print_ident(uint64_t *prefix, size_t level, bool lst_children)
 }
 
 static void
-pretty_print_tree(pretty_print_node_t *node, uint64_t *prefix, size_t level, bool lst_children)
-{
+pretty_print_tree(pretty_print_node_t *node, uint64_t *prefix, size_t level, bool lst_children) {
     pretty_print_print_ident(prefix, level, lst_children);
 
     list_t *list = node->children;
@@ -99,8 +95,7 @@ pretty_print_tree(pretty_print_node_t *node, uint64_t *prefix, size_t level, boo
 }
 
 static pretty_print_node_t *
-pretty_print_node_new(arena_t *arena)
-{
+pretty_print_node_new(arena_t *arena) {
     pretty_print_node_t *node = (pretty_print_node_t *)arena_alloc(arena, sizeof(pretty_print_node_t));
     node->children = (list_t *)arena_alloc(arena, sizeof(list_t));
     list_init(node->children, arena);
@@ -108,8 +103,7 @@ pretty_print_node_new(arena_t *arena)
 }
 
 static pretty_print_node_t *
-pretty_print_new_fn_param(ast_fn_param_t *param, arena_t *arena)
-{
+pretty_print_new_fn_param(ast_fn_param_t *param, arena_t *arena) {
     pretty_print_node_t *node = pretty_print_node_new(arena);
     char name[256];
     sprintf(name, "Param_Definition <name:" SV_FMT "> <type:" SV_FMT ">", SV_ARG(param->id), SV_ARG(param->type->id));
@@ -119,8 +113,7 @@ pretty_print_new_fn_param(ast_fn_param_t *param, arena_t *arena)
 }
 
 static pretty_print_node_t *
-ast_node_to_pretty_print_node(ast_node_t *ast, arena_t *arena)
-{
+ast_node_to_pretty_print_node(ast_node_t *ast, arena_t *arena) {
     switch (ast->kind) {
         case AST_NODE_TRANSLATION_UNIT: {
             pretty_print_node_t *node = pretty_print_node_new(arena);
@@ -413,8 +406,7 @@ ast_node_to_pretty_print_node(ast_node_t *ast, arena_t *arena)
 }
 
 void
-pretty_print_ast(ast_node_t *ast)
-{
+pretty_print_ast(ast_node_t *ast) {
     arena_t arena = arena_new(8 * 1024);
     pretty_print_node_t *root = ast_node_to_pretty_print_node(ast, &arena);
     uint64_t prefix = 0;
diff --git a/src/scope.c b/src/scope.c
index ff9067c..0cc4a74 100644
--- a/src/scope.c
+++ b/src/scope.c
@@ -23,8 +23,7 @@
 #include "scope.h"
 
 scope_t *
-scope_new(arena_t *arena)
-{
+scope_new(arena_t *arena) {
     assert(arena);
     scope_t *scope = (scope_t *)arena_alloc(arena, sizeof(scope_t));
     if (scope == NULL) {
@@ -49,8 +48,7 @@ scope_new(arena_t *arena)
 }
 
 symbol_t *
-symbol_new(arena_t *arena, string_view_t id, type_t *type)
-{
+symbol_new(arena_t *arena, string_view_t id, type_t *type) {
     assert(arena);
     symbol_t *symbol = (symbol_t *)arena_alloc(arena, sizeof(symbol_t));
     if (symbol == NULL) {
@@ -63,8 +61,7 @@ symbol_new(arena_t *arena, string_view_t id, type_t *type)
 }
 
 symbol_t *
-scope_lookup(scope_t *scope, string_view_t id)
-{
+scope_lookup(scope_t *scope, string_view_t id) {
     assert(scope);
     while (scope != NULL) {
         char cstr_id[id.size + 1];
@@ -81,8 +78,7 @@ scope_lookup(scope_t *scope, string_view_t id)
 }
 
 void
-scope_insert(scope_t *scope, symbol_t *symbol)
-{
+scope_insert(scope_t *scope, symbol_t *symbol) {
     assert(scope);
     assert(symbol);
 
@@ -94,8 +90,7 @@ scope_insert(scope_t *scope, symbol_t *symbol)
 }
 
 scope_t *
-scope_push(scope_t *scope)
-{
+scope_push(scope_t *scope) {
     assert(scope);
 
     scope_t *child = scope_new(scope->arena);
@@ -107,8 +102,7 @@ scope_push(scope_t *scope)
 }
 
 scope_t *
-scope_pop(scope_t *scope)
-{
+scope_pop(scope_t *scope) {
     assert(scope);
     assert(scope->parent);
     return scope->parent;
diff --git a/src/scope.h b/src/scope.h
index 08eb681..ed08837 100644
--- a/src/scope.h
+++ b/src/scope.h
@@ -23,14 +23,12 @@
 #include "string_view.h"
 #include "type.h"
 
-typedef struct symbol
-{
+typedef struct symbol {
     string_view_t id;
     type_t *type;
 } symbol_t;
 
-typedef struct scope
-{
+typedef struct scope {
     struct scope *parent;
     list_t *children;
     arena_t *arena;
diff --git a/src/string_view.c b/src/string_view.c
index b4d4103..22cb61e 100644
--- a/src/string_view.c
+++ b/src/string_view.c
@@ -22,14 +22,12 @@
 #include <string.h>
 
 string_view_t
-string_view_from_cstr(char *cstr)
-{
+string_view_from_cstr(char *cstr) {
     return (string_view_t){ .chars = cstr, .size = strlen(cstr) };
 }
 
 bool
-string_view_eq_to_cstr(string_view_t str, char *cstr)
-{
+string_view_eq_to_cstr(string_view_t str, char *cstr) {
     size_t cstr_len = strlen(cstr);
     if (str.size != cstr_len) {
         return false;
@@ -43,8 +41,7 @@ string_view_eq_to_cstr(string_view_t str, char *cstr)
 }
 
 uint32_t
-string_view_to_u32(string_view_t str)
-{
+string_view_to_u32(string_view_t str) {
     char ret[str.size + 1];
     ret[str.size] = 0;
     memcpy(ret, str.chars, str.size);
diff --git a/src/string_view.h b/src/string_view.h
index 0a3654f..fdb6148 100644
--- a/src/string_view.h
+++ b/src/string_view.h
@@ -24,8 +24,7 @@
 #define SV_FMT "%.*s"
 #define SV_ARG(sv) (int)(sv).size, (sv).chars
 
-typedef struct string_view
-{
+typedef struct string_view {
     char *chars;
     size_t size;
 
diff --git a/src/type.c b/src/type.c
index 4a8d6f4..185f0fa 100644
--- a/src/type.c
+++ b/src/type.c
@@ -18,8 +18,7 @@
 #include "assert.h"
 
 type_t *
-type_new_unknown(arena_t *arena, string_view_t id)
-{
+type_new_unknown(arena_t *arena, string_view_t id) {
     type_t *type = arena_alloc(arena, sizeof(type_t));
     assert(type);
 
@@ -29,8 +28,7 @@ type_new_unknown(arena_t *arena, string_view_t id)
 }
 
 type_t *
-type_new_ptr(arena_t *arena, string_view_t id, type_t *ref_type)
-{
+type_new_ptr(arena_t *arena, string_view_t id, type_t *ref_type) {
     type_t *type = arena_alloc(arena, sizeof(type_t));
     assert(type);
 
diff --git a/src/type.h b/src/type.h
index d930a88..edc421b 100644
--- a/src/type.h
+++ b/src/type.h
@@ -21,46 +21,30 @@
 
 typedef union type type_t;
 
-typedef enum
-{
-    TYPE_UNKNOWN,
-    TYPE_PRIMITIVE,
-    TYPE_PTR
-} type_kind_t;
+typedef enum { TYPE_UNKNOWN, TYPE_PRIMITIVE, TYPE_PTR } type_kind_t;
 
-typedef enum
-{
-    TYPE_U8,
-    TYPE_U16,
-    TYPE_U32,
-    TYPE_U64
-} type_primitive_kind_t;
+typedef enum { TYPE_U8, TYPE_U16, TYPE_U32, TYPE_U64 } type_primitive_kind_t;
 
-typedef struct type_primitive
-{
+typedef struct type_primitive {
     type_kind_t _type_kind;
     string_view_t id;
     type_primitive_kind_t kind;
     short size;
 } type_primitive_t;
 
-typedef struct type_unknown
-{
+typedef struct type_unknown {
     type_kind_t _type_kind;
     string_view_t id;
 } type_unknown_t;
 
-typedef struct type_ptr
-{
+typedef struct type_ptr {
     type_kind_t _type_kind;
     string_view_t id;
     type_t *type;
 } type_ptr_t;
 
-typedef union type
-{
-    struct
-    {
+typedef union type {
+    struct {
         type_kind_t kind;
         string_view_t id;
     };
diff --git a/tests/unit/arena_test.c b/tests/unit/arena_test.c
index a471572..81553c9 100644
--- a/tests/unit/arena_test.c
+++ b/tests/unit/arena_test.c
@@ -19,8 +19,7 @@
 #include "munit.h"
 
 static MunitResult
-arena_alloc_test(const MunitParameter params[], void *user_data_or_fixture)
-{
+arena_alloc_test(const MunitParameter params[], void *user_data_or_fixture) {
     arena_t arena = arena_new(ARENA_ALIGNMENT_BYTES * 2);
 
     uint8_t *a = arena_alloc(&arena, sizeof(uint8_t));
@@ -50,8 +49,7 @@ arena_alloc_test(const MunitParameter params[], void *user_data_or_fixture)
 }
 
 static MunitResult
-arena_padding_test(const MunitParameter params[], void *user_data_or_fixture)
-{
+arena_padding_test(const MunitParameter params[], void *user_data_or_fixture) {
     arena_t arena = arena_new(512);
 
     // Allocated bytes is < ARENA_ALIGNMENT_BYTES
@@ -91,8 +89,7 @@ static MunitTest tests[] = { { "/arena_alloc_test", arena_alloc_test, NULL, NULL
 static const MunitSuite suite = { "/arena", tests, NULL, 1, MUNIT_SUITE_OPTION_NONE };
 
 int
-main(int argc, char *argv[])
-{
+main(int argc, char *argv[]) {
     return munit_suite_main(&suite, NULL, argc, argv);
     return EXIT_SUCCESS;
 }
diff --git a/tests/unit/list_test.c b/tests/unit/list_test.c
index 8b759f9..fe19a23 100644
--- a/tests/unit/list_test.c
+++ b/tests/unit/list_test.c
@@ -21,8 +21,7 @@
 #include <stdio.h>
 
 static MunitResult
-list_append_test(const MunitParameter params[], void *user_data_or_fixture)
-{
+list_append_test(const MunitParameter params[], void *user_data_or_fixture) {
     arena_t arena = arena_new(sizeof(list_item_t));
 
     list_t list;
@@ -41,8 +40,7 @@ list_append_test(const MunitParameter params[], void *user_data_or_fixture)
 }
 
 static MunitResult
-list_get_test(const MunitParameter params[], void *user_data_or_fixture)
-{
+list_get_test(const MunitParameter params[], void *user_data_or_fixture) {
     arena_t arena = arena_new(sizeof(list_item_t) * 3);
 
     list_t list;
@@ -66,8 +64,7 @@ list_get_test(const MunitParameter params[], void *user_data_or_fixture)
 }
 
 static MunitResult
-list_next_test(const MunitParameter params[], void *user_data_or_fixture)
-{
+list_next_test(const MunitParameter params[], void *user_data_or_fixture) {
     arena_t arena = arena_new(sizeof(list_item_t) * 3);
 
     list_t list;
@@ -103,8 +100,7 @@ static MunitTest tests[] = { { "/list_append_test", list_append_test, NULL, NULL
 static const MunitSuite suite = { "/list", tests, NULL, 1, MUNIT_SUITE_OPTION_NONE };
 
 int
-main(int argc, char *argv[])
-{
+main(int argc, char *argv[]) {
     return munit_suite_main(&suite, NULL, argc, argv);
     return EXIT_SUCCESS;
 }
diff --git a/tests/unit/map_test.c b/tests/unit/map_test.c
index 9497c7c..15d82ef 100644
--- a/tests/unit/map_test.c
+++ b/tests/unit/map_test.c
@@ -24,8 +24,7 @@
 #define MAP_TEST_ARENA_CAPACITY (1024 * 16)
 
 static MunitResult
-test_create_new(const MunitParameter params[], void *user_data_or_fixture)
-{
+test_create_new(const MunitParameter params[], void *user_data_or_fixture) {
     arena_t arena = arena_new(MAP_TEST_ARENA_CAPACITY);
 
     map_t *map = map_new(&arena);
@@ -38,8 +37,7 @@ test_create_new(const MunitParameter params[], void *user_data_or_fixture)
 }
 
 static MunitResult
-test_map_put_and_get(const MunitParameter params[], void *user_data_or_fixture)
-{
+test_map_put_and_get(const MunitParameter params[], void *user_data_or_fixture) {
     arena_t arena = arena_new(MAP_TEST_ARENA_CAPACITY);
     map_t *map = map_new(&arena);
 
@@ -63,8 +61,7 @@ test_map_put_and_get(const MunitParameter params[], void *user_data_or_fixture)
 }
 
 static MunitResult
-test_map_get_kvs(const MunitParameter params[], void *user_data_or_fixture)
-{
+test_map_get_kvs(const MunitParameter params[], void *user_data_or_fixture) {
     arena_t arena = arena_new(MAP_TEST_ARENA_CAPACITY);
     map_t *map = map_new(&arena);
 
@@ -100,8 +97,7 @@ static MunitTest tests[] = {
 static const MunitSuite suite = { "/map", tests, NULL, 1, MUNIT_SUITE_OPTION_NONE };
 
 int
-main(int argc, char *argv[])
-{
+main(int argc, char *argv[]) {
     return munit_suite_main(&suite, NULL, argc, argv);
     return EXIT_SUCCESS;
 }
diff --git a/tests/unit/string_view_test.c b/tests/unit/string_view_test.c
index 7a6776c..f8ca792 100644
--- a/tests/unit/string_view_test.c
+++ b/tests/unit/string_view_test.c
@@ -22,8 +22,7 @@
 #include <string.h>
 
 static MunitResult
-string_view_eq_to_cstr_test(const MunitParameter params[], void *user_data_or_fixture)
-{
+string_view_eq_to_cstr_test(const MunitParameter params[], void *user_data_or_fixture) {
     char *name = "John Doe";
 
     string_view_t str = { .chars = name, .size = strlen(name) };
@@ -40,8 +39,7 @@ string_view_eq_to_cstr_test(const MunitParameter params[], void *user_data_or_fi
 }
 
 static MunitResult
-string_view_to_u32_test(const MunitParameter params[], void *user_data_or_fixture)
-{
+string_view_to_u32_test(const MunitParameter params[], void *user_data_or_fixture) {
     char *number = "69";
 
     string_view_t str = { .chars = number, .size = strlen(number) };
@@ -64,8 +62,7 @@ static MunitTest tests[] = {
 static const MunitSuite suite = { "/string_view", tests, NULL, 1, MUNIT_SUITE_OPTION_NONE };
 
 int
-main(int argc, char *argv[])
-{
+main(int argc, char *argv[]) {
     return munit_suite_main(&suite, NULL, argc, argv);
     return EXIT_SUCCESS;
 }
-- 
2.46.0


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH olang v1 3/6] codestyle: prevent extra empty lines at EOF
  2024-10-10  1:33 [PATCH olang 0/6] Suggestions in code style Carlos Maniero
  2024-10-10  1:33 ` [PATCH olang v1 1/6] codestyle: change AlignAfterOpenBracket to BlockIndent Carlos Maniero
  2024-10-10  1:33 ` [PATCH olang v1 2/6] codestyle: never BreakBeforeBraces Carlos Maniero
@ 2024-10-10  1:33 ` Carlos Maniero
  2024-10-10  1:33 ` [PATCH olang v1 4/6] codestyle: do not allow single line enums Carlos Maniero
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 8+ messages in thread
From: Carlos Maniero @ 2024-10-10  1:33 UTC (permalink / raw)
  To: ~johnnyrichard/olang-devel; +Cc: Carlos Maniero

Signed-off-by: Carlos Maniero <carlos@maniero.me>
---
 .clang-format | 1 +
 1 file changed, 1 insertion(+)

diff --git a/.clang-format b/.clang-format
index 68c0e5b..f106b8f 100644
--- a/.clang-format
+++ b/.clang-format
@@ -131,6 +131,7 @@ InsertTrailingCommas: None
 JavaScriptQuotes: Leave
 JavaScriptWrapImports: true
 KeepEmptyLinesAtTheStartOfBlocks: true
+KeepEmptyLinesAtEOF: false
 LambdaBodyIndentation: Signature
 MacroBlockBegin: ''
 MacroBlockEnd:   ''
-- 
2.46.0


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH olang v1 4/6] codestyle: do not allow single line enums
  2024-10-10  1:33 [PATCH olang 0/6] Suggestions in code style Carlos Maniero
                   ` (2 preceding siblings ...)
  2024-10-10  1:33 ` [PATCH olang v1 3/6] codestyle: prevent extra empty lines at EOF Carlos Maniero
@ 2024-10-10  1:33 ` Carlos Maniero
  2024-10-10  1:33 ` [PATCH olang v1 5/6] codestyle: add trailing comma on struct initializer Carlos Maniero
  2024-10-10  1:33 ` [PATCH olang v1 6/6] codestyle: limit the code to 80 characters Carlos Maniero
  5 siblings, 0 replies; 8+ messages in thread
From: Carlos Maniero @ 2024-10-10  1:33 UTC (permalink / raw)
  To: ~johnnyrichard/olang-devel; +Cc: Carlos Maniero

Signed-off-by: Carlos Maniero <carlos@maniero.me>
---
 .clang-format |  2 +-
 src/ast.h     |  4 +++-
 src/type.h    | 13 +++++++++++--
 3 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/.clang-format b/.clang-format
index f106b8f..a1e9892 100644
--- a/.clang-format
+++ b/.clang-format
@@ -33,7 +33,7 @@ AlignOperands:   Align
 AlignTrailingComments: true
 AllowAllArgumentsOnNextLine: true
 AllowAllParametersOfDeclarationOnNextLine: false
-AllowShortEnumsOnASingleLine: true
+AllowShortEnumsOnASingleLine: false
 AllowShortBlocksOnASingleLine: Never
 AllowShortCaseLabelsOnASingleLine: false
 AllowShortFunctionsOnASingleLine: Inline
diff --git a/src/ast.h b/src/ast.h
index b220708..98e035f 100644
--- a/src/ast.h
+++ b/src/ast.h
@@ -89,7 +89,9 @@ typedef struct ast_var_definition {
     scope_t *scope;
 } ast_var_definition_t;
 
-typedef enum { AST_LITERAL_U32 } ast_literal_kind_t;
+typedef enum {
+    AST_LITERAL_U32
+} ast_literal_kind_t;
 
 typedef struct ast_literal {
     ast_node_meta_t meta;
diff --git a/src/type.h b/src/type.h
index edc421b..204f849 100644
--- a/src/type.h
+++ b/src/type.h
@@ -21,9 +21,18 @@
 
 typedef union type type_t;
 
-typedef enum { TYPE_UNKNOWN, TYPE_PRIMITIVE, TYPE_PTR } type_kind_t;
+typedef enum {
+    TYPE_UNKNOWN,
+    TYPE_PRIMITIVE,
+    TYPE_PTR
+} type_kind_t;
 
-typedef enum { TYPE_U8, TYPE_U16, TYPE_U32, TYPE_U64 } type_primitive_kind_t;
+typedef enum {
+    TYPE_U8,
+    TYPE_U16,
+    TYPE_U32,
+    TYPE_U64
+} type_primitive_kind_t;
 
 typedef struct type_primitive {
     type_kind_t _type_kind;
-- 
2.46.0


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH olang v1 5/6] codestyle: add trailing comma on struct initializer
  2024-10-10  1:33 [PATCH olang 0/6] Suggestions in code style Carlos Maniero
                   ` (3 preceding siblings ...)
  2024-10-10  1:33 ` [PATCH olang v1 4/6] codestyle: do not allow single line enums Carlos Maniero
@ 2024-10-10  1:33 ` Carlos Maniero
  2024-10-10  1:34   ` [olang/patches/.build.yml] build success builds.sr.ht
  2024-10-10  1:33 ` [PATCH olang v1 6/6] codestyle: limit the code to 80 characters Carlos Maniero
  5 siblings, 1 reply; 8+ messages in thread
From: Carlos Maniero @ 2024-10-10  1:33 UTC (permalink / raw)
  To: ~johnnyrichard/olang-devel; +Cc: Carlos Maniero

It makes the struct to be formatted that way:

  {
    .a = 1,
    .b = 2,
  }

Instead of:

  { .a = 1,
    .b = 2 }

Unfortunately, there is no config on clang-format to enforce this.

Signed-off-by: Carlos Maniero <carlos@maniero.me>
---
 src/cli.c                     |  5 +++-
 src/lexer.c                   | 51 +++++++++++++++++++++++++++++------
 src/main.c                    |  5 +++-
 src/map.c                     | 14 ++++++++--
 src/string_view.c             |  5 +++-
 tests/unit/string_view_test.c | 20 +++++++++++---
 6 files changed, 83 insertions(+), 17 deletions(-)

diff --git a/src/cli.c b/src/cli.c
index d57945a..1f30ea3 100644
--- a/src/cli.c
+++ b/src/cli.c
@@ -34,7 +34,10 @@ cli_opts_parse_sysroot(cli_opts_t *opts, cli_args_t *args);
 
 cli_opts_t
 cli_parse_args(int argc, char **argv) {
-    cli_args_t args = { .argc = argc, .argv = argv };
+    cli_args_t args = {
+        .argc = argc,
+        .argv = argv,
+    };
     cli_opts_t opts = { 0 };
 
     opts.compiler_path = cli_args_shift(&args);
diff --git a/src/lexer.c b/src/lexer.c
index 352f979..c11bacf 100644
--- a/src/lexer.c
+++ b/src/lexer.c
@@ -88,8 +88,10 @@ lexer_next_token(lexer_t *lexer, token_t *token) {
                 current_char = lexer_current_char(lexer);
             }
 
-            string_view_t text = { .chars = lexer->src.code.chars + start_cur.offset,
-                                   .size = lexer->cur.offset - start_cur.offset };
+            string_view_t text = {
+                .chars = lexer->src.code.chars + start_cur.offset,
+                .size = lexer->cur.offset - start_cur.offset,
+            };
 
             lexer_init_str_value_token(lexer, token, lexer_str_to_token_kind(text), start_cur);
             return;
@@ -392,20 +394,50 @@ _isspace(char c) {
 
 static void
 lexer_init_char_value_token(lexer_t *lexer, token_t *token, token_kind_t kind) {
-    string_view_t str = { .chars = lexer->src.code.chars + lexer->cur.offset, .size = 1 };
-    *token = (token_t){ .kind = kind, .value = str, .loc = (token_loc_t){ .src = lexer->src, .cur = lexer->cur } };
+    string_view_t str = {
+        .chars = lexer->src.code.chars + lexer->cur.offset,
+        .size = 1,
+    };
+    *token = (token_t){
+        .kind = kind,
+        .value = str,
+        .loc =
+            (token_loc_t){
+                .src = lexer->src,
+                .cur = lexer->cur,
+            },
+    };
 }
 
 static void
 lexer_init_str_value_token(lexer_t *lexer, token_t *token, token_kind_t kind, lexer_cursor_t cur) {
-    string_view_t str = { .chars = lexer->src.code.chars + cur.offset, .size = lexer->cur.offset - cur.offset };
-    *token = (token_t){ .kind = kind, .value = str, .loc = (token_loc_t){ .src = lexer->src, .cur = cur } };
+    string_view_t str = {
+        .chars = lexer->src.code.chars + cur.offset,
+        .size = lexer->cur.offset - cur.offset,
+    };
+    *token = (token_t){
+        .kind = kind,
+        .value = str,
+        .loc =
+            (token_loc_t){
+                .src = lexer->src,
+                .cur = cur,
+            },
+    };
 }
 
 static void
 lexer_init_eof_token(lexer_t *lexer, token_t *token) {
     string_view_t str = { 0 };
-    *token = (token_t){ .kind = TOKEN_EOF, .value = str, .loc = (token_loc_t){ .src = lexer->src, .cur = lexer->cur } };
+    *token = (token_t){
+        .kind = TOKEN_EOF,
+        .value = str,
+        .loc =
+            (token_loc_t){
+                .src = lexer->src,
+                .cur = lexer->cur,
+            },
+    };
 }
 
 static token_kind_t
@@ -456,7 +488,10 @@ lexer_lookahead(lexer_t *lexer, token_t *token, size_t n) {
 string_view_t
 token_loc_to_line(token_loc_t loc) {
     size_t offset = loc.cur.bol;
-    string_view_t line = { .chars = loc.src.code.chars + offset, .size = 0 };
+    string_view_t line = {
+        .chars = loc.src.code.chars + offset,
+        .size = 0,
+    };
 
     while ((line.size + offset) < loc.src.code.size && line.chars[line.size] != '\n' && line.chars[line.size] != 0) {
         ++line.size;
diff --git a/src/main.c b/src/main.c
index bb0e451..0e174a1 100644
--- a/src/main.c
+++ b/src/main.c
@@ -235,7 +235,10 @@ read_entire_file(char *filepath, arena_t *arena) {
 
     fclose(stream);
 
-    return (source_code_t){ .filepath = filepath, .code = code };
+    return (source_code_t){
+        .filepath = filepath,
+        .code = code,
+    };
 }
 
 static void
diff --git a/src/map.c b/src/map.c
index 9109eaa..31100b4 100644
--- a/src/map.c
+++ b/src/map.c
@@ -82,7 +82,12 @@ map_put(map_t *map, char *key, void *value) {
     map_entry_t *entry = map->entries + map_get_index(map, hash);
 
     if (entry->key == NULL) {
-        *entry = (map_entry_t){ .key = _strdup(key, map->arena), .hash = hash, .value = value, .next = NULL };
+        *entry = (map_entry_t){
+            .key = _strdup(key, map->arena),
+            .hash = hash,
+            .value = value,
+            .next = NULL,
+        };
         return true;
     }
 
@@ -93,7 +98,12 @@ map_put(map_t *map, char *key, void *value) {
         }
         if (entry->next == NULL) {
             entry->next = (map_entry_t *)arena_alloc(map->arena, sizeof(map_entry_t));
-            *entry->next = (map_entry_t){ .key = _strdup(key, map->arena), .hash = hash, .value = value, .next = NULL };
+            *entry->next = (map_entry_t){
+                .key = _strdup(key, map->arena),
+                .hash = hash,
+                .value = value,
+                .next = NULL,
+            };
 
             break;
         }
diff --git a/src/string_view.c b/src/string_view.c
index 22cb61e..438174c 100644
--- a/src/string_view.c
+++ b/src/string_view.c
@@ -23,7 +23,10 @@
 
 string_view_t
 string_view_from_cstr(char *cstr) {
-    return (string_view_t){ .chars = cstr, .size = strlen(cstr) };
+    return (string_view_t){
+        .chars = cstr,
+        .size = strlen(cstr),
+    };
 }
 
 bool
diff --git a/tests/unit/string_view_test.c b/tests/unit/string_view_test.c
index f8ca792..6f42e0c 100644
--- a/tests/unit/string_view_test.c
+++ b/tests/unit/string_view_test.c
@@ -25,14 +25,20 @@ static MunitResult
 string_view_eq_to_cstr_test(const MunitParameter params[], void *user_data_or_fixture) {
     char *name = "John Doe";
 
-    string_view_t str = { .chars = name, .size = strlen(name) };
+    string_view_t str = {
+        .chars = name,
+        .size = strlen(name),
+    };
 
     assert_true(string_view_eq_to_cstr(str, "John Doe"));
     assert_false(string_view_eq_to_cstr(str, "Doe"));
 
     char *return_stmt = "return EXIT_SUCCESS;";
 
-    str = (string_view_t){ .chars = return_stmt + 7, .size = 12 };
+    str = (string_view_t){
+        .chars = return_stmt + 7,
+        .size = 12,
+    };
     assert_true(string_view_eq_to_cstr(str, "EXIT_SUCCESS"));
 
     return MUNIT_OK;
@@ -42,11 +48,17 @@ static MunitResult
 string_view_to_u32_test(const MunitParameter params[], void *user_data_or_fixture) {
     char *number = "69";
 
-    string_view_t str = { .chars = number, .size = strlen(number) };
+    string_view_t str = {
+        .chars = number,
+        .size = strlen(number),
+    };
 
     assert_uint32(string_view_to_u32(str), ==, 69);
 
-    str = (string_view_t){ .chars = "39;", .size = 2 };
+    str = (string_view_t){
+        .chars = "39;",
+        .size = 2,
+    };
 
     assert_uint32(string_view_to_u32(str), ==, 39);
 
-- 
2.46.0


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH olang v1 6/6] codestyle: limit the code to 80 characters
  2024-10-10  1:33 [PATCH olang 0/6] Suggestions in code style Carlos Maniero
                   ` (4 preceding siblings ...)
  2024-10-10  1:33 ` [PATCH olang v1 5/6] codestyle: add trailing comma on struct initializer Carlos Maniero
@ 2024-10-10  1:33 ` Carlos Maniero
  5 siblings, 0 replies; 8+ messages in thread
From: Carlos Maniero @ 2024-10-10  1:33 UTC (permalink / raw)
  To: ~johnnyrichard/olang-devel; +Cc: Carlos Maniero

Signed-off-by: Carlos Maniero <carlos@maniero.me>
---
 .clang-format                 |   4 +-
 src/ast.c                     |  82 +++++--
 src/ast.h                     |  52 +++-
 src/checker.c                 |  13 +-
 src/cli.c                     |   3 +-
 src/codegen_linux_x86_64.c    | 434 +++++++++++++++++++++++++++-------
 src/codegen_linux_x86_64.h    |   5 +-
 src/lexer.c                   |  61 +++--
 src/main.c                    |  26 +-
 src/map.c                     |  15 +-
 src/parser.c                  |  95 ++++++--
 src/pretty_print_ast.c        | 100 +++++---
 src/scope.c                   |  12 +-
 tests/unit/arena_test.c       |  26 +-
 tests/unit/list_test.c        |  33 ++-
 tests/unit/map_test.c         |  25 +-
 tests/unit/string_view_test.c |  30 ++-
 17 files changed, 799 insertions(+), 217 deletions(-)

diff --git a/.clang-format b/.clang-format
index a1e9892..bdc2904 100644
--- a/.clang-format
+++ b/.clang-format
@@ -77,7 +77,7 @@ BreakConstructorInitializersBeforeComma: false
 BreakConstructorInitializers: BeforeComma
 BreakAfterJavaFieldAnnotations: false
 BreakStringLiterals: true
-ColumnLimit:     120
+ColumnLimit:     80
 CommentPragmas:  '^ IWYU pragma:'
 QualifierAlignment: Leave
 CompactNamespaces: false
@@ -145,7 +145,7 @@ ObjCSpaceBeforeProtocolList: false
 PenaltyBreakAssignment: 2
 PenaltyBreakBeforeFirstCallParameter: 19
 PenaltyBreakComment: 300
-PenaltyBreakFirstLessLess: 120
+PenaltyBreakFirstLessLess: 80
 PenaltyBreakOpenParenthesis: 0
 PenaltyBreakString: 1000
 PenaltyBreakTemplateDeclaration: 10
diff --git a/src/ast.c b/src/ast.c
index 1a23864..dd8dd66 100644
--- a/src/ast.c
+++ b/src/ast.c
@@ -51,7 +51,8 @@ ast_new_node_fn_def(
     assert(params);
     assert(block);
 
-    ast_node_t *node_fn_def = (ast_node_t *)arena_alloc(arena, sizeof(ast_node_t));
+    ast_node_t *node_fn_def =
+        (ast_node_t *)arena_alloc(arena, sizeof(ast_node_t));
     assert(node_fn_def);
 
     node_fn_def->kind = AST_NODE_FN_DEF;
@@ -67,11 +68,17 @@ ast_new_node_fn_def(
 }
 
 ast_node_t *
-ast_new_node_fn_call(arena_t *arena, token_loc_t loc, string_view_t id, list_t *args) {
+ast_new_node_fn_call(
+    arena_t *arena,
+    token_loc_t loc,
+    string_view_t id,
+    list_t *args
+) {
     assert(arena);
     assert(args);
 
-    ast_node_t *node_fn_call = (ast_node_t *)arena_alloc(arena, sizeof(ast_node_t));
+    ast_node_t *node_fn_call =
+        (ast_node_t *)arena_alloc(arena, sizeof(ast_node_t));
     assert(node_fn_call);
 
     node_fn_call->kind = AST_NODE_FN_CALL;
@@ -85,8 +92,15 @@ ast_new_node_fn_call(arena_t *arena, token_loc_t loc, string_view_t id, list_t *
 }
 
 ast_node_t *
-ast_new_node_var_def(arena_t *arena, token_loc_t loc, string_view_t id, type_t *type, ast_node_t *value) {
-    ast_node_t *node_var_def = (ast_node_t *)arena_alloc(arena, sizeof(ast_node_t));
+ast_new_node_var_def(
+    arena_t *arena,
+    token_loc_t loc,
+    string_view_t id,
+    type_t *type,
+    ast_node_t *value
+) {
+    ast_node_t *node_var_def =
+        (ast_node_t *)arena_alloc(arena, sizeof(ast_node_t));
     assert(node_var_def);
 
     node_var_def->kind = AST_NODE_VAR_DEF;
@@ -101,8 +115,15 @@ ast_new_node_var_def(arena_t *arena, token_loc_t loc, string_view_t id, type_t *
 }
 
 ast_node_t *
-ast_new_node_bin_op(arena_t *arena, token_loc_t loc, ast_binary_op_kind_t kind, ast_node_t *lhs, ast_node_t *rhs) {
-    ast_node_t *node_bin_op = (ast_node_t *)arena_alloc(arena, sizeof(ast_node_t));
+ast_new_node_bin_op(
+    arena_t *arena,
+    token_loc_t loc,
+    ast_binary_op_kind_t kind,
+    ast_node_t *lhs,
+    ast_node_t *rhs
+) {
+    ast_node_t *node_bin_op =
+        (ast_node_t *)arena_alloc(arena, sizeof(ast_node_t));
     assert(node_bin_op);
 
     node_bin_op->kind = AST_NODE_BINARY_OP;
@@ -115,8 +136,14 @@ ast_new_node_bin_op(arena_t *arena, token_loc_t loc, ast_binary_op_kind_t kind,
 }
 
 ast_node_t *
-ast_new_node_unary_op(arena_t *arena, token_loc_t loc, ast_unary_op_kind_t kind, ast_node_t *expr) {
-    ast_node_t *node_unary_op = (ast_node_t *)arena_alloc(arena, sizeof(ast_node_t));
+ast_new_node_unary_op(
+    arena_t *arena,
+    token_loc_t loc,
+    ast_unary_op_kind_t kind,
+    ast_node_t *expr
+) {
+    ast_node_t *node_unary_op =
+        (ast_node_t *)arena_alloc(arena, sizeof(ast_node_t));
     assert(node_unary_op);
 
     node_unary_op->kind = AST_NODE_UNARY_OP;
@@ -129,7 +156,8 @@ ast_new_node_unary_op(arena_t *arena, token_loc_t loc, ast_unary_op_kind_t kind,
 
 ast_node_t *
 ast_new_node_literal_u32(arena_t *arena, token_loc_t loc, uint32_t value) {
-    ast_node_t *node_literal = (ast_node_t *)arena_alloc(arena, sizeof(ast_node_t));
+    ast_node_t *node_literal =
+        (ast_node_t *)arena_alloc(arena, sizeof(ast_node_t));
     assert(node_literal);
 
     node_literal->kind = AST_NODE_LITERAL;
@@ -153,8 +181,14 @@ ast_new_node_ref(arena_t *arena, token_loc_t loc, string_view_t id) {
 }
 
 ast_node_t *
-ast_new_node_var_assign_stmt(arena_t *arena, token_loc_t loc, ast_node_t *ref, ast_node_t *expr) {
-    ast_node_t *node_var_assign_stmt = (ast_node_t *)arena_alloc(arena, sizeof(ast_node_t));
+ast_new_node_var_assign_stmt(
+    arena_t *arena,
+    token_loc_t loc,
+    ast_node_t *ref,
+    ast_node_t *expr
+) {
+    ast_node_t *node_var_assign_stmt =
+        (ast_node_t *)arena_alloc(arena, sizeof(ast_node_t));
     assert(node_var_assign_stmt);
 
     node_var_assign_stmt->kind = AST_NODE_VAR_ASSIGN_STMT;
@@ -167,7 +201,8 @@ ast_new_node_var_assign_stmt(arena_t *arena, token_loc_t loc, ast_node_t *ref, a
 
 ast_node_t *
 ast_new_node_return_stmt(arena_t *arena, token_loc_t loc, ast_node_t *expr) {
-    ast_node_t *node_return_stmt = (ast_node_t *)arena_alloc(arena, sizeof(ast_node_t));
+    ast_node_t *node_return_stmt =
+        (ast_node_t *)arena_alloc(arena, sizeof(ast_node_t));
     assert(node_return_stmt);
 
     node_return_stmt->kind = AST_NODE_RETURN_STMT;
@@ -178,7 +213,13 @@ ast_new_node_return_stmt(arena_t *arena, token_loc_t loc, ast_node_t *expr) {
 }
 
 ast_node_t *
-ast_new_node_if_stmt(arena_t *arena, token_loc_t loc, ast_node_t *cond, ast_node_t *then, ast_node_t *_else) {
+ast_new_node_if_stmt(
+    arena_t *arena,
+    token_loc_t loc,
+    ast_node_t *cond,
+    ast_node_t *then,
+    ast_node_t *_else
+) {
     ast_node_t *node_if_stmt = arena_alloc(arena, sizeof(ast_node_t));
     assert(node_if_stmt);
 
@@ -192,7 +233,12 @@ ast_new_node_if_stmt(arena_t *arena, token_loc_t loc, ast_node_t *cond, ast_node
 }
 
 ast_node_t *
-ast_new_node_while_stmt(arena_t *arena, token_loc_t loc, ast_node_t *cond, ast_node_t *then) {
+ast_new_node_while_stmt(
+    arena_t *arena,
+    token_loc_t loc,
+    ast_node_t *cond,
+    ast_node_t *then
+) {
     ast_node_t *node_while_stmt = arena_alloc(arena, sizeof(ast_node_t));
     assert(node_while_stmt);
 
@@ -206,7 +252,8 @@ ast_new_node_while_stmt(arena_t *arena, token_loc_t loc, ast_node_t *cond, ast_n
 
 ast_node_t *
 ast_new_node_block(arena_t *arena) {
-    ast_node_t *node_block = (ast_node_t *)arena_alloc(arena, sizeof(ast_node_t));
+    ast_node_t *node_block =
+        (ast_node_t *)arena_alloc(arena, sizeof(ast_node_t));
     assert(node_block);
 
     node_block->kind = AST_NODE_BLOCK;
@@ -221,7 +268,8 @@ ast_new_node_block(arena_t *arena) {
 
 ast_fn_param_t *
 ast_new_fn_param(arena_t *arena, string_view_t id, type_t *type) {
-    ast_fn_param_t *fn_param = (ast_fn_param_t *)arena_alloc(arena, sizeof(ast_fn_param_t));
+    ast_fn_param_t *fn_param =
+        (ast_fn_param_t *)arena_alloc(arena, sizeof(ast_fn_param_t));
     assert(fn_param);
 
     fn_param->id = id;
diff --git a/src/ast.h b/src/ast.h
index 98e035f..8380b38 100644
--- a/src/ast.h
+++ b/src/ast.h
@@ -209,16 +209,38 @@ ast_new_node_fn_def(
 );
 
 ast_node_t *
-ast_new_node_fn_call(arena_t *arena, token_loc_t loc, string_view_t id, list_t *args);
+ast_new_node_fn_call(
+    arena_t *arena,
+    token_loc_t loc,
+    string_view_t id,
+    list_t *args
+);
 
 ast_node_t *
-ast_new_node_var_def(arena_t *arena, token_loc_t loc, string_view_t id, type_t *type, ast_node_t *value);
+ast_new_node_var_def(
+    arena_t *arena,
+    token_loc_t loc,
+    string_view_t id,
+    type_t *type,
+    ast_node_t *value
+);
 
 ast_node_t *
-ast_new_node_bin_op(arena_t *arena, token_loc_t loc, ast_binary_op_kind_t kind, ast_node_t *lhs, ast_node_t *rhs);
+ast_new_node_bin_op(
+    arena_t *arena,
+    token_loc_t loc,
+    ast_binary_op_kind_t kind,
+    ast_node_t *lhs,
+    ast_node_t *rhs
+);
 
 ast_node_t *
-ast_new_node_unary_op(arena_t *arena, token_loc_t loc, ast_unary_op_kind_t kind, ast_node_t *expr);
+ast_new_node_unary_op(
+    arena_t *arena,
+    token_loc_t loc,
+    ast_unary_op_kind_t kind,
+    ast_node_t *expr
+);
 
 ast_node_t *
 ast_new_node_literal_u32(arena_t *arena, token_loc_t loc, uint32_t value);
@@ -227,16 +249,32 @@ ast_node_t *
 ast_new_node_ref(arena_t *arena, token_loc_t loc, string_view_t id);
 
 ast_node_t *
-ast_new_node_var_assign_stmt(arena_t *arena, token_loc_t loc, ast_node_t *ref, ast_node_t *expr);
+ast_new_node_var_assign_stmt(
+    arena_t *arena,
+    token_loc_t loc,
+    ast_node_t *ref,
+    ast_node_t *expr
+);
 
 ast_node_t *
 ast_new_node_return_stmt(arena_t *arena, token_loc_t loc, ast_node_t *expr);
 
 ast_node_t *
-ast_new_node_if_stmt(arena_t *arena, token_loc_t loc, ast_node_t *cond, ast_node_t *then, ast_node_t *_else);
+ast_new_node_if_stmt(
+    arena_t *arena,
+    token_loc_t loc,
+    ast_node_t *cond,
+    ast_node_t *then,
+    ast_node_t *_else
+);
 
 ast_node_t *
-ast_new_node_while_stmt(arena_t *arena, token_loc_t loc, ast_node_t *cond, ast_node_t *then);
+ast_new_node_while_stmt(
+    arena_t *arena,
+    token_loc_t loc,
+    ast_node_t *cond,
+    ast_node_t *then
+);
 
 ast_node_t *
 ast_new_node_block(arena_t *arena);
diff --git a/src/checker.c b/src/checker.c
index 1613c04..28df2d6 100644
--- a/src/checker.c
+++ b/src/checker.c
@@ -29,7 +29,9 @@ checker_new(arena_t *arena) {
 
     checker_t *checker = (checker_t *)arena_alloc(arena, sizeof(checker_t));
     if (checker == NULL) {
-        fprintf(stderr, "[FATAL] Out of memory: checker_new: %s\n", strerror(errno));
+        fprintf(
+            stderr, "[FATAL] Out of memory: checker_new: %s\n", strerror(errno)
+        );
         exit(EXIT_FAILURE);
     }
     checker->arena = arena;
@@ -114,7 +116,8 @@ populate_scope(checker_t *checker, scope_t *scope, ast_node_t *ast) {
             fn_def->scope = scope_push(scope);
 
             type_resolve(fn_def->return_type);
-            symbol_t *symbol = symbol_new(checker->arena, fn_def->id, fn_def->return_type);
+            symbol_t *symbol =
+                symbol_new(checker->arena, fn_def->id, fn_def->return_type);
             scope_insert(scope, symbol);
 
             list_item_t *item = list_head(fn_def->params);
@@ -123,7 +126,8 @@ populate_scope(checker_t *checker, scope_t *scope, ast_node_t *ast) {
                 ast_fn_param_t *param = (ast_fn_param_t *)item->value;
 
                 type_resolve(param->type);
-                symbol_t *symbol = symbol_new(checker->arena, param->id, param->type);
+                symbol_t *symbol =
+                    symbol_new(checker->arena, param->id, param->type);
                 scope_insert(fn_def->scope, symbol);
 
                 item = list_next(item);
@@ -213,7 +217,8 @@ populate_scope(checker_t *checker, scope_t *scope, ast_node_t *ast) {
 
             type_resolve(ast->as_var_def.type);
 
-            symbol_t *symbol = symbol_new(checker->arena, id, ast->as_var_def.type);
+            symbol_t *symbol =
+                symbol_new(checker->arena, id, ast->as_var_def.type);
 
             scope_insert(scope, symbol);
             ast->as_var_def.scope = scope;
diff --git a/src/cli.c b/src/cli.c
index 1f30ea3..1765ecf 100644
--- a/src/cli.c
+++ b/src/cli.c
@@ -64,7 +64,8 @@ cli_parse_args(int argc, char **argv) {
         arg = cli_args_shift(&args);
     }
 
-    if (opts.options & CLI_OPT_OUTPUT || opts.options & CLI_OPT_DUMP_TOKENS || opts.options & CLI_OPT_DUMP_AST) {
+    if (opts.options & CLI_OPT_OUTPUT || opts.options & CLI_OPT_DUMP_TOKENS ||
+        opts.options & CLI_OPT_DUMP_AST) {
         return opts;
     }
 
diff --git a/src/codegen_linux_x86_64.c b/src/codegen_linux_x86_64.c
index c0b7326..aa9cfb4 100644
--- a/src/codegen_linux_x86_64.c
+++ b/src/codegen_linux_x86_64.c
@@ -57,22 +57,34 @@ typedef enum x86_64_register_type {
  * ──────────────────────────────────────────────────────────────
  * x86-64        rdi   rsi   rdx   r10   r8    r9    -
  */
-static int x86_call_args[X86_CALL_ARG_SIZE] = { REG_DEST_IDX, REG_SRC_IDX, REG_DATA, REG_R10, REG_R8, REG_R9 };
+static int x86_call_args[X86_CALL_ARG_SIZE] = { REG_DEST_IDX, REG_SRC_IDX,
+                                                REG_DATA,     REG_R10,
+                                                REG_R8,       REG_R9 };
 
 static void
 codegen_linux_x86_64_emit_start_entrypoint(codegen_x86_64_t *codegen);
 
 static void
-codegen_linux_x86_64_emit_function(codegen_x86_64_t *codegen, ast_fn_definition_t *fn);
+codegen_linux_x86_64_emit_function(
+    codegen_x86_64_t *codegen,
+    ast_fn_definition_t *fn
+);
 
 static void
 codegen_linux_x86_64_emit_if(codegen_x86_64_t *codegen, ast_if_stmt_t is_stmt);
 
 static void
-codegen_linux_x86_64_put_stack_offset(codegen_x86_64_t *codegen, symbol_t *symbol, size_t offset);
+codegen_linux_x86_64_put_stack_offset(
+    codegen_x86_64_t *codegen,
+    symbol_t *symbol,
+    size_t offset
+);
 
 static size_t
-codegen_linux_x86_64_get_stack_offset(codegen_x86_64_t *codegen, symbol_t *symbol);
+codegen_linux_x86_64_get_stack_offset(
+    codegen_x86_64_t *codegen,
+    symbol_t *symbol
+);
 
 static size_t
 type_to_bytes(type_t *type);
@@ -81,7 +93,11 @@ static char *
 get_reg_for(x86_64_register_type_t type, size_t bytes);
 
 void
-codegen_linux_x86_64_init(codegen_x86_64_t *codegen, arena_t *arena, FILE *out) {
+codegen_linux_x86_64_init(
+    codegen_x86_64_t *codegen,
+    arena_t *arena,
+    FILE *out
+) {
     assert(codegen);
     assert(arena);
     assert(codegen);
@@ -92,7 +108,10 @@ codegen_linux_x86_64_init(codegen_x86_64_t *codegen, arena_t *arena, FILE *out)
 }
 
 void
-codegen_linux_x86_64_emit_translation_unit(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);
 
@@ -141,7 +160,10 @@ codegen_linux_x86_64_get_next_label(codegen_x86_64_t *codegen) {
 typedef size_t size_in_bytes_t;
 
 static size_in_bytes_t
-codegen_linux_x86_64_emit_expression(codegen_x86_64_t *codegen, ast_node_t *expr_node) {
+codegen_linux_x86_64_emit_expression(
+    codegen_x86_64_t *codegen,
+    ast_node_t *expr_node
+) {
     switch (expr_node->kind) {
         case AST_NODE_LITERAL: {
             ast_literal_t literal_u32 = expr_node->as_literal;
@@ -157,11 +179,17 @@ codegen_linux_x86_64_emit_expression(codegen_x86_64_t *codegen, ast_node_t *expr
             symbol_t *symbol = scope_lookup(ref.scope, ref.id);
             assert(symbol);
 
-            size_t offset = codegen_linux_x86_64_get_stack_offset(codegen, symbol);
+            size_t offset =
+                codegen_linux_x86_64_get_stack_offset(codegen, symbol);
 
             size_t bytes = type_to_bytes(symbol->type);
 
-            fprintf(codegen->out, "    mov -%ld(%%rbp), %s\n", offset, get_reg_for(REG_ACCUMULATOR, bytes));
+            fprintf(
+                codegen->out,
+                "    mov -%ld(%%rbp), %s\n",
+                offset,
+                get_reg_for(REG_ACCUMULATOR, bytes)
+            );
             return bytes;
         }
         case AST_NODE_FN_CALL: {
@@ -171,7 +199,8 @@ codegen_linux_x86_64_emit_expression(codegen_x86_64_t *codegen, ast_node_t *expr
             assert(symbol);
 
             size_t i = 0;
-            for (list_item_t *item = list_head(fn_call.args); item != NULL; item = list_next(item)) {
+            for (list_item_t *item = list_head(fn_call.args); item != NULL;
+                 item = list_next(item)) {
                 // FIXME: add support for more args than X86_CALL_ARG_SIZE
                 assert(i < X86_CALL_ARG_SIZE);
 
@@ -179,12 +208,20 @@ codegen_linux_x86_64_emit_expression(codegen_x86_64_t *codegen, ast_node_t *expr
 
                 codegen_linux_x86_64_emit_expression(codegen, arg_node);
 
-                fprintf(codegen->out, "    push %s\n", get_reg_for(REG_ACCUMULATOR, 8));
+                fprintf(
+                    codegen->out,
+                    "    push %s\n",
+                    get_reg_for(REG_ACCUMULATOR, 8)
+                );
                 ++i;
             }
 
             for (; i > 0; --i) {
-                fprintf(codegen->out, "    pop %s\n", get_reg_for(x86_call_args[i - 1], 8));
+                fprintf(
+                    codegen->out,
+                    "    pop %s\n",
+                    get_reg_for(x86_call_args[i - 1], 8)
+                );
             }
 
             fprintf(codegen->out, "    call " SV_FMT "\n", SV_ARG(fn_call.id));
@@ -196,13 +233,20 @@ codegen_linux_x86_64_emit_expression(codegen_x86_64_t *codegen, ast_node_t *expr
             switch (bin_op.kind) {
                 case AST_BINOP_ADDITION: {
                     fprintf(codegen->out, "    xor %%rax, %%rax\n");
-                    size_in_bytes_t rhs_bytes = codegen_linux_x86_64_emit_expression(codegen, bin_op.rhs);
+                    size_in_bytes_t rhs_bytes =
+                        codegen_linux_x86_64_emit_expression(
+                            codegen, bin_op.rhs
+                        );
                     fprintf(codegen->out, "    push %%rax\n");
 
                     fprintf(codegen->out, "    xor %%rax, %%rax\n");
-                    size_in_bytes_t lhs_bytes = codegen_linux_x86_64_emit_expression(codegen, bin_op.lhs);
+                    size_in_bytes_t lhs_bytes =
+                        codegen_linux_x86_64_emit_expression(
+                            codegen, bin_op.lhs
+                        );
 
-                    size_in_bytes_t expr_bytes = bytes_max(rhs_bytes, lhs_bytes);
+                    size_in_bytes_t expr_bytes =
+                        bytes_max(rhs_bytes, lhs_bytes);
 
                     fprintf(codegen->out, "    pop %%rcx\n");
                     fprintf(
@@ -216,48 +260,81 @@ codegen_linux_x86_64_emit_expression(codegen_x86_64_t *codegen, ast_node_t *expr
                 }
                 case AST_BINOP_MULTIPLICATION: {
                     fprintf(codegen->out, "    xor %%rax, %%rax\n");
-                    size_in_bytes_t rhs_bytes = codegen_linux_x86_64_emit_expression(codegen, bin_op.rhs);
+                    size_in_bytes_t rhs_bytes =
+                        codegen_linux_x86_64_emit_expression(
+                            codegen, bin_op.rhs
+                        );
                     fprintf(codegen->out, "    push %%rax\n");
 
                     fprintf(codegen->out, "    xor %%rax, %%rax\n");
-                    size_in_bytes_t lhs_bytes = codegen_linux_x86_64_emit_expression(codegen, bin_op.lhs);
+                    size_in_bytes_t lhs_bytes =
+                        codegen_linux_x86_64_emit_expression(
+                            codegen, bin_op.lhs
+                        );
 
-                    size_in_bytes_t expr_bytes = bytes_max(rhs_bytes, lhs_bytes);
+                    size_in_bytes_t expr_bytes =
+                        bytes_max(rhs_bytes, lhs_bytes);
 
                     fprintf(codegen->out, "    pop %%rcx\n");
-                    fprintf(codegen->out, "    mul %s\n", get_reg_for(REG_COUNTER, expr_bytes));
+                    fprintf(
+                        codegen->out,
+                        "    mul %s\n",
+                        get_reg_for(REG_COUNTER, expr_bytes)
+                    );
 
                     return expr_bytes;
                 }
                 case AST_BINOP_DIVISION: {
                     fprintf(codegen->out, "    xor %%rax, %%rax\n");
-                    size_in_bytes_t rhs_bytes = codegen_linux_x86_64_emit_expression(codegen, bin_op.rhs);
+                    size_in_bytes_t rhs_bytes =
+                        codegen_linux_x86_64_emit_expression(
+                            codegen, bin_op.rhs
+                        );
                     fprintf(codegen->out, "    push %%rax\n");
 
                     fprintf(codegen->out, "    xor %%rax, %%rax\n");
-                    size_in_bytes_t lhs_bytes = codegen_linux_x86_64_emit_expression(codegen, bin_op.lhs);
+                    size_in_bytes_t lhs_bytes =
+                        codegen_linux_x86_64_emit_expression(
+                            codegen, bin_op.lhs
+                        );
 
-                    size_in_bytes_t expr_bytes = bytes_max(rhs_bytes, lhs_bytes);
+                    size_in_bytes_t expr_bytes =
+                        bytes_max(rhs_bytes, lhs_bytes);
 
                     fprintf(codegen->out, "    pop %%rcx\n");
                     fprintf(codegen->out, "    xor %%rdx, %%rdx\n");
-                    fprintf(codegen->out, "    div %s\n", get_reg_for(REG_COUNTER, expr_bytes));
+                    fprintf(
+                        codegen->out,
+                        "    div %s\n",
+                        get_reg_for(REG_COUNTER, expr_bytes)
+                    );
 
                     return expr_bytes;
                 }
                 case AST_BINOP_REMINDER: {
                     fprintf(codegen->out, "    xor %%rax, %%rax\n");
-                    size_in_bytes_t rhs_bytes = codegen_linux_x86_64_emit_expression(codegen, bin_op.rhs);
+                    size_in_bytes_t rhs_bytes =
+                        codegen_linux_x86_64_emit_expression(
+                            codegen, bin_op.rhs
+                        );
                     fprintf(codegen->out, "    push %%rax\n");
 
                     fprintf(codegen->out, "    xor %%rax, %%rax\n");
-                    size_in_bytes_t lhs_bytes = codegen_linux_x86_64_emit_expression(codegen, bin_op.lhs);
+                    size_in_bytes_t lhs_bytes =
+                        codegen_linux_x86_64_emit_expression(
+                            codegen, bin_op.lhs
+                        );
 
-                    size_in_bytes_t expr_bytes = bytes_max(rhs_bytes, lhs_bytes);
+                    size_in_bytes_t expr_bytes =
+                        bytes_max(rhs_bytes, lhs_bytes);
 
                     fprintf(codegen->out, "    pop %%rcx\n");
                     fprintf(codegen->out, "    xor %%rdx, %%rdx\n");
-                    fprintf(codegen->out, "    div %s\n", get_reg_for(REG_COUNTER, expr_bytes));
+                    fprintf(
+                        codegen->out,
+                        "    div %s\n",
+                        get_reg_for(REG_COUNTER, expr_bytes)
+                    );
                     fprintf(
                         codegen->out,
                         "    mov %s, %s\n",
@@ -269,13 +346,20 @@ codegen_linux_x86_64_emit_expression(codegen_x86_64_t *codegen, ast_node_t *expr
                 }
                 case AST_BINOP_SUBTRACTION: {
                     fprintf(codegen->out, "    xor %%rax, %%rax\n");
-                    size_in_bytes_t rhs_bytes = codegen_linux_x86_64_emit_expression(codegen, bin_op.rhs);
+                    size_in_bytes_t rhs_bytes =
+                        codegen_linux_x86_64_emit_expression(
+                            codegen, bin_op.rhs
+                        );
                     fprintf(codegen->out, "    push %%rax\n");
 
                     fprintf(codegen->out, "    xor %%rax, %%rax\n");
-                    size_in_bytes_t lhs_bytes = codegen_linux_x86_64_emit_expression(codegen, bin_op.lhs);
+                    size_in_bytes_t lhs_bytes =
+                        codegen_linux_x86_64_emit_expression(
+                            codegen, bin_op.lhs
+                        );
 
-                    size_in_bytes_t expr_bytes = bytes_max(rhs_bytes, lhs_bytes);
+                    size_in_bytes_t expr_bytes =
+                        bytes_max(rhs_bytes, lhs_bytes);
 
                     fprintf(codegen->out, "    pop %%rcx\n");
                     fprintf(
@@ -289,13 +373,20 @@ codegen_linux_x86_64_emit_expression(codegen_x86_64_t *codegen, ast_node_t *expr
                 }
                 case AST_BINOP_CMP_EQ: {
                     fprintf(codegen->out, "    xor %%rax, %%rax\n");
-                    size_in_bytes_t rhs_bytes = codegen_linux_x86_64_emit_expression(codegen, bin_op.rhs);
+                    size_in_bytes_t rhs_bytes =
+                        codegen_linux_x86_64_emit_expression(
+                            codegen, bin_op.rhs
+                        );
                     fprintf(codegen->out, "    push %%rax\n");
 
                     fprintf(codegen->out, "    xor %%rax, %%rax\n");
-                    size_in_bytes_t lhs_bytes = codegen_linux_x86_64_emit_expression(codegen, bin_op.lhs);
+                    size_in_bytes_t lhs_bytes =
+                        codegen_linux_x86_64_emit_expression(
+                            codegen, bin_op.lhs
+                        );
 
-                    size_in_bytes_t expr_bytes = bytes_max(rhs_bytes, lhs_bytes);
+                    size_in_bytes_t expr_bytes =
+                        bytes_max(rhs_bytes, lhs_bytes);
 
                     fprintf(codegen->out, "    pop %%rcx\n");
                     fprintf(
@@ -305,19 +396,30 @@ codegen_linux_x86_64_emit_expression(codegen_x86_64_t *codegen, ast_node_t *expr
                         get_reg_for(REG_ACCUMULATOR, expr_bytes)
                     );
                     fprintf(codegen->out, "    sete %%al\n");
-                    fprintf(codegen->out, "    movzb %%al, %s\n", get_reg_for(REG_ACCUMULATOR, expr_bytes));
+                    fprintf(
+                        codegen->out,
+                        "    movzb %%al, %s\n",
+                        get_reg_for(REG_ACCUMULATOR, expr_bytes)
+                    );
 
                     return expr_bytes;
                 }
                 case AST_BINOP_CMP_LT: {
                     fprintf(codegen->out, "    xor %%rax, %%rax\n");
-                    size_in_bytes_t rhs_bytes = codegen_linux_x86_64_emit_expression(codegen, bin_op.rhs);
+                    size_in_bytes_t rhs_bytes =
+                        codegen_linux_x86_64_emit_expression(
+                            codegen, bin_op.rhs
+                        );
                     fprintf(codegen->out, "    push %%rax\n");
 
                     fprintf(codegen->out, "    xor %%rax, %%rax\n");
-                    size_in_bytes_t lhs_bytes = codegen_linux_x86_64_emit_expression(codegen, bin_op.lhs);
+                    size_in_bytes_t lhs_bytes =
+                        codegen_linux_x86_64_emit_expression(
+                            codegen, bin_op.lhs
+                        );
 
-                    size_in_bytes_t expr_bytes = bytes_max(rhs_bytes, lhs_bytes);
+                    size_in_bytes_t expr_bytes =
+                        bytes_max(rhs_bytes, lhs_bytes);
 
                     fprintf(codegen->out, "    pop %%rcx\n");
                     fprintf(
@@ -327,19 +429,30 @@ codegen_linux_x86_64_emit_expression(codegen_x86_64_t *codegen, ast_node_t *expr
                         get_reg_for(REG_ACCUMULATOR, expr_bytes)
                     );
                     fprintf(codegen->out, "    setl %%al\n");
-                    fprintf(codegen->out, "    movzb %%al, %s\n", get_reg_for(REG_ACCUMULATOR, expr_bytes));
+                    fprintf(
+                        codegen->out,
+                        "    movzb %%al, %s\n",
+                        get_reg_for(REG_ACCUMULATOR, expr_bytes)
+                    );
 
                     return expr_bytes;
                 }
                 case AST_BINOP_CMP_GT: {
                     fprintf(codegen->out, "    xor %%rax, %%rax\n");
-                    size_in_bytes_t rhs_bytes = codegen_linux_x86_64_emit_expression(codegen, bin_op.rhs);
+                    size_in_bytes_t rhs_bytes =
+                        codegen_linux_x86_64_emit_expression(
+                            codegen, bin_op.rhs
+                        );
                     fprintf(codegen->out, "    push %%rax\n");
 
                     fprintf(codegen->out, "    xor %%rax, %%rax\n");
-                    size_in_bytes_t lhs_bytes = codegen_linux_x86_64_emit_expression(codegen, bin_op.lhs);
+                    size_in_bytes_t lhs_bytes =
+                        codegen_linux_x86_64_emit_expression(
+                            codegen, bin_op.lhs
+                        );
 
-                    size_in_bytes_t expr_bytes = bytes_max(rhs_bytes, lhs_bytes);
+                    size_in_bytes_t expr_bytes =
+                        bytes_max(rhs_bytes, lhs_bytes);
 
                     fprintf(codegen->out, "    pop %%rcx\n");
                     fprintf(
@@ -349,19 +462,30 @@ codegen_linux_x86_64_emit_expression(codegen_x86_64_t *codegen, ast_node_t *expr
                         get_reg_for(REG_ACCUMULATOR, expr_bytes)
                     );
                     fprintf(codegen->out, "    setg %%al\n");
-                    fprintf(codegen->out, "    movzb %%al, %s\n", get_reg_for(REG_ACCUMULATOR, expr_bytes));
+                    fprintf(
+                        codegen->out,
+                        "    movzb %%al, %s\n",
+                        get_reg_for(REG_ACCUMULATOR, expr_bytes)
+                    );
 
                     return expr_bytes;
                 }
                 case AST_BINOP_CMP_NEQ: {
                     fprintf(codegen->out, "    xor %%rax, %%rax\n");
-                    size_in_bytes_t rhs_bytes = codegen_linux_x86_64_emit_expression(codegen, bin_op.rhs);
+                    size_in_bytes_t rhs_bytes =
+                        codegen_linux_x86_64_emit_expression(
+                            codegen, bin_op.rhs
+                        );
                     fprintf(codegen->out, "    push %%rax\n");
 
                     fprintf(codegen->out, "    xor %%rax, %%rax\n");
-                    size_in_bytes_t lhs_bytes = codegen_linux_x86_64_emit_expression(codegen, bin_op.lhs);
+                    size_in_bytes_t lhs_bytes =
+                        codegen_linux_x86_64_emit_expression(
+                            codegen, bin_op.lhs
+                        );
 
-                    size_in_bytes_t expr_bytes = bytes_max(rhs_bytes, lhs_bytes);
+                    size_in_bytes_t expr_bytes =
+                        bytes_max(rhs_bytes, lhs_bytes);
 
                     fprintf(codegen->out, "    pop %%rcx\n");
                     fprintf(
@@ -371,19 +495,30 @@ codegen_linux_x86_64_emit_expression(codegen_x86_64_t *codegen, ast_node_t *expr
                         get_reg_for(REG_ACCUMULATOR, expr_bytes)
                     );
                     fprintf(codegen->out, "    setne %%al\n");
-                    fprintf(codegen->out, "    movzb %%al, %s\n", get_reg_for(REG_ACCUMULATOR, expr_bytes));
+                    fprintf(
+                        codegen->out,
+                        "    movzb %%al, %s\n",
+                        get_reg_for(REG_ACCUMULATOR, expr_bytes)
+                    );
 
                     return expr_bytes;
                 }
                 case AST_BINOP_CMP_LEQ: {
                     fprintf(codegen->out, "    xor %%rax, %%rax\n");
-                    size_in_bytes_t rhs_bytes = codegen_linux_x86_64_emit_expression(codegen, bin_op.rhs);
+                    size_in_bytes_t rhs_bytes =
+                        codegen_linux_x86_64_emit_expression(
+                            codegen, bin_op.rhs
+                        );
                     fprintf(codegen->out, "    push %%rax\n");
 
                     fprintf(codegen->out, "    xor %%rax, %%rax\n");
-                    size_in_bytes_t lhs_bytes = codegen_linux_x86_64_emit_expression(codegen, bin_op.lhs);
+                    size_in_bytes_t lhs_bytes =
+                        codegen_linux_x86_64_emit_expression(
+                            codegen, bin_op.lhs
+                        );
 
-                    size_in_bytes_t expr_bytes = bytes_max(rhs_bytes, lhs_bytes);
+                    size_in_bytes_t expr_bytes =
+                        bytes_max(rhs_bytes, lhs_bytes);
 
                     fprintf(codegen->out, "    pop %%rcx\n");
                     fprintf(
@@ -393,19 +528,30 @@ codegen_linux_x86_64_emit_expression(codegen_x86_64_t *codegen, ast_node_t *expr
                         get_reg_for(REG_ACCUMULATOR, expr_bytes)
                     );
                     fprintf(codegen->out, "    setle %%al\n");
-                    fprintf(codegen->out, "    movzb %%al, %s\n", get_reg_for(REG_ACCUMULATOR, expr_bytes));
+                    fprintf(
+                        codegen->out,
+                        "    movzb %%al, %s\n",
+                        get_reg_for(REG_ACCUMULATOR, expr_bytes)
+                    );
 
                     return expr_bytes;
                 }
                 case AST_BINOP_CMP_GEQ: {
                     fprintf(codegen->out, "    xor %%rax, %%rax\n");
-                    size_in_bytes_t rhs_bytes = codegen_linux_x86_64_emit_expression(codegen, bin_op.rhs);
+                    size_in_bytes_t rhs_bytes =
+                        codegen_linux_x86_64_emit_expression(
+                            codegen, bin_op.rhs
+                        );
                     fprintf(codegen->out, "    push %%rax\n");
 
                     fprintf(codegen->out, "    xor %%rax, %%rax\n");
-                    size_in_bytes_t lhs_bytes = codegen_linux_x86_64_emit_expression(codegen, bin_op.lhs);
+                    size_in_bytes_t lhs_bytes =
+                        codegen_linux_x86_64_emit_expression(
+                            codegen, bin_op.lhs
+                        );
 
-                    size_in_bytes_t expr_bytes = bytes_max(rhs_bytes, lhs_bytes);
+                    size_in_bytes_t expr_bytes =
+                        bytes_max(rhs_bytes, lhs_bytes);
 
                     fprintf(codegen->out, "    pop %%rcx\n");
                     fprintf(
@@ -415,7 +561,11 @@ codegen_linux_x86_64_emit_expression(codegen_x86_64_t *codegen, ast_node_t *expr
                         get_reg_for(REG_ACCUMULATOR, expr_bytes)
                     );
                     fprintf(codegen->out, "    setge %%al\n");
-                    fprintf(codegen->out, "    movzb %%al, %s\n", get_reg_for(REG_ACCUMULATOR, expr_bytes));
+                    fprintf(
+                        codegen->out,
+                        "    movzb %%al, %s\n",
+                        get_reg_for(REG_ACCUMULATOR, expr_bytes)
+                    );
 
                     return expr_bytes;
                 }
@@ -425,10 +575,17 @@ codegen_linux_x86_64_emit_expression(codegen_x86_64_t *codegen, ast_node_t *expr
                     fprintf(codegen->out, "    push %%rax\n");
 
                     fprintf(codegen->out, "    xor %%rax, %%rax\n");
-                    size_in_bytes_t lhs_bytes = codegen_linux_x86_64_emit_expression(codegen, bin_op.lhs);
+                    size_in_bytes_t lhs_bytes =
+                        codegen_linux_x86_64_emit_expression(
+                            codegen, bin_op.lhs
+                        );
 
                     fprintf(codegen->out, "    pop %%rcx\n");
-                    fprintf(codegen->out, "    shl %%cl, %s\n", get_reg_for(REG_ACCUMULATOR, lhs_bytes));
+                    fprintf(
+                        codegen->out,
+                        "    shl %%cl, %s\n",
+                        get_reg_for(REG_ACCUMULATOR, lhs_bytes)
+                    );
 
                     return lhs_bytes;
                 }
@@ -438,22 +595,36 @@ codegen_linux_x86_64_emit_expression(codegen_x86_64_t *codegen, ast_node_t *expr
                     fprintf(codegen->out, "    push %%rax\n");
 
                     fprintf(codegen->out, "    xor %%rax, %%rax\n");
-                    size_in_bytes_t lhs_bytes = codegen_linux_x86_64_emit_expression(codegen, bin_op.lhs);
+                    size_in_bytes_t lhs_bytes =
+                        codegen_linux_x86_64_emit_expression(
+                            codegen, bin_op.lhs
+                        );
 
                     fprintf(codegen->out, "    pop %%rcx\n");
-                    fprintf(codegen->out, "    shr %%cl, %s\n", get_reg_for(REG_ACCUMULATOR, lhs_bytes));
+                    fprintf(
+                        codegen->out,
+                        "    shr %%cl, %s\n",
+                        get_reg_for(REG_ACCUMULATOR, lhs_bytes)
+                    );
 
                     return lhs_bytes;
                 }
                 case AST_BINOP_BITWISE_XOR: {
                     fprintf(codegen->out, "    xor %%rax, %%rax\n");
-                    size_in_bytes_t rhs_bytes = codegen_linux_x86_64_emit_expression(codegen, bin_op.rhs);
+                    size_in_bytes_t rhs_bytes =
+                        codegen_linux_x86_64_emit_expression(
+                            codegen, bin_op.rhs
+                        );
                     fprintf(codegen->out, "    push %%rax\n");
 
                     fprintf(codegen->out, "    xor %%rax, %%rax\n");
-                    size_in_bytes_t lhs_bytes = codegen_linux_x86_64_emit_expression(codegen, bin_op.lhs);
+                    size_in_bytes_t lhs_bytes =
+                        codegen_linux_x86_64_emit_expression(
+                            codegen, bin_op.lhs
+                        );
 
-                    size_in_bytes_t expr_bytes = bytes_max(rhs_bytes, lhs_bytes);
+                    size_in_bytes_t expr_bytes =
+                        bytes_max(rhs_bytes, lhs_bytes);
 
                     fprintf(codegen->out, "    pop %%rcx\n");
                     fprintf(
@@ -467,13 +638,20 @@ codegen_linux_x86_64_emit_expression(codegen_x86_64_t *codegen, ast_node_t *expr
                 }
                 case AST_BINOP_BITWISE_AND: {
                     fprintf(codegen->out, "    xor %%rax, %%rax\n");
-                    size_in_bytes_t rhs_bytes = codegen_linux_x86_64_emit_expression(codegen, bin_op.rhs);
+                    size_in_bytes_t rhs_bytes =
+                        codegen_linux_x86_64_emit_expression(
+                            codegen, bin_op.rhs
+                        );
                     fprintf(codegen->out, "    push %%rax\n");
 
                     fprintf(codegen->out, "    xor %%rax, %%rax\n");
-                    size_in_bytes_t lhs_bytes = codegen_linux_x86_64_emit_expression(codegen, bin_op.lhs);
+                    size_in_bytes_t lhs_bytes =
+                        codegen_linux_x86_64_emit_expression(
+                            codegen, bin_op.lhs
+                        );
 
-                    size_in_bytes_t expr_bytes = bytes_max(rhs_bytes, lhs_bytes);
+                    size_in_bytes_t expr_bytes =
+                        bytes_max(rhs_bytes, lhs_bytes);
 
                     fprintf(codegen->out, "    pop %%rcx\n");
                     fprintf(
@@ -487,13 +665,20 @@ codegen_linux_x86_64_emit_expression(codegen_x86_64_t *codegen, ast_node_t *expr
                 }
                 case AST_BINOP_BITWISE_OR: {
                     fprintf(codegen->out, "    xor %%rax, %%rax\n");
-                    size_in_bytes_t rhs_bytes = codegen_linux_x86_64_emit_expression(codegen, bin_op.rhs);
+                    size_in_bytes_t rhs_bytes =
+                        codegen_linux_x86_64_emit_expression(
+                            codegen, bin_op.rhs
+                        );
                     fprintf(codegen->out, "    push %%rax\n");
 
                     fprintf(codegen->out, "    xor %%rax, %%rax\n");
-                    size_in_bytes_t lhs_bytes = codegen_linux_x86_64_emit_expression(codegen, bin_op.lhs);
+                    size_in_bytes_t lhs_bytes =
+                        codegen_linux_x86_64_emit_expression(
+                            codegen, bin_op.lhs
+                        );
 
-                    size_in_bytes_t expr_bytes = bytes_max(rhs_bytes, lhs_bytes);
+                    size_in_bytes_t expr_bytes =
+                        bytes_max(rhs_bytes, lhs_bytes);
 
                     fprintf(codegen->out, "    pop %%rcx\n");
                     fprintf(
@@ -506,16 +691,31 @@ codegen_linux_x86_64_emit_expression(codegen_x86_64_t *codegen, ast_node_t *expr
                     return expr_bytes;
                 }
                 case AST_BINOP_LOGICAL_AND: {
-                    size_t label_exit = codegen_linux_x86_64_get_next_label(codegen);
+                    size_t label_exit =
+                        codegen_linux_x86_64_get_next_label(codegen);
 
                     fprintf(codegen->out, "    xor %%rax, %%rax\n");
-                    size_in_bytes_t lhs_bytes = codegen_linux_x86_64_emit_expression(codegen, bin_op.lhs);
-                    fprintf(codegen->out, "    cmp $0, %s\n", get_reg_for(REG_ACCUMULATOR, lhs_bytes));
+                    size_in_bytes_t lhs_bytes =
+                        codegen_linux_x86_64_emit_expression(
+                            codegen, bin_op.lhs
+                        );
+                    fprintf(
+                        codegen->out,
+                        "    cmp $0, %s\n",
+                        get_reg_for(REG_ACCUMULATOR, lhs_bytes)
+                    );
                     fprintf(codegen->out, "    je .L%ld\n", label_exit);
 
                     fprintf(codegen->out, "    xor %%rax, %%rax\n");
-                    size_in_bytes_t rhs_bytes = codegen_linux_x86_64_emit_expression(codegen, bin_op.rhs);
-                    fprintf(codegen->out, "    cmp $0, %s\n", get_reg_for(REG_ACCUMULATOR, rhs_bytes));
+                    size_in_bytes_t rhs_bytes =
+                        codegen_linux_x86_64_emit_expression(
+                            codegen, bin_op.rhs
+                        );
+                    fprintf(
+                        codegen->out,
+                        "    cmp $0, %s\n",
+                        get_reg_for(REG_ACCUMULATOR, rhs_bytes)
+                    );
                     fprintf(codegen->out, "    je .L%ld\n", label_exit);
                     fprintf(codegen->out, "    mov $1, %%rax\n");
                     fprintf(codegen->out, ".L%ld:\n", label_exit);
@@ -523,17 +723,33 @@ codegen_linux_x86_64_emit_expression(codegen_x86_64_t *codegen, ast_node_t *expr
                     return 1;
                 }
                 case AST_BINOP_LOGICAL_OR: {
-                    size_t label_t = codegen_linux_x86_64_get_next_label(codegen);
-                    size_t label_f = codegen_linux_x86_64_get_next_label(codegen);
+                    size_t label_t =
+                        codegen_linux_x86_64_get_next_label(codegen);
+                    size_t label_f =
+                        codegen_linux_x86_64_get_next_label(codegen);
 
                     fprintf(codegen->out, "    xor %%rax, %%rax\n");
-                    size_in_bytes_t lhs_bytes = codegen_linux_x86_64_emit_expression(codegen, bin_op.lhs);
-                    fprintf(codegen->out, "    cmp $0, %s\n", get_reg_for(REG_ACCUMULATOR, lhs_bytes));
+                    size_in_bytes_t lhs_bytes =
+                        codegen_linux_x86_64_emit_expression(
+                            codegen, bin_op.lhs
+                        );
+                    fprintf(
+                        codegen->out,
+                        "    cmp $0, %s\n",
+                        get_reg_for(REG_ACCUMULATOR, lhs_bytes)
+                    );
                     fprintf(codegen->out, "    jne .L%ld\n", label_t);
 
                     fprintf(codegen->out, "    xor %%rax, %%rax\n");
-                    size_in_bytes_t rhs_bytes = codegen_linux_x86_64_emit_expression(codegen, bin_op.rhs);
-                    fprintf(codegen->out, "    cmp $0, %s\n", get_reg_for(REG_ACCUMULATOR, rhs_bytes));
+                    size_in_bytes_t rhs_bytes =
+                        codegen_linux_x86_64_emit_expression(
+                            codegen, bin_op.rhs
+                        );
+                    fprintf(
+                        codegen->out,
+                        "    cmp $0, %s\n",
+                        get_reg_for(REG_ACCUMULATOR, rhs_bytes)
+                    );
                     fprintf(codegen->out, "    je .L%ld\n", label_f);
 
                     fprintf(codegen->out, ".L%ld:\n", label_t);
@@ -553,9 +769,16 @@ codegen_linux_x86_64_emit_expression(codegen_x86_64_t *codegen, ast_node_t *expr
             ast_unary_op_t unary_op = expr_node->as_unary_op;
             switch (unary_op.kind) {
                 case AST_UNARY_BITWISE_NOT: {
-                    size_in_bytes_t expr_bytes = codegen_linux_x86_64_emit_expression(codegen, unary_op.expr);
+                    size_in_bytes_t expr_bytes =
+                        codegen_linux_x86_64_emit_expression(
+                            codegen, unary_op.expr
+                        );
 
-                    fprintf(codegen->out, "    not %s\n", get_reg_for(REG_ACCUMULATOR, expr_bytes));
+                    fprintf(
+                        codegen->out,
+                        "    not %s\n",
+                        get_reg_for(REG_ACCUMULATOR, expr_bytes)
+                    );
 
                     return expr_bytes;
                 }
@@ -599,10 +822,14 @@ codegen_linux_x86_64_emit_block(codegen_x86_64_t *codegen, ast_block_t *block) {
                 symbol_t *symbol = scope_lookup(scope, var_def.id);
                 assert(symbol);
 
-                codegen_linux_x86_64_put_stack_offset(codegen, symbol, codegen->base_offset);
+                codegen_linux_x86_64_put_stack_offset(
+                    codegen, symbol, codegen->base_offset
+                );
 
                 if (var_def.value) {
-                    codegen_linux_x86_64_emit_expression(codegen, var_def.value);
+                    codegen_linux_x86_64_emit_expression(
+                        codegen, var_def.value
+                    );
                 }
 
                 size_t type_size = type_to_bytes(symbol->type);
@@ -626,12 +853,18 @@ codegen_linux_x86_64_emit_block(codegen_x86_64_t *codegen, ast_block_t *block) {
                 symbol_t *symbol = scope_lookup(scope, ref.id);
                 assert(symbol);
 
-                size_t offset = codegen_linux_x86_64_get_stack_offset(codegen, symbol);
+                size_t offset =
+                    codegen_linux_x86_64_get_stack_offset(codegen, symbol);
 
                 codegen_linux_x86_64_emit_expression(codegen, var_assign.expr);
 
                 size_t type_size = type_to_bytes(symbol->type);
-                fprintf(codegen->out, "    mov %s, -%ld(%%rbp)\n", get_reg_for(REG_ACCUMULATOR, type_size), offset);
+                fprintf(
+                    codegen->out,
+                    "    mov %s, -%ld(%%rbp)\n",
+                    get_reg_for(REG_ACCUMULATOR, type_size),
+                    offset
+                );
 
                 break;
             }
@@ -647,7 +880,8 @@ codegen_linux_x86_64_emit_block(codegen_x86_64_t *codegen, ast_block_t *block) {
                 ast_node_t *cond = while_stmt.cond;
                 ast_node_t *then = while_stmt.then;
 
-                size_t begin_label = codegen_linux_x86_64_get_next_label(codegen);
+                size_t begin_label =
+                    codegen_linux_x86_64_get_next_label(codegen);
                 size_t end_label = codegen_linux_x86_64_get_next_label(codegen);
 
                 fprintf(codegen->out, ".L%ld:\n", begin_label);
@@ -655,7 +889,9 @@ codegen_linux_x86_64_emit_block(codegen_x86_64_t *codegen, ast_block_t *block) {
                 fprintf(codegen->out, "    cmp $1, %%rax\n");
                 fprintf(codegen->out, "    jnz .L%ld\n", end_label);
 
-                assert(then->kind == AST_NODE_BLOCK && "invalid while-then block");
+                assert(
+                    then->kind == AST_NODE_BLOCK && "invalid while-then block"
+                );
                 ast_block_t then_block = then->as_block;
 
                 codegen_linux_x86_64_emit_block(codegen, &then_block);
@@ -754,7 +990,8 @@ calculate_fn_local_size(scope_t *scope) {
     list_item_t *item = list_head(scope->children);
 
     while (item != NULL) {
-        size_t child_local_size = calculate_fn_local_size((scope_t *)item->value);
+        size_t child_local_size =
+            calculate_fn_local_size((scope_t *)item->value);
 
         if (child_local_size > max_child_local_size) {
             max_child_local_size = child_local_size;
@@ -767,7 +1004,10 @@ calculate_fn_local_size(scope_t *scope) {
 }
 
 static void
-codegen_linux_x86_64_emit_function(codegen_x86_64_t *codegen, ast_fn_definition_t *fn_def) {
+codegen_linux_x86_64_emit_function(
+    codegen_x86_64_t *codegen,
+    ast_fn_definition_t *fn_def
+) {
     codegen->base_offset = X86_CALL_EIP_STACK_OFFSET;
 
     ast_node_t *block_node = fn_def->block;
@@ -777,7 +1017,8 @@ codegen_linux_x86_64_emit_function(codegen_x86_64_t *codegen, ast_fn_definition_
     fprintf(codegen->out, "    mov %%rsp, %%rbp\n");
 
     size_t i = 0;
-    for (list_item_t *item = list_head(fn_def->params); item != NULL; item = list_next(item)) {
+    for (list_item_t *item = list_head(fn_def->params); item != NULL;
+         item = list_next(item)) {
         assert(i < X86_CALL_ARG_SIZE);
 
         ast_fn_param_t *param = item->value;
@@ -787,7 +1028,9 @@ codegen_linux_x86_64_emit_function(codegen_x86_64_t *codegen, ast_fn_definition_
 
         size_t offset = codegen->base_offset;
 
-        codegen_linux_x86_64_put_stack_offset(codegen, symbol, codegen->base_offset);
+        codegen_linux_x86_64_put_stack_offset(
+            codegen, symbol, codegen->base_offset
+        );
 
         fprintf(
             codegen->out,
@@ -815,7 +1058,11 @@ codegen_linux_x86_64_emit_function(codegen_x86_64_t *codegen, ast_fn_definition_
 }
 
 static void
-codegen_linux_x86_64_put_stack_offset(codegen_x86_64_t *codegen, symbol_t *symbol, size_t offset) {
+codegen_linux_x86_64_put_stack_offset(
+    codegen_x86_64_t *codegen,
+    symbol_t *symbol,
+    size_t offset
+) {
     size_t *stack_offset = arena_alloc(codegen->arena, sizeof(size_t));
     *stack_offset = offset;
 
@@ -826,7 +1073,10 @@ codegen_linux_x86_64_put_stack_offset(codegen_x86_64_t *codegen, symbol_t *symbo
 }
 
 static size_t
-codegen_linux_x86_64_get_stack_offset(codegen_x86_64_t *codegen, symbol_t *symbol) {
+codegen_linux_x86_64_get_stack_offset(
+    codegen_x86_64_t *codegen,
+    symbol_t *symbol
+) {
     char symbol_ptr[PTR_HEX_CSTR_SIZE];
     sprintf(symbol_ptr, "%lx", (uintptr_t)symbol);
 
diff --git a/src/codegen_linux_x86_64.h b/src/codegen_linux_x86_64.h
index 3c5a10e..a1de3ab 100644
--- a/src/codegen_linux_x86_64.h
+++ b/src/codegen_linux_x86_64.h
@@ -34,6 +34,9 @@ void
 codegen_linux_x86_64_init(codegen_x86_64_t *codegen, arena_t *arena, FILE *out);
 
 void
-codegen_linux_x86_64_emit_translation_unit(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/lexer.c b/src/lexer.c
index c11bacf..633f0ed 100644
--- a/src/lexer.c
+++ b/src/lexer.c
@@ -49,7 +49,12 @@ static void
 lexer_init_char_value_token(lexer_t *lexer, token_t *token, token_kind_t kind);
 
 static void
-lexer_init_str_value_token(lexer_t *lexer, token_t *token, token_kind_t kind, lexer_cursor_t cur);
+lexer_init_str_value_token(
+    lexer_t *lexer,
+    token_t *token,
+    token_kind_t kind,
+    lexer_cursor_t cur
+);
 
 static void
 lexer_init_eof_token(lexer_t *lexer, token_t *token);
@@ -93,7 +98,9 @@ lexer_next_token(lexer_t *lexer, token_t *token) {
                 .size = lexer->cur.offset - start_cur.offset,
             };
 
-            lexer_init_str_value_token(lexer, token, lexer_str_to_token_kind(text), start_cur);
+            lexer_init_str_value_token(
+                lexer, token, lexer_str_to_token_kind(text), start_cur
+            );
             return;
         }
 
@@ -115,7 +122,9 @@ lexer_next_token(lexer_t *lexer, token_t *token) {
 
                 if (lexer_current_char(lexer) == '=') {
                     lexer_skip_char(lexer);
-                    lexer_init_str_value_token(lexer, token, TOKEN_CMP_EQ, start_cur);
+                    lexer_init_str_value_token(
+                        lexer, token, TOKEN_CMP_EQ, start_cur
+                    );
                     return;
                 }
 
@@ -128,7 +137,9 @@ lexer_next_token(lexer_t *lexer, token_t *token) {
 
                 if (lexer_current_char(lexer) == '=') {
                     lexer_skip_char(lexer);
-                    lexer_init_str_value_token(lexer, token, TOKEN_CMP_NEQ, start_cur);
+                    lexer_init_str_value_token(
+                        lexer, token, TOKEN_CMP_NEQ, start_cur
+                    );
                     return;
                 }
 
@@ -141,7 +152,9 @@ lexer_next_token(lexer_t *lexer, token_t *token) {
 
                 if (lexer_current_char(lexer) == '&') {
                     lexer_skip_char(lexer);
-                    lexer_init_str_value_token(lexer, token, TOKEN_LOGICAL_AND, start_cur);
+                    lexer_init_str_value_token(
+                        lexer, token, TOKEN_LOGICAL_AND, start_cur
+                    );
                     return;
                 }
 
@@ -154,7 +167,9 @@ lexer_next_token(lexer_t *lexer, token_t *token) {
 
                 if (lexer_current_char(lexer) == '|') {
                     lexer_skip_char(lexer);
-                    lexer_init_str_value_token(lexer, token, TOKEN_LOGICAL_OR, start_cur);
+                    lexer_init_str_value_token(
+                        lexer, token, TOKEN_LOGICAL_OR, start_cur
+                    );
                     return;
                 }
 
@@ -168,16 +183,22 @@ lexer_next_token(lexer_t *lexer, token_t *token) {
                 switch (lexer_current_char(lexer)) {
                     case '<': {
                         lexer_skip_char(lexer);
-                        lexer_init_str_value_token(lexer, token, TOKEN_BITWISE_LSHIFT, start_cur);
+                        lexer_init_str_value_token(
+                            lexer, token, TOKEN_BITWISE_LSHIFT, start_cur
+                        );
                         return;
                     }
                     case '=': {
                         lexer_skip_char(lexer);
-                        lexer_init_str_value_token(lexer, token, TOKEN_CMP_LEQ, start_cur);
+                        lexer_init_str_value_token(
+                            lexer, token, TOKEN_CMP_LEQ, start_cur
+                        );
                         return;
                     }
                     default: {
-                        lexer_init_str_value_token(lexer, token, TOKEN_LT, start_cur);
+                        lexer_init_str_value_token(
+                            lexer, token, TOKEN_LT, start_cur
+                        );
                         return;
                     }
                 }
@@ -189,16 +210,22 @@ lexer_next_token(lexer_t *lexer, token_t *token) {
                 switch (lexer_current_char(lexer)) {
                     case '>': {
                         lexer_skip_char(lexer);
-                        lexer_init_str_value_token(lexer, token, TOKEN_BITWISE_RSHIFT, start_cur);
+                        lexer_init_str_value_token(
+                            lexer, token, TOKEN_BITWISE_RSHIFT, start_cur
+                        );
                         return;
                     }
                     case '=': {
                         lexer_skip_char(lexer);
-                        lexer_init_str_value_token(lexer, token, TOKEN_CMP_GEQ, start_cur);
+                        lexer_init_str_value_token(
+                            lexer, token, TOKEN_CMP_GEQ, start_cur
+                        );
                         return;
                     }
                     default: {
-                        lexer_init_str_value_token(lexer, token, TOKEN_GT, start_cur);
+                        lexer_init_str_value_token(
+                            lexer, token, TOKEN_GT, start_cur
+                        );
                         return;
                     }
                 }
@@ -410,7 +437,12 @@ lexer_init_char_value_token(lexer_t *lexer, token_t *token, token_kind_t kind) {
 }
 
 static void
-lexer_init_str_value_token(lexer_t *lexer, token_t *token, token_kind_t kind, lexer_cursor_t cur) {
+lexer_init_str_value_token(
+    lexer_t *lexer,
+    token_t *token,
+    token_kind_t kind,
+    lexer_cursor_t cur
+) {
     string_view_t str = {
         .chars = lexer->src.code.chars + cur.offset,
         .size = lexer->cur.offset - cur.offset,
@@ -493,7 +525,8 @@ token_loc_to_line(token_loc_t loc) {
         .size = 0,
     };
 
-    while ((line.size + offset) < loc.src.code.size && line.chars[line.size] != '\n' && line.chars[line.size] != 0) {
+    while ((line.size + offset) < loc.src.code.size &&
+           line.chars[line.size] != '\n' && line.chars[line.size] != 0) {
         ++line.size;
     }
 
diff --git a/src/main.c b/src/main.c
index 0e174a1..bc2eabf 100644
--- a/src/main.c
+++ b/src/main.c
@@ -154,7 +154,9 @@ handle_codegen_linux(cli_opts_t *opts) {
         } else if (strcmp(opts->arch, "aarch64") == 0) {
             codegen_linux_aarch64_emit_translation_unit(out, ast);
         } else {
-            fprintf(stderr, "error: architecture '%s' not supported\n", opts->arch);
+            fprintf(
+                stderr, "error: architecture '%s' not supported\n", opts->arch
+            );
             cli_print_usage(stderr, opts->compiler_path);
             exit(EXIT_FAILURE);
         }
@@ -167,7 +169,13 @@ handle_codegen_linux(cli_opts_t *opts) {
     }
 
     char command[512];
-    sprintf(command, "%s/bin/as %s -o " SV_FMT ".o", opts->sysroot, asm_file, SV_ARG(opts->output_bin));
+    sprintf(
+        command,
+        "%s/bin/as %s -o " SV_FMT ".o",
+        opts->sysroot,
+        asm_file,
+        SV_ARG(opts->output_bin)
+    );
 
     int exit_code = system(command);
 
@@ -207,7 +215,12 @@ read_entire_file(char *filepath, arena_t *arena) {
     FILE *stream = fopen(filepath, "rb");
 
     if (stream == NULL) {
-        fprintf(stderr, "error: could not open file %s: %s\n", filepath, strerror(errno));
+        fprintf(
+            stderr,
+            "error: could not open file %s: %s\n",
+            filepath,
+            strerror(errno)
+        );
         exit(EXIT_FAILURE);
     }
 
@@ -222,7 +235,12 @@ read_entire_file(char *filepath, arena_t *arena) {
     code.chars = (char *)arena_alloc(arena, (size_t)code.size);
 
     if (code.chars == NULL) {
-        fprintf(stderr, "error: could not read file %s: %s\n", filepath, strerror(errno));
+        fprintf(
+            stderr,
+            "error: could not read file %s: %s\n",
+            filepath,
+            strerror(errno)
+        );
         exit(EXIT_FAILURE);
     }
 
diff --git a/src/map.c b/src/map.c
index 31100b4..0c6ccd6 100644
--- a/src/map.c
+++ b/src/map.c
@@ -41,7 +41,9 @@ map_t *
 map_new(arena_t *arena) {
     map_t *map = (map_t *)arena_alloc(arena, sizeof(map_t));
     if (map == NULL) {
-        fprintf(stderr, "[FATAL] Out of memory: map_new: %s\n", strerror(errno));
+        fprintf(
+            stderr, "[FATAL] Out of memory: map_new: %s\n", strerror(errno)
+        );
         exit(EXIT_FAILURE);
     }
     map->arena = arena;
@@ -52,11 +54,15 @@ map_new(arena_t *arena) {
 static void
 map_init(map_t *map) {
     assert(map);
-    map->entries = (map_entry_t *)arena_alloc(map->arena, MAP_INITIAL_CAPACITY * sizeof(map_entry_t));
+    map->entries = (map_entry_t *)arena_alloc(
+        map->arena, MAP_INITIAL_CAPACITY * sizeof(map_entry_t)
+    );
     assert(map->entries != NULL);
     memset(map->entries, 0, MAP_INITIAL_CAPACITY * sizeof(map_entry_t));
     if (map->entries == NULL) {
-        fprintf(stderr, "[FATAL] Out of memory: map_init: %s\n", strerror(errno));
+        fprintf(
+            stderr, "[FATAL] Out of memory: map_init: %s\n", strerror(errno)
+        );
         exit(EXIT_FAILURE);
     }
     map->capacity = MAP_INITIAL_CAPACITY;
@@ -97,7 +103,8 @@ map_put(map_t *map, char *key, void *value) {
             break;
         }
         if (entry->next == NULL) {
-            entry->next = (map_entry_t *)arena_alloc(map->arena, sizeof(map_entry_t));
+            entry->next =
+                (map_entry_t *)arena_alloc(map->arena, sizeof(map_entry_t));
             *entry->next = (map_entry_t){
                 .key = _strdup(key, map->arena),
                 .hash = hash,
diff --git a/src/parser.c b/src/parser.c
index 385d1a5..29cfbe8 100644
--- a/src/parser.c
+++ b/src/parser.c
@@ -148,7 +148,11 @@ token_kind_to_binary_op_kind(token_kind_t kind) {
         case TOKEN_LOGICAL_OR:
             return AST_BINOP_LOGICAL_OR;
         default: {
-            fprintf(stderr, "error: token kind (%s) not compatible with binary op kind\n", token_kind_to_cstr(kind));
+            fprintf(
+                stderr,
+                "error: token kind (%s) not compatible with binary op kind\n",
+                token_kind_to_cstr(kind)
+            );
             assert(false);
         }
     }
@@ -220,7 +224,9 @@ token_kind_to_unary_op_kind(token_kind_t token_kind) {
         case TOKEN_BANG:
             return AST_UNARY_LOGICAL_NOT;
         default:
-            assert(false && "unable to covert the token_kind_t to unary_op_kind_t");
+            assert(
+                false && "unable to covert the token_kind_t to unary_op_kind_t"
+            );
     }
 }
 
@@ -242,12 +248,21 @@ parser_parse_expr_1(parser_t *parser, ast_node_t *lhs, size_t prev_precedence) {
         lexer_peek_next(parser->lexer, &lookahead_token);
 
         while (token_kind_is_binary_op(lookahead_token.kind) &&
-               get_binary_op_precedence(lookahead_token.kind) > get_binary_op_precedence(token_op.kind)) {
-            rhs = parser_parse_expr_1(parser, rhs, get_binary_op_precedence(token_op.kind));
+               get_binary_op_precedence(lookahead_token.kind) >
+                   get_binary_op_precedence(token_op.kind)) {
+            rhs = parser_parse_expr_1(
+                parser, rhs, get_binary_op_precedence(token_op.kind)
+            );
             lexer_peek_next(parser->lexer, &lookahead_token);
         }
 
-        lhs = ast_new_node_bin_op(parser->arena, token_op.loc, token_kind_to_binary_op_kind(token_op.kind), lhs, rhs);
+        lhs = ast_new_node_bin_op(
+            parser->arena,
+            token_op.loc,
+            token_kind_to_binary_op_kind(token_op.kind),
+            lhs,
+            rhs
+        );
         if (lhs == NULL) {
             return NULL;
         }
@@ -273,7 +288,9 @@ parser_parse_factor(parser_t *parser) {
 
     switch (token.kind) {
         case TOKEN_NUMBER:
-            return ast_new_node_literal_u32(parser->arena, token.loc, string_view_to_u32(token.value));
+            return ast_new_node_literal_u32(
+                parser->arena, token.loc, string_view_to_u32(token.value)
+            );
 
         case TOKEN_ID: {
             token_t token_id = token;
@@ -282,10 +299,14 @@ parser_parse_factor(parser_t *parser) {
 
             if (token.kind == TOKEN_OPAREN) {
                 list_t *args = parser_parse_fn_args(parser);
-                return ast_new_node_fn_call(parser->arena, token_id.loc, token_id.value, args);
+                return ast_new_node_fn_call(
+                    parser->arena, token_id.loc, token_id.value, args
+                );
             }
 
-            return ast_new_node_ref(parser->arena, token_id.loc, token_id.value);
+            return ast_new_node_ref(
+                parser->arena, token_id.loc, token_id.value
+            );
         }
         case TOKEN_AND:
         case TOKEN_STAR:
@@ -315,7 +336,11 @@ parser_parse_factor(parser_t *parser) {
             return expr;
         }
         default: {
-            fprintf(stderr, "error: parse_factor: unsupported or invalid token (%s)\n", token_kind_to_cstr(token.kind));
+            fprintf(
+                stderr,
+                "error: parse_factor: unsupported or invalid token (%s)\n",
+                token_kind_to_cstr(token.kind)
+            );
             assert(false);
         }
     }
@@ -329,7 +354,11 @@ parser_parse_fn_args(parser_t *parser) {
 
     list_t *args = arena_alloc(parser->arena, sizeof(list_t));
     if (args == NULL) {
-        fprintf(stderr, "[FATAL] Out of memory: parser_parse_fn_args: %s\n", strerror(errno));
+        fprintf(
+            stderr,
+            "[FATAL] Out of memory: parser_parse_fn_args: %s\n",
+            strerror(errno)
+        );
         exit(EXIT_FAILURE);
     }
 
@@ -370,7 +399,11 @@ parser_parse_fn_params(parser_t *parser) {
 
     list_t *params = arena_alloc(parser->arena, sizeof(list_t));
     if (params == NULL) {
-        fprintf(stderr, "[FATAL] Out of memory: parser_parse_fn_params: %s\n", strerror(errno));
+        fprintf(
+            stderr,
+            "[FATAL] Out of memory: parser_parse_fn_params: %s\n",
+            strerror(errno)
+        );
         exit(EXIT_FAILURE);
     }
 
@@ -398,7 +431,8 @@ parser_parse_fn_params(parser_t *parser) {
             return NULL;
         }
 
-        ast_fn_param_t *param = ast_new_fn_param(parser->arena, token.value, type);
+        ast_fn_param_t *param =
+            ast_new_fn_param(parser->arena, token.value, type);
         list_append(params, param);
 
         skip_line_feeds(parser->lexer);
@@ -447,7 +481,14 @@ parser_parse_fn_definition(parser_t *parser) {
         return NULL;
     }
 
-    return ast_new_node_fn_def(parser->arena, fn_name_token.loc, fn_name_token.value, params, ret_type, block);
+    return ast_new_node_fn_def(
+        parser->arena,
+        fn_name_token.loc,
+        fn_name_token.value,
+        params,
+        ret_type,
+        block
+    );
 }
 
 static type_t *
@@ -478,7 +519,8 @@ parser_parse_type(parser_t *parser) {
         }
         string_view_t ptr_id = token.value;
 
-        ptr_id.size = ptr_token.value.chars - token.value.chars + ptr_token.value.size;
+        ptr_id.size =
+            ptr_token.value.chars - token.value.chars + ptr_token.value.size;
 
         return type_new_ptr(parser->arena, ptr_id, type);
     }
@@ -574,7 +616,8 @@ parser_parse_return_stmt(parser_t *parser) {
         return NULL;
     }
 
-    ast_node_t *node_return_stmt = ast_new_node_return_stmt(parser->arena, token_ret.loc, expr);
+    ast_node_t *node_return_stmt =
+        ast_new_node_return_stmt(parser->arena, token_ret.loc, expr);
     assert(node_return_stmt);
 
     return node_return_stmt;
@@ -624,7 +667,8 @@ parser_parse_if_stmt(parser_t *parser) {
         }
     }
 
-    ast_node_t *node_if_stmt = ast_new_node_if_stmt(parser->arena, token_if.loc, cond, then, _else);
+    ast_node_t *node_if_stmt =
+        ast_new_node_if_stmt(parser->arena, token_if.loc, cond, then, _else);
 
     assert(node_if_stmt);
 
@@ -655,7 +699,8 @@ parser_parse_while_stmt(parser_t *parser) {
     token_t next_token;
     peek_next_non_lf_token(parser->lexer, &next_token);
 
-    ast_node_t *node_while_stmt = ast_new_node_while_stmt(parser->arena, token_while.loc, cond, then);
+    ast_node_t *node_while_stmt =
+        ast_new_node_while_stmt(parser->arena, token_while.loc, cond, then);
 
     assert(node_while_stmt);
 
@@ -688,7 +733,9 @@ parser_parse_var_def(parser_t *parser) {
         return NULL;
     }
 
-    ast_node_t *var_node = ast_new_node_var_def(parser->arena, token_id.loc, token_id.value, type, expr);
+    ast_node_t *var_node = ast_new_node_var_def(
+        parser->arena, token_id.loc, token_id.value, type, expr
+    );
 
     return var_node;
 }
@@ -707,7 +754,8 @@ parser_parse_var_assign_stmt(parser_t *parser) {
         return NULL;
     }
 
-    ast_node_t *ref = ast_new_node_ref(parser->arena, token_id.loc, token_id.value);
+    ast_node_t *ref =
+        ast_new_node_ref(parser->arena, token_id.loc, token_id.value);
     ast_node_t *expr = parser_parse_expr(parser);
 
     return ast_new_node_var_assign_stmt(parser->arena, token_eq.loc, ref, expr);
@@ -720,7 +768,11 @@ skip_expected_token(parser_t *parser, token_kind_t expected_kind) {
 }
 
 static bool
-expected_next_token(parser_t *parser, token_t *token, token_kind_t expected_kind) {
+expected_next_token(
+    parser_t *parser,
+    token_t *token,
+    token_kind_t expected_kind
+) {
     lexer_next_token(parser->lexer, token);
     return expected_token(token, expected_kind);
 }
@@ -730,7 +782,8 @@ expected_token(token_t *token, token_kind_t expected_kind) {
     if (token->kind != expected_kind) {
         fprintf(
             stderr,
-            "%s:%lu:%lu: syntax error: got '" SV_FMT "' token but expect '%s'\n",
+            "%s:%lu:%lu: syntax error: got '" SV_FMT
+            "' token but expect '%s'\n",
             token->loc.src.filepath,
             token_loc_to_lineno(token->loc),
             token_loc_to_colno(token->loc),
diff --git a/src/pretty_print_ast.c b/src/pretty_print_ast.c
index 38199ed..c694f82 100644
--- a/src/pretty_print_ast.c
+++ b/src/pretty_print_ast.c
@@ -76,7 +76,12 @@ pretty_print_print_ident(uint64_t *prefix, size_t level, bool lst_children) {
 }
 
 static void
-pretty_print_tree(pretty_print_node_t *node, uint64_t *prefix, size_t level, bool lst_children) {
+pretty_print_tree(
+    pretty_print_node_t *node,
+    uint64_t *prefix,
+    size_t level,
+    bool lst_children
+) {
     pretty_print_print_ident(prefix, level, lst_children);
 
     list_t *list = node->children;
@@ -89,14 +94,16 @@ pretty_print_tree(pretty_print_node_t *node, uint64_t *prefix, size_t level, boo
 
     size_t size = list_size(list);
     for (size_t i = 0; i < size; ++i) {
-        pretty_print_node_t *it = (pretty_print_node_t *)list_get(list, i)->value;
+        pretty_print_node_t *it =
+            (pretty_print_node_t *)list_get(list, i)->value;
         pretty_print_tree(it, prefix, level + 1, i + 1 == size);
     }
 }
 
 static pretty_print_node_t *
 pretty_print_node_new(arena_t *arena) {
-    pretty_print_node_t *node = (pretty_print_node_t *)arena_alloc(arena, sizeof(pretty_print_node_t));
+    pretty_print_node_t *node =
+        (pretty_print_node_t *)arena_alloc(arena, sizeof(pretty_print_node_t));
     node->children = (list_t *)arena_alloc(arena, sizeof(list_t));
     list_init(node->children, arena);
     return node;
@@ -106,7 +113,12 @@ static pretty_print_node_t *
 pretty_print_new_fn_param(ast_fn_param_t *param, arena_t *arena) {
     pretty_print_node_t *node = pretty_print_node_new(arena);
     char name[256];
-    sprintf(name, "Param_Definition <name:" SV_FMT "> <type:" SV_FMT ">", SV_ARG(param->id), SV_ARG(param->type->id));
+    sprintf(
+        name,
+        "Param_Definition <name:" SV_FMT "> <type:" SV_FMT ">",
+        SV_ARG(param->id),
+        SV_ARG(param->type->id)
+    );
     node->name = (char *)arena_alloc(arena, sizeof(char) * (strlen(name) + 1));
     strcpy(node->name, name);
     return node;
@@ -124,7 +136,8 @@ ast_node_to_pretty_print_node(ast_node_t *ast, arena_t *arena) {
             while (item != NULL) {
                 ast_node_t *decl = (ast_node_t *)item->value;
 
-                pretty_print_node_t *fn_node = ast_node_to_pretty_print_node(decl, arena);
+                pretty_print_node_t *fn_node =
+                    ast_node_to_pretty_print_node(decl, arena);
                 list_append(node->children, fn_node);
 
                 item = list_next(item);
@@ -143,16 +156,21 @@ ast_node_to_pretty_print_node(ast_node_t *ast, arena_t *arena) {
                 SV_ARG(fn_def.id),
                 SV_ARG(fn_def.return_type->id)
             );
-            node->name = (char *)arena_alloc(arena, sizeof(char) * (strlen(name) + 1));
+            node->name =
+                (char *)arena_alloc(arena, sizeof(char) * (strlen(name) + 1));
             strcpy(node->name, name);
 
             list_item_t *param = list_head(fn_def.params);
             while (param != NULL) {
-                list_append(node->children, pretty_print_new_fn_param(param->value, arena));
+                list_append(
+                    node->children,
+                    pretty_print_new_fn_param(param->value, arena)
+                );
                 param = list_next(param);
             }
 
-            pretty_print_node_t *block = ast_node_to_pretty_print_node(fn_def.block, arena);
+            pretty_print_node_t *block =
+                ast_node_to_pretty_print_node(fn_def.block, arena);
             list_append(node->children, block);
             return node;
         }
@@ -161,13 +179,19 @@ ast_node_to_pretty_print_node(ast_node_t *ast, arena_t *arena) {
             ast_fn_call_t fn_call = ast->as_fn_call;
 
             char name[256];
-            sprintf(name, "Function_Call <name:" SV_FMT ">", SV_ARG(fn_call.id));
-            node->name = (char *)arena_alloc(arena, sizeof(char) * (strlen(name) + 1));
+            sprintf(
+                name, "Function_Call <name:" SV_FMT ">", SV_ARG(fn_call.id)
+            );
+            node->name =
+                (char *)arena_alloc(arena, sizeof(char) * (strlen(name) + 1));
             strcpy(node->name, name);
 
             list_item_t *item = list_head(fn_call.args);
             while (item != NULL) {
-                list_append(node->children, ast_node_to_pretty_print_node(item->value, arena));
+                list_append(
+                    node->children,
+                    ast_node_to_pretty_print_node(item->value, arena)
+                );
                 item = list_next(item);
             }
 
@@ -181,8 +205,10 @@ ast_node_to_pretty_print_node(ast_node_t *ast, arena_t *arena) {
 
             size_t block_nodes_size = list_size(block.nodes);
             for (size_t i = 0; i < block_nodes_size; ++i) {
-                ast_node_t *ast_node = (ast_node_t *)list_get(block.nodes, i)->value;
-                pretty_print_node_t *child = ast_node_to_pretty_print_node(ast_node, arena);
+                ast_node_t *ast_node =
+                    (ast_node_t *)list_get(block.nodes, i)->value;
+                pretty_print_node_t *child =
+                    ast_node_to_pretty_print_node(ast_node, arena);
                 list_append(node->children, child);
             }
             return node;
@@ -193,8 +219,10 @@ ast_node_to_pretty_print_node(ast_node_t *ast, arena_t *arena) {
 
             node->name = "Var_Assigment";
 
-            pretty_print_node_t *ref = ast_node_to_pretty_print_node(var_assign_stmt.ref, arena);
-            pretty_print_node_t *expr = ast_node_to_pretty_print_node(var_assign_stmt.expr, arena);
+            pretty_print_node_t *ref =
+                ast_node_to_pretty_print_node(var_assign_stmt.ref, arena);
+            pretty_print_node_t *expr =
+                ast_node_to_pretty_print_node(var_assign_stmt.expr, arena);
 
             list_append(node->children, ref);
             list_append(node->children, expr);
@@ -207,7 +235,8 @@ ast_node_to_pretty_print_node(ast_node_t *ast, arena_t *arena) {
 
             node->name = "Return_Statement";
 
-            pretty_print_node_t *child = ast_node_to_pretty_print_node(return_stmt.expr, arena);
+            pretty_print_node_t *child =
+                ast_node_to_pretty_print_node(return_stmt.expr, arena);
             list_append(node->children, child);
 
             return node;
@@ -218,7 +247,8 @@ ast_node_to_pretty_print_node(ast_node_t *ast, arena_t *arena) {
 
             node->name = "If_Statement";
 
-            pretty_print_node_t *child = ast_node_to_pretty_print_node(if_stmt.cond, arena);
+            pretty_print_node_t *child =
+                ast_node_to_pretty_print_node(if_stmt.cond, arena);
             list_append(node->children, child);
 
             child = ast_node_to_pretty_print_node(if_stmt.then, arena);
@@ -237,7 +267,8 @@ ast_node_to_pretty_print_node(ast_node_t *ast, arena_t *arena) {
 
             node->name = "While_Statement";
 
-            pretty_print_node_t *child = ast_node_to_pretty_print_node(while_stmt.cond, arena);
+            pretty_print_node_t *child =
+                ast_node_to_pretty_print_node(while_stmt.cond, arena);
             list_append(node->children, child);
 
             child = ast_node_to_pretty_print_node(while_stmt.then, arena);
@@ -252,8 +283,12 @@ ast_node_to_pretty_print_node(ast_node_t *ast, arena_t *arena) {
             char name[256];
             switch (literal.kind) {
                 case AST_LITERAL_U32: {
-                    sprintf(name, "Literal <kind:u32> <value:%u>", literal.as_u32);
-                    node->name = (char *)arena_alloc(arena, sizeof(char) * (strlen(name) + 1));
+                    sprintf(
+                        name, "Literal <kind:u32> <value:%u>", literal.as_u32
+                    );
+                    node->name = (char *)arena_alloc(
+                        arena, sizeof(char) * (strlen(name) + 1)
+                    );
                     strcpy(node->name, name);
                     break;
                 }
@@ -268,11 +303,18 @@ ast_node_to_pretty_print_node(ast_node_t *ast, arena_t *arena) {
             ast_var_definition_t var = ast->as_var_def;
 
             char name[256];
-            sprintf(name, "Var_Definition <name:" SV_FMT "> <kind:" SV_FMT ">", SV_ARG(var.id), SV_ARG(var.type->id));
-            node->name = (char *)arena_alloc(arena, sizeof(char) * (strlen(name) + 1));
+            sprintf(
+                name,
+                "Var_Definition <name:" SV_FMT "> <kind:" SV_FMT ">",
+                SV_ARG(var.id),
+                SV_ARG(var.type->id)
+            );
+            node->name =
+                (char *)arena_alloc(arena, sizeof(char) * (strlen(name) + 1));
             strcpy(node->name, name);
 
-            pretty_print_node_t *child = ast_node_to_pretty_print_node(var.value, arena);
+            pretty_print_node_t *child =
+                ast_node_to_pretty_print_node(var.value, arena);
             list_append(node->children, child);
 
             return node;
@@ -283,7 +325,8 @@ ast_node_to_pretty_print_node(ast_node_t *ast, arena_t *arena) {
 
             char name[256];
             sprintf(name, "Reference <name:" SV_FMT ">", SV_ARG(ref.id));
-            node->name = (char *)arena_alloc(arena, sizeof(char) * (strlen(name) + 1));
+            node->name =
+                (char *)arena_alloc(arena, sizeof(char) * (strlen(name) + 1));
             strcpy(node->name, name);
 
             return node;
@@ -369,8 +412,10 @@ ast_node_to_pretty_print_node(ast_node_t *ast, arena_t *arena) {
                     assert(false && "binop not implemented");
             }
 
-            pretty_print_node_t *lhs = ast_node_to_pretty_print_node(binop.lhs, arena);
-            pretty_print_node_t *rhs = ast_node_to_pretty_print_node(binop.rhs, arena);
+            pretty_print_node_t *lhs =
+                ast_node_to_pretty_print_node(binop.lhs, arena);
+            pretty_print_node_t *rhs =
+                ast_node_to_pretty_print_node(binop.rhs, arena);
 
             list_append(node->children, lhs);
             list_append(node->children, rhs);
@@ -391,7 +436,8 @@ ast_node_to_pretty_print_node(ast_node_t *ast, arena_t *arena) {
                     assert(false && "unary operation kind not implemented");
             }
 
-            pretty_print_node_t *expr = ast_node_to_pretty_print_node(unary_op.expr, arena);
+            pretty_print_node_t *expr =
+                ast_node_to_pretty_print_node(unary_op.expr, arena);
             list_append(node->children, expr);
 
             return node;
diff --git a/src/scope.c b/src/scope.c
index 0cc4a74..f793bba 100644
--- a/src/scope.c
+++ b/src/scope.c
@@ -27,7 +27,9 @@ scope_new(arena_t *arena) {
     assert(arena);
     scope_t *scope = (scope_t *)arena_alloc(arena, sizeof(scope_t));
     if (scope == NULL) {
-        fprintf(stderr, "[FATAL] Out of memory: scope_new: %s\n", strerror(errno));
+        fprintf(
+            stderr, "[FATAL] Out of memory: scope_new: %s\n", strerror(errno)
+        );
         exit(EXIT_FAILURE);
     }
     scope->arena = arena;
@@ -37,7 +39,9 @@ scope_new(arena_t *arena) {
     list_t *children = (list_t *)arena_alloc(arena, sizeof(list_t));
 
     if (children == NULL) {
-        fprintf(stderr, "[FATAL] Out of memory: scope_new: %s\n", strerror(errno));
+        fprintf(
+            stderr, "[FATAL] Out of memory: scope_new: %s\n", strerror(errno)
+        );
         exit(EXIT_FAILURE);
     }
 
@@ -52,7 +56,9 @@ symbol_new(arena_t *arena, string_view_t id, type_t *type) {
     assert(arena);
     symbol_t *symbol = (symbol_t *)arena_alloc(arena, sizeof(symbol_t));
     if (symbol == NULL) {
-        fprintf(stderr, "[FATAL] Out of memory: symbol_new: %s\n", strerror(errno));
+        fprintf(
+            stderr, "[FATAL] Out of memory: symbol_new: %s\n", strerror(errno)
+        );
         exit(EXIT_FAILURE);
     }
     symbol->id = id;
diff --git a/tests/unit/arena_test.c b/tests/unit/arena_test.c
index 81553c9..8acf8ec 100644
--- a/tests/unit/arena_test.c
+++ b/tests/unit/arena_test.c
@@ -82,11 +82,27 @@ arena_padding_test(const MunitParameter params[], void *user_data_or_fixture) {
     return MUNIT_OK;
 }
 
-static MunitTest tests[] = { { "/arena_alloc_test", arena_alloc_test, NULL, NULL, MUNIT_TEST_OPTION_NONE, NULL },
-                             { "/arena_padding_test", arena_padding_test, NULL, NULL, MUNIT_TEST_OPTION_NONE, NULL },
-                             { NULL, NULL, NULL, NULL, MUNIT_TEST_OPTION_NONE, NULL } };
-
-static const MunitSuite suite = { "/arena", tests, NULL, 1, MUNIT_SUITE_OPTION_NONE };
+static MunitTest tests[] = {
+    { "/arena_alloc_test",
+      arena_alloc_test,
+      NULL,
+      NULL,
+      MUNIT_TEST_OPTION_NONE,
+      NULL },
+    { "/arena_padding_test",
+      arena_padding_test,
+      NULL,
+      NULL,
+      MUNIT_TEST_OPTION_NONE,
+      NULL },
+    { NULL, NULL, NULL, NULL, MUNIT_TEST_OPTION_NONE, NULL }
+};
+
+static const MunitSuite suite = { "/arena",
+                                  tests,
+                                  NULL,
+                                  1,
+                                  MUNIT_SUITE_OPTION_NONE };
 
 int
 main(int argc, char *argv[]) {
diff --git a/tests/unit/list_test.c b/tests/unit/list_test.c
index fe19a23..f15e16d 100644
--- a/tests/unit/list_test.c
+++ b/tests/unit/list_test.c
@@ -92,12 +92,33 @@ list_next_test(const MunitParameter params[], void *user_data_or_fixture) {
     return MUNIT_OK;
 }
 
-static MunitTest tests[] = { { "/list_append_test", list_append_test, NULL, NULL, MUNIT_TEST_OPTION_NONE, NULL },
-                             { "/list_get_test", list_get_test, NULL, NULL, MUNIT_TEST_OPTION_NONE, NULL },
-                             { "/list_next_test", list_next_test, NULL, NULL, MUNIT_TEST_OPTION_NONE, NULL },
-                             { NULL, NULL, NULL, NULL, MUNIT_TEST_OPTION_NONE, NULL } };
-
-static const MunitSuite suite = { "/list", tests, NULL, 1, MUNIT_SUITE_OPTION_NONE };
+static MunitTest tests[] = {
+    { "/list_append_test",
+      list_append_test,
+      NULL,
+      NULL,
+      MUNIT_TEST_OPTION_NONE,
+      NULL },
+    { "/list_get_test",
+      list_get_test,
+      NULL,
+      NULL,
+      MUNIT_TEST_OPTION_NONE,
+      NULL },
+    { "/list_next_test",
+      list_next_test,
+      NULL,
+      NULL,
+      MUNIT_TEST_OPTION_NONE,
+      NULL },
+    { NULL, NULL, NULL, NULL, MUNIT_TEST_OPTION_NONE, NULL }
+};
+
+static const MunitSuite suite = { "/list",
+                                  tests,
+                                  NULL,
+                                  1,
+                                  MUNIT_SUITE_OPTION_NONE };
 
 int
 main(int argc, char *argv[]) {
diff --git a/tests/unit/map_test.c b/tests/unit/map_test.c
index 15d82ef..b252b7f 100644
--- a/tests/unit/map_test.c
+++ b/tests/unit/map_test.c
@@ -37,7 +37,10 @@ test_create_new(const MunitParameter params[], void *user_data_or_fixture) {
 }
 
 static MunitResult
-test_map_put_and_get(const MunitParameter params[], void *user_data_or_fixture) {
+test_map_put_and_get(
+    const MunitParameter params[],
+    void *user_data_or_fixture
+) {
     arena_t arena = arena_new(MAP_TEST_ARENA_CAPACITY);
     map_t *map = map_new(&arena);
 
@@ -89,12 +92,26 @@ test_map_get_kvs(const MunitParameter params[], void *user_data_or_fixture) {
 }
 
 static MunitTest tests[] = {
-    { "/test_create_new", test_create_new, NULL, NULL, MUNIT_TEST_OPTION_NONE, NULL },
-    { "/test_map_put_and_get", test_map_put_and_get, NULL, NULL, MUNIT_TEST_OPTION_NONE, NULL },
+    { "/test_create_new",
+      test_create_new,
+      NULL,
+      NULL,
+      MUNIT_TEST_OPTION_NONE,
+      NULL },
+    { "/test_map_put_and_get",
+      test_map_put_and_get,
+      NULL,
+      NULL,
+      MUNIT_TEST_OPTION_NONE,
+      NULL },
     { NULL, NULL, NULL, NULL, MUNIT_TEST_OPTION_NONE, NULL }
 };
 
-static const MunitSuite suite = { "/map", tests, NULL, 1, MUNIT_SUITE_OPTION_NONE };
+static const MunitSuite suite = { "/map",
+                                  tests,
+                                  NULL,
+                                  1,
+                                  MUNIT_SUITE_OPTION_NONE };
 
 int
 main(int argc, char *argv[]) {
diff --git a/tests/unit/string_view_test.c b/tests/unit/string_view_test.c
index 6f42e0c..f5a962d 100644
--- a/tests/unit/string_view_test.c
+++ b/tests/unit/string_view_test.c
@@ -22,7 +22,10 @@
 #include <string.h>
 
 static MunitResult
-string_view_eq_to_cstr_test(const MunitParameter params[], void *user_data_or_fixture) {
+string_view_eq_to_cstr_test(
+    const MunitParameter params[],
+    void *user_data_or_fixture
+) {
     char *name = "John Doe";
 
     string_view_t str = {
@@ -45,7 +48,10 @@ string_view_eq_to_cstr_test(const MunitParameter params[], void *user_data_or_fi
 }
 
 static MunitResult
-string_view_to_u32_test(const MunitParameter params[], void *user_data_or_fixture) {
+string_view_to_u32_test(
+    const MunitParameter params[],
+    void *user_data_or_fixture
+) {
     char *number = "69";
 
     string_view_t str = {
@@ -66,12 +72,26 @@ string_view_to_u32_test(const MunitParameter params[], void *user_data_or_fixtur
 }
 
 static MunitTest tests[] = {
-    { "/eq_to_cstr_test", string_view_eq_to_cstr_test, NULL, NULL, MUNIT_TEST_OPTION_NONE, NULL },
-    { "/to_u32_test", string_view_to_u32_test, NULL, NULL, MUNIT_TEST_OPTION_NONE, NULL },
+    { "/eq_to_cstr_test",
+      string_view_eq_to_cstr_test,
+      NULL,
+      NULL,
+      MUNIT_TEST_OPTION_NONE,
+      NULL },
+    { "/to_u32_test",
+      string_view_to_u32_test,
+      NULL,
+      NULL,
+      MUNIT_TEST_OPTION_NONE,
+      NULL },
     { NULL, NULL, NULL, NULL, MUNIT_TEST_OPTION_NONE, NULL }
 };
 
-static const MunitSuite suite = { "/string_view", tests, NULL, 1, MUNIT_SUITE_OPTION_NONE };
+static const MunitSuite suite = { "/string_view",
+                                  tests,
+                                  NULL,
+                                  1,
+                                  MUNIT_SUITE_OPTION_NONE };
 
 int
 main(int argc, char *argv[]) {
-- 
2.46.0


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [olang/patches/.build.yml] build success
  2024-10-10  1:33 ` [PATCH olang v1 5/6] codestyle: add trailing comma on struct initializer Carlos Maniero
@ 2024-10-10  1:34   ` builds.sr.ht
  0 siblings, 0 replies; 8+ messages in thread
From: builds.sr.ht @ 2024-10-10  1:34 UTC (permalink / raw)
  To: Carlos Maniero; +Cc: ~johnnyrichard/olang-devel

olang/patches/.build.yml: SUCCESS in 21s

[Suggestions in code style][0] from [Carlos Maniero][1]

[0]: https://lists.sr.ht/~johnnyrichard/olang-devel/patches/55412
[1]: mailto:carlos@maniero.me

✓ #1348097 SUCCESS olang/patches/.build.yml https://builds.sr.ht/~johnnyrichard/job/1348097

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2024-10-10  1:34 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-10-10  1:33 [PATCH olang 0/6] Suggestions in code style Carlos Maniero
2024-10-10  1:33 ` [PATCH olang v1 1/6] codestyle: change AlignAfterOpenBracket to BlockIndent Carlos Maniero
2024-10-10  1:33 ` [PATCH olang v1 2/6] codestyle: never BreakBeforeBraces Carlos Maniero
2024-10-10  1:33 ` [PATCH olang v1 3/6] codestyle: prevent extra empty lines at EOF Carlos Maniero
2024-10-10  1:33 ` [PATCH olang v1 4/6] codestyle: do not allow single line enums Carlos Maniero
2024-10-10  1:33 ` [PATCH olang v1 5/6] codestyle: add trailing comma on struct initializer Carlos Maniero
2024-10-10  1:34   ` [olang/patches/.build.yml] build success builds.sr.ht
2024-10-10  1:33 ` [PATCH olang v1 6/6] codestyle: limit the code to 80 characters Carlos Maniero

Code repositories for project(s) associated with this public inbox

	https://git.johnnyrichard.com/olang.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox