From 14a72a3520d541315fb37e6864e7e7fa4b9ede32 Mon Sep 17 00:00:00 2001 From: Charlie Gordon Date: Tue, 21 Jan 2025 09:00:24 +0100 Subject: [PATCH] lexer: use explicit intiializers for token_names --- parser/token.c2 | 240 ++++++++++++++++++++++++------------------------ 1 file changed, 120 insertions(+), 120 deletions(-) diff --git a/parser/token.c2 b/parser/token.c2 index a959a2dc..f941ce8e 100644 --- a/parser/token.c2 +++ b/parser/token.c2 @@ -147,126 +147,126 @@ public type Kind enum u8 { // NOTE: keep in sync with TokenKind const char*[] token_names = { - "none", - "identifier", - "integer", - "float", - "character", - "string", - "(", - ")", - "[", - "]", - "{", - "}", - "!", - "!=", - "*", - "*=", - "&", - "&&", - "&=", - "|", - "||", - "|=", - "=", - "==", - ";", - ":", - "@", - "^", - "^=", - "?", - ".", - "..", - "...", - ",", - "+", - "++", - "+=", - "-", - "--", - "-=", - "~", - "/", - "/=", - "%", - "%=", - "<", - "<<", - "<=", - "<<=", - ">", - ">>", - ">=", - ">>=", - "bool", - "char", - "i8", - "i16", - "i32", - "i64", - "u8", - "u16", - "u32", - "u64", - "reg8", - "reg16", - "reg32", - "reg64", - "isize", - "usize", - "f32", - "f64", - "void", - "as", - "asm", - "assert", - "break", - "case", - "cast", - "const", - "continue", - "default", - "do", - "elemsof", - "else", - "enum_max", - "enum_min", - "enum", - "fallthrough", - "false", - "fn", - "for", - "goto", - "if", - "import", - "local", - "module", - "nil", - "offsetof", - "public", - "return", - "sizeof", - "sswitch", - "static_assert", - "struct", - "switch", - "template", - "to_container", - "true", - "type", - "union", - "volatile", - "while", - "#if", - "#else", - "#endif", - "l-comment", - "b-comment", - "eof", - "warning", - "error", + [Kind.None] = "none", + [Kind.Identifier] = "identifier", + [Kind.IntegerLiteral] = "integer", + [Kind.FloatLiteral] = "float", + [Kind.CharLiteral] = "character", + [Kind.StringLiteral] = "string", + [Kind.LParen] = "(", + [Kind.RParen] = ")", + [Kind.LSquare] = "[", + [Kind.RSquare] = "]", + [Kind.LBrace] = "{", + [Kind.RBrace] = "}", + [Kind.Exclaim] = "!", + [Kind.ExclaimEqual] = "!=", + [Kind.Star] = "*", + [Kind.StarEqual] = "*=", + [Kind.Amp] = "&", + [Kind.AmpAmp] = "&&", + [Kind.AmpEqual] = "&=", + [Kind.Pipe] = "|", + [Kind.PipePipe] = "||", + [Kind.PipeEqual] = "|=", + [Kind.Equal] = "=", + [Kind.EqualEqual] = "==", + [Kind.Semicolon] = ";", + [Kind.Colon] = ":", + [Kind.At] = "@", + [Kind.Caret] = "^", + [Kind.CaretEqual] = "^=", + [Kind.Question] = "?", + [Kind.Dot] = ".", + [Kind.Range] = "..", + [Kind.Ellipsis] = "...", + [Kind.Comma] = ",", + [Kind.Plus] = "+", + [Kind.PlusPlus] = "++", + [Kind.PlusEqual] = "+=", + [Kind.Minus] = "-", + [Kind.MinusMinus] = "--", + [Kind.MinusEqual] = "-=", + [Kind.Tilde] = "~", + [Kind.Slash] = "/", + [Kind.SlashEqual] = "/=", + [Kind.Percent] = "%", + [Kind.PercentEqual] = "%=", + [Kind.Less] = "<", + [Kind.LessLess] = "<<", + [Kind.LessEqual] = "<=", + [Kind.LessLessEqual] = "<<=", + [Kind.Greater] = ">", + [Kind.GreaterGreater] = ">>", + [Kind.GreaterEqual] = ">=", + [Kind.GreaterGreaterEqual] = ">>=", + [Kind.KW_bool] = "bool", + [Kind.KW_char] = "char", + [Kind.KW_i8] = "i8", + [Kind.KW_i16] = "i16", + [Kind.KW_i32] = "i32", + [Kind.KW_i64] = "i64", + [Kind.KW_u8] = "u8", + [Kind.KW_u16] = "u16", + [Kind.KW_u32] = "u32", + [Kind.KW_u64] = "u64", + [Kind.KW_reg8] = "reg8", + [Kind.KW_reg16] = "reg16", + [Kind.KW_reg32] = "reg32", + [Kind.KW_reg64] = "reg64", + [Kind.KW_isize] = "isize", + [Kind.KW_usize] = "usize", + [Kind.KW_f32] = "f32", + [Kind.KW_f64] = "f64", + [Kind.KW_void] = "void", + [Kind.KW_as] = "as", + [Kind.KW_asm] = "asm", + [Kind.KW_assert] = "assert", + [Kind.KW_break] = "break", + [Kind.KW_case] = "case", + [Kind.KW_cast] = "cast", + [Kind.KW_const] = "const", + [Kind.KW_continue] = "continue", + [Kind.KW_default] = "default", + [Kind.KW_do] = "do", + [Kind.KW_elemsof] = "elemsof", + [Kind.KW_else] = "else", + [Kind.KW_enum_max] = "enum_max", + [Kind.KW_enum_min] = "enum_min", + [Kind.KW_enum] = "enum", + [Kind.KW_fallthrough] = "fallthrough", + [Kind.KW_false] = "false", + [Kind.KW_fn] = "fn", + [Kind.KW_for] = "for", + [Kind.KW_goto] = "goto", + [Kind.KW_if] = "if", + [Kind.KW_import] = "import", + [Kind.KW_local] = "local", + [Kind.KW_module] = "module", + [Kind.KW_nil] = "nil", + [Kind.KW_offsetof] = "offsetof", + [Kind.KW_public] = "public", + [Kind.KW_return] = "return", + [Kind.KW_sizeof] = "sizeof", + [Kind.KW_sswitch] = "sswitch", + [Kind.KW_static_assert] = "static_assert", + [Kind.KW_struct] = "struct", + [Kind.KW_switch] = "switch", + [Kind.KW_template] = "template", + [Kind.KW_to_container] = "to_container", + [Kind.KW_true] = "true", + [Kind.KW_type] = "type", + [Kind.KW_union] = "union", + [Kind.KW_volatile] = "volatile", + [Kind.KW_while] = "while", + [Kind.Feat_if] = "#if", + [Kind.Feat_else] = "#else", + [Kind.Feat_endif] = "#endif", + [Kind.LineComment] = "l-comment", + [Kind.BlockComment] = "b-comment", + [Kind.Eof] = "eof", + [Kind.Warning] = "warning", + [Kind.Error] = "error", } static_assert(elemsof(Kind), elemsof(token_names));