Add support for custom keywords in core:odin/* packages

This commit is contained in:
gingerBill
2019-02-25 12:41:43 +00:00
parent a0c81c79ad
commit 0c8746ada6
3 changed files with 32 additions and 12 deletions
+8 -2
View File
@@ -486,12 +486,18 @@ scan :: proc(t: ^Tokenizer) -> token.Token {
case is_letter(ch):
lit = scan_identifier(t);
kind = token.Ident;
if len(lit) > 1 {
check_keyword: if len(lit) > 1 {
// TODO(bill): Maybe have a hash table lookup rather than this linear search
for i in token.B_Keyword_Begin .. token.B_Keyword_End {
if lit == token.tokens[i] {
kind = token.Kind(i);
break;
break check_keyword;
}
}
for keyword, i in token.custom_keyword_tokens {
if lit == keyword {
kind = token.Kind(i+1)+token.B_Custom_Keyword_Begin;
break check_keyword;
}
}
}