File tree Expand file tree Collapse file tree 2 files changed +5
-1
lines changed Expand file tree Collapse file tree 2 files changed +5
-1
lines changed Original file line number Diff line number Diff line change @@ -228,7 +228,6 @@ static const char *const tok_enc =
228
228
"=e=" // = ==
229
229
"!." ; // start of special cases: != . ...
230
230
231
- // TODO static assert that number of tokens is less than 256 so we can safely make this table with byte sized entries
232
231
static const uint8_t tok_enc_kind [] = {
233
232
MP_TOKEN_DEL_PAREN_OPEN , MP_TOKEN_DEL_PAREN_CLOSE ,
234
233
MP_TOKEN_DEL_BRACKET_OPEN , MP_TOKEN_DEL_BRACKET_CLOSE ,
@@ -774,6 +773,9 @@ void mp_lexer_to_next(mp_lexer_t *lex) {
774
773
} else {
775
774
// search for encoded delimiter or operator
776
775
776
+ // assert that the token enum value fits in a byte, so they all fit in tok_enc_kind
777
+ MP_STATIC_ASSERT (MP_TOKEN_NUMBER_OF <= 256 );
778
+
777
779
const char * t = tok_enc ;
778
780
size_t tok_enc_index = 0 ;
779
781
for (; * t != 0 && !is_char (lex , * t ); t += 1 ) {
Original file line number Diff line number Diff line change @@ -152,6 +152,8 @@ typedef enum _mp_token_kind_t {
152
152
MP_TOKEN_DEL_SEMICOLON ,
153
153
MP_TOKEN_DEL_EQUAL ,
154
154
MP_TOKEN_DEL_MINUS_MORE ,
155
+
156
+ MP_TOKEN_NUMBER_OF ,
155
157
} mp_token_kind_t ;
156
158
157
159
// this data structure is exposed for efficiency
You can’t perform that action at this time.
0 commit comments