From 6912e5c194ef28d3d567ccdf0ee77f30219d9e17 Mon Sep 17 00:00:00 2001 From: pommicket Date: Tue, 27 Dec 2022 14:48:26 -0500 Subject: nicer keyword system --- syntax.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'syntax.c') diff --git a/syntax.c b/syntax.c index 18bc076..a8ce4d4 100644 --- a/syntax.c +++ b/syntax.c @@ -118,14 +118,15 @@ bool syntax_is_opening_bracket(Language lang, char32_t c) { } // lookup the given string in the keywords table -static Keyword const *syntax_keyword_lookup(Keyword const *const *all_keywords, size_t n_all_keywords, char32_t const *str, size_t len) { +static Keyword const *syntax_keyword_lookup(const KeywordList *all_keywords, size_t n_all_keywords, char32_t const *str, size_t len) { if (!len) return NULL; if (str[0] >= n_all_keywords) return NULL; - Keyword const *keywords = all_keywords[str[0]]; - + const KeywordList *list = &all_keywords[str[0]]; + const Keyword *keywords = list->keywords; + size_t nkeywords = list->len; if (keywords) { - for (size_t k = 0; keywords[k].str; ++k) { + for (size_t k = 0; k < nkeywords; ++k) { if (syntax_keyword_matches(str, len, keywords[k].str)) { return &keywords[k]; } -- cgit v1.2.3