Oh boy do I love formatting.
This commit is contained in:
parent
d699f492fa
commit
f8ee7cc66e
@ -2,7 +2,7 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
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++) {
|
||||
|
@ -41,7 +41,7 @@
|
||||
%token<fval> 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));
|
||||
}
|
||||
%%
|
||||
|
||||
|
@ -1,11 +1,10 @@
|
||||
#include "include/htab.h"
|
||||
#include "include/fnv1a.h"
|
||||
#include "include/util.h"
|
||||
#include "include/util.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
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);
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -5,8 +5,9 @@
|
||||
#include <stdint.h>
|
||||
|
||||
#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];
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user