diff --git a/cli/generate/src/render.rs b/cli/generate/src/render.rs index 62993d55..2711ac19 100644 --- a/cli/generate/src/render.rs +++ b/cli/generate/src/render.rs @@ -983,11 +983,7 @@ impl Generator { return; } - add_line!( - self, - "static TSCharacterRange {}[] = {{", - info.constant_name - ); + add_line!(self, "const TSCharacterRange {}[] = {{", info.constant_name); indent!(self); for (ix, range) in characters.ranges().enumerate() { diff --git a/lib/src/parser.h b/lib/src/parser.h index 2338b4a2..13aa49b5 100644 --- a/lib/src/parser.h +++ b/lib/src/parser.h @@ -132,13 +132,13 @@ struct TSLanguage { const char *name; }; -static inline bool set_contains(TSCharacterRange *ranges, uint32_t len, int32_t lookahead) { +static inline bool set_contains(const TSCharacterRange *ranges, uint32_t len, int32_t lookahead) { uint32_t index = 0; uint32_t size = len - index; while (size > 1) { uint32_t half_size = size / 2; uint32_t mid_index = index + half_size; - TSCharacterRange *range = &ranges[mid_index]; + const TSCharacterRange *range = &ranges[mid_index]; if (lookahead >= range->start && lookahead <= range->end) { return true; } else if (lookahead > range->end) { @@ -146,7 +146,7 @@ static inline bool set_contains(TSCharacterRange *ranges, uint32_t len, int32_t } size -= half_size; } - TSCharacterRange *range = &ranges[index]; + const TSCharacterRange *range = &ranges[index]; return (lookahead >= range->start && lookahead <= range->end); }