From f8ee7cc66efceab7bf3309d3f495b2ad9fc56e52 Mon Sep 17 00:00:00 2001 From: Jacob Signorovitch Date: Wed, 26 Mar 2025 18:16:13 -0400 Subject: [PATCH] Oh boy do I love formatting. --- src/fnv1a.c | 2 +- src/grammar.y | 3 +-- src/htab.c | 9 +++------ src/include/builtin.h | 4 +--- src/include/htab.h | 5 +++-- src/lexer.c | 8 ++++---- 6 files changed, 13 insertions(+), 18 deletions(-) diff --git a/src/fnv1a.c b/src/fnv1a.c index 3c1b01e..bfef6c9 100644 --- a/src/fnv1a.c +++ b/src/fnv1a.c @@ -2,7 +2,7 @@ #include -uint64_t fnv1a_hash(char *key, size_t ln) { +uint64_t fnv1a_hash(char* key, size_t ln) { uint64_t hash = FNV1A_BASIS_64; for (size_t i = 0; i < ln; i++) { diff --git a/src/grammar.y b/src/grammar.y index ff1d546..5f41658 100644 --- a/src/grammar.y +++ b/src/grammar.y @@ -41,7 +41,7 @@ %token NUM // Number. %token SUB // Subtract -. -%token ADD // Addition *. +%token ADD // Addition *. %token MUL // Multiplication *. %token DIV // Division /. @@ -196,4 +196,3 @@ exp: $$ = ast_init(AST_TYPE_CALL, ast_call_data_init(to, 2, argv)); } %% - diff --git a/src/htab.c b/src/htab.c index f214253..3d2d041 100644 --- a/src/htab.c +++ b/src/htab.c @@ -1,11 +1,10 @@ #include "include/htab.h" #include "include/fnv1a.h" #include "include/util.h" -#include "include/util.h" #include -#include #include +#include HTab* htab_init() { HTab* htab = calloc(1, sizeof(HTab)); @@ -13,9 +12,7 @@ HTab* htab_init() { return htab; } -void htab_destroy(HTab *htab) { - free(htab); -} +void htab_destroy(HTab* htab) { free(htab); } // Get the index of a key. size_t geti(char* key) { @@ -32,7 +29,7 @@ void* htab_get(HTab* htab, char* key) { void htab_ins(HTab* htab, char* key, void* data) { size_t i = geti(key); - //assert((*htab)[i] == NULL); + // assert((*htab)[i] == NULL); (*htab)[i] = data; log_dbgf("Inserted something to hash table @ index %lu", i); } diff --git a/src/include/builtin.h b/src/include/builtin.h index e2f1363..18158a6 100644 --- a/src/include/builtin.h +++ b/src/include/builtin.h @@ -21,8 +21,6 @@ static AST* (*builtin_fns[NBUILTIN_FNS])(size_t argc, AST** argv) = { builtin_sum, builtin_sub, builtin_mul, builtin_div }; -static char* builtin_fns_names[NBUILTIN_FNS] = { - "sum", "sub", "mul", "div" -}; +static char* builtin_fns_names[NBUILTIN_FNS] = {"sum", "sub", "mul", "div"}; #endif diff --git a/src/include/htab.h b/src/include/htab.h index 82cbca9..8b92553 100644 --- a/src/include/htab.h +++ b/src/include/htab.h @@ -5,8 +5,9 @@ #include #define HTAB_FN fnv1a_hash // Function used for hashing. -#define HTAB_SPACE 1024 // Number of entries possible in the hash table; must be - // power of 2. +#define HTAB_SPACE \ + 1024 // Number of entries possible in the hash table; must be + // power of 2. // Hash Table. typedef void* HTab[HTAB_SPACE]; diff --git a/src/lexer.c b/src/lexer.c index 815253e..8ea1be8 100644 --- a/src/lexer.c +++ b/src/lexer.c @@ -112,10 +112,10 @@ int yylex() { case '(': return GROUPS; case ')': return GROUPE; case ',': return SEP; - case ';': return EXPSEP; - case '{': return BLOCKS; - case '}': return BLOCKE; - case '=': return EQ; + case ';': return EXPSEP; + case '{': return BLOCKS; + case '}': return BLOCKE; + case '=': return EQ; default: fprintf(stderr, "Unexpected character: %c\n", c); }