From dee72dfcc0124be81e338a1d85948b8f1250085d Mon Sep 17 00:00:00 2001 From: c+1 Date: Mon, 2 Oct 2023 13:13:23 -0400 Subject: emalloc(), ecalloc(), erealloc() --- src/include/lexer.h | 3 ++- src/include/token.h | 2 +- src/include/util.h | 8 ++++++-- 3 files changed, 9 insertions(+), 4 deletions(-) (limited to 'src/include') diff --git a/src/include/lexer.h b/src/include/lexer.h index 28d0e6f..8d4f75f 100644 --- a/src/include/lexer.h +++ b/src/include/lexer.h @@ -1,11 +1,12 @@ #ifndef LEXER_H #define LEXER_H +#include "util.h" +#include "syntax.h" #include "token.h" #define LEXER_VALID (lexer->c != '\0' && lexer->i < strlen(lexer->content)) - /* the lexer struct */ typedef struct LEXER_STRUC { /* current character in content */ diff --git a/src/include/token.h b/src/include/token.h index d3dda67..1a307cd 100644 --- a/src/include/token.h +++ b/src/include/token.h @@ -13,7 +13,7 @@ typedef struct TOKEN_STRUC { enum TOKEN_ENUM { TOKEN_KEYWORD, // keyword - TOKEN_PRIM_STR, // 'string' + TOKEN_PRIM_STR, // "string" TOKEN_PRIM_INT, // 42 TOKEN_COMM, // `comment` TOKEN_STMNT_END, // ; diff --git a/src/include/util.h b/src/include/util.h index a2f887b..712af43 100644 --- a/src/include/util.h +++ b/src/include/util.h @@ -18,7 +18,11 @@ void log_raw(const char*, ...); /* log a warning */ void log_war(const char*, ...); -/* does c appear in s? */ -int appears_in_str(char*, char*); +/* if calloc() returns null, die */ +void* ecalloc(size_t, size_t); +/* if malloc() returns null, die */ +void* emalloc(size_t); +/* if realloc() returns null, die */ +void* erealloc(void*, size_t); #endif -- cgit v1.2.3