diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/lexer.h | 5 | ||||
-rw-r--r-- | src/parser.h | 5 |
2 files changed, 10 insertions, 0 deletions
diff --git a/src/lexer.h b/src/lexer.h index 636237f..bb780ee 100644 --- a/src/lexer.h +++ b/src/lexer.h @@ -1,6 +1,7 @@ #ifndef ORYX_LEXER_H #define ORYX_LEXER_H +#include <assert.h> #include <stddef.h> #include <stdint.h> @@ -35,9 +36,13 @@ enum { token T to the doubled equivalent by doing T += 193. */ LEXLANGL_DBL = UINT8_MAX - 2, /* << */ LEXRANGL_DBL = UINT8_MAX - 0, /* >> */ + + _LEX_LAST_ENT, }; typedef uint8_t lexeme_kind_t_; +static_assert(_LEX_LAST_ENT - 1 <= (lexeme_kind_t_)-1, + "Too many lexer tokens to fix in LEXEME_KIND_T_"); #define LEXEMES_BLKSZ (sizeof(lexeme_kind_t_) + sizeof(struct strview)) diff --git a/src/parser.h b/src/parser.h index 4fcdacd..ee6b324 100644 --- a/src/parser.h +++ b/src/parser.h @@ -1,6 +1,7 @@ #ifndef ORYX_PARSER_H #define ORYX_PARSER_H +#include <assert.h> #include <stdbool.h> #include <stddef.h> #include <stdint.h> @@ -44,9 +45,13 @@ enum { /* Binary sub ‘lhs - rhs’ */ ASTBINSUB = '-', + + _AST_LAST_ENT = 256, }; typedef uint8_t ast_kind_t_; +static_assert(_AST_LAST_ENT - 1 <= (ast_kind_t_)-1, + "Too many AST tokens to fix in AST_KIND_T_"); #define AST_EMPTY ((idx_t_)-1) #define AST_SOA_BLKSZ (sizeof(ast_kind_t_) + sizeof(idx_t_) * 3) |