authorgravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2021-02-12 01:14:04+02:00
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2021-02-12 02:12:00+02:00
loge2289961c6b53451e5bdcdfb6eec27e27f6553ca
tree4752b2cf7df22896fb7289649f5b44b0a22b454e
parentfaa3fa65ac89b774b26bdd0ea4ac70861b29d0b4
signaturelock-open Commit is signed but in an unrecognized format.

snake_case Token.Tag


4 files changed, 1415 insertions(+), 1415 deletions(-)

lib/std/zig/ast.zig+56-56
......@@ -343,7 +343,7 @@ pub const Tree = struct {
343343 .ContainerField,
344344 => {
345345 const name_token = main_tokens[n];
346 if (name_token > 0 and token_tags[name_token - 1] == .Keyword_comptime) {
346 if (name_token > 0 and token_tags[name_token - 1] == .keyword_comptime) {
347347 end_offset += 1;
348348 }
349349 return name_token - end_offset;
......@@ -358,12 +358,12 @@ pub const Tree = struct {
358358 while (i > 0) {
359359 i -= 1;
360360 switch (token_tags[i]) {
361 .Keyword_extern,
362 .Keyword_export,
363 .Keyword_comptime,
364 .Keyword_pub,
365 .Keyword_threadlocal,
366 .StringLiteral,
361 .keyword_extern,
362 .keyword_export,
363 .keyword_comptime,
364 .keyword_pub,
365 .keyword_threadlocal,
366 .string_literal,
367367 => continue,
368368
369369 else => return i + 1 - end_offset,
......@@ -379,7 +379,7 @@ pub const Tree = struct {
379379 => {
380380 // Look for a label.
381381 const lbrace = main_tokens[n];
382 if (token_tags[lbrace - 1] == .Colon) {
382 if (token_tags[lbrace - 1] == .colon) {
383383 end_offset += 2;
384384 }
385385 return lbrace - end_offset;
......@@ -400,7 +400,7 @@ pub const Tree = struct {
400400 => {
401401 const main_token = main_tokens[n];
402402 switch (token_tags[main_token - 1]) {
403 .Keyword_packed, .Keyword_extern => end_offset += 1,
403 .keyword_packed, .keyword_extern => end_offset += 1,
404404 else => {},
405405 }
406406 return main_token - end_offset;
......@@ -413,13 +413,13 @@ pub const Tree = struct {
413413 => {
414414 const main_token = main_tokens[n];
415415 return switch (token_tags[main_token]) {
416 .Asterisk,
417 .AsteriskAsterisk,
416 .asterisk,
417 .asterisk_asterisk,
418418 => switch (token_tags[main_token - 1]) {
419 .LBracket => main_token - 1,
419 .l_bracket => main_token - 1,
420420 else => main_token,
421421 },
422 .LBracket => main_token,
422 .l_bracket => main_token,
423423 else => unreachable,
424424 } - end_offset;
425425 },
......@@ -438,7 +438,7 @@ pub const Tree = struct {
438438 },
439439
440440 .AsmOutput, .AsmInput => {
441 assert(token_tags[main_tokens[n] - 1] == .LBracket);
441 assert(token_tags[main_tokens[n] - 1] == .l_bracket);
442442 return main_tokens[n] - 1 - end_offset;
443443 },
444444
......@@ -450,7 +450,7 @@ pub const Tree = struct {
450450 => {
451451 const main_token = main_tokens[n];
452452 return switch (token_tags[main_token - 1]) {
453 .Keyword_inline => main_token - 1,
453 .keyword_inline => main_token - 1,
454454 else => main_token,
455455 } - end_offset;
456456 },
......@@ -1599,11 +1599,11 @@ pub const Tree = struct {
15991599 while (i > 0) {
16001600 i -= 1;
16011601 switch (token_tags[i]) {
1602 .Keyword_extern, .Keyword_export => result.extern_export_token = i,
1603 .Keyword_comptime => result.comptime_token = i,
1604 .Keyword_pub => result.visib_token = i,
1605 .Keyword_threadlocal => result.threadlocal_token = i,
1606 .StringLiteral => result.lib_name = i,
1602 .keyword_extern, .keyword_export => result.extern_export_token = i,
1603 .keyword_comptime => result.comptime_token = i,
1604 .keyword_pub => result.visib_token = i,
1605 .keyword_threadlocal => result.threadlocal_token = i,
1606 .string_literal => result.lib_name = i,
16071607 else => break,
16081608 }
16091609 }
......@@ -1621,14 +1621,14 @@ pub const Tree = struct {
16211621 // if (cond_expr) |x|
16221622 // ^ ^
16231623 const payload_pipe = tree.lastToken(info.cond_expr) + 2;
1624 if (token_tags[payload_pipe] == .Pipe) {
1624 if (token_tags[payload_pipe] == .pipe) {
16251625 result.payload_token = payload_pipe + 1;
16261626 }
16271627 if (info.else_expr != 0) {
16281628 // then_expr else |x|
16291629 // ^ ^
16301630 result.else_token = tree.lastToken(info.then_expr) + 1;
1631 if (token_tags[result.else_token + 1] == .Pipe) {
1631 if (token_tags[result.else_token + 1] == .pipe) {
16321632 result.error_token = result.else_token + 2;
16331633 }
16341634 }
......@@ -1643,7 +1643,7 @@ pub const Tree = struct {
16431643 };
16441644 // comptime name: type = init,
16451645 // ^
1646 if (info.name_token > 0 and token_tags[info.name_token - 1] == .Keyword_comptime) {
1646 if (info.name_token > 0 and token_tags[info.name_token - 1] == .keyword_comptime) {
16471647 result.comptime_token = info.name_token - 1;
16481648 }
16491649 return result;
......@@ -1671,17 +1671,17 @@ pub const Tree = struct {
16711671 // literals in some places here
16721672 const Kind = full.PtrType.Kind;
16731673 const kind: Kind = switch (token_tags[info.main_token]) {
1674 .Asterisk,
1675 .AsteriskAsterisk,
1674 .asterisk,
1675 .asterisk_asterisk,
16761676 => switch (token_tags[info.main_token + 1]) {
1677 .RBracket => .many,
1678 .Colon => .sentinel,
1679 .Identifier => if (token_tags[info.main_token - 1] == .LBracket) Kind.c else .one,
1677 .r_bracket => .many,
1678 .colon => .sentinel,
1679 .identifier => if (token_tags[info.main_token - 1] == .l_bracket) Kind.c else .one,
16801680 else => .one,
16811681 },
1682 .LBracket => switch (token_tags[info.main_token + 1]) {
1683 .RBracket => Kind.slice,
1684 .Colon => .slice_sentinel,
1682 .l_bracket => switch (token_tags[info.main_token + 1]) {
1683 .r_bracket => Kind.slice,
1684 .colon => .slice_sentinel,
16851685 else => unreachable,
16861686 },
16871687 else => unreachable,
......@@ -1707,10 +1707,10 @@ pub const Tree = struct {
17071707 const end = tree.firstToken(info.child_type);
17081708 while (i < end) : (i += 1) {
17091709 switch (token_tags[i]) {
1710 .Keyword_allowzero => result.allowzero_token = i,
1711 .Keyword_const => result.const_token = i,
1712 .Keyword_volatile => result.volatile_token = i,
1713 .Keyword_align => {
1710 .keyword_allowzero => result.allowzero_token = i,
1711 .keyword_const => result.const_token = i,
1712 .keyword_volatile => result.volatile_token = i,
1713 .keyword_align => {
17141714 assert(info.align_node != 0);
17151715 if (info.bit_range_end != 0) {
17161716 assert(info.bit_range_start != 0);
......@@ -1732,7 +1732,7 @@ pub const Tree = struct {
17321732 .layout_token = null,
17331733 };
17341734 switch (token_tags[info.main_token - 1]) {
1735 .Keyword_extern, .Keyword_packed => result.layout_token = info.main_token - 1,
1735 .keyword_extern, .keyword_packed => result.layout_token = info.main_token - 1,
17361736 else => {},
17371737 }
17381738 return result;
......@@ -1744,7 +1744,7 @@ pub const Tree = struct {
17441744 .ast = info,
17451745 .payload_token = null,
17461746 };
1747 if (token_tags[info.arrow_token + 1] == .Pipe) {
1747 if (token_tags[info.arrow_token + 1] == .pipe) {
17481748 result.payload_token = info.arrow_token + 2;
17491749 }
17501750 return result;
......@@ -1760,7 +1760,7 @@ pub const Tree = struct {
17601760 .outputs = &.{},
17611761 .first_clobber = null,
17621762 };
1763 if (token_tags[info.asm_token + 1] == .Keyword_volatile) {
1763 if (token_tags[info.asm_token + 1] == .keyword_volatile) {
17641764 result.volatile_token = info.asm_token + 1;
17651765 }
17661766 const outputs_end: usize = for (info.items) |item, i| {
......@@ -1776,10 +1776,10 @@ pub const Tree = struct {
17761776 if (info.items.len == 0) {
17771777 // asm ("foo" ::: "a", "b");
17781778 const template_token = tree.lastToken(info.template);
1779 if (token_tags[template_token + 1] == .Colon and
1780 token_tags[template_token + 2] == .Colon and
1781 token_tags[template_token + 3] == .Colon and
1782 token_tags[template_token + 4] == .StringLiteral)
1779 if (token_tags[template_token + 1] == .colon and
1780 token_tags[template_token + 2] == .colon and
1781 token_tags[template_token + 3] == .colon and
1782 token_tags[template_token + 4] == .string_literal)
17831783 {
17841784 result.first_clobber = template_token + 4;
17851785 }
......@@ -1787,8 +1787,8 @@ pub const Tree = struct {
17871787 // asm ("foo" :: [_] "" (y) : "a", "b");
17881788 const last_input = result.inputs[result.inputs.len - 1];
17891789 const rparen = tree.lastToken(last_input);
1790 if (token_tags[rparen + 1] == .Colon and
1791 token_tags[rparen + 2] == .StringLiteral)
1790 if (token_tags[rparen + 1] == .colon and
1791 token_tags[rparen + 2] == .string_literal)
17921792 {
17931793 result.first_clobber = rparen + 2;
17941794 }
......@@ -1796,9 +1796,9 @@ pub const Tree = struct {
17961796 // asm ("foo" : [_] "" (x) :: "a", "b");
17971797 const last_output = result.outputs[result.outputs.len - 1];
17981798 const rparen = tree.lastToken(last_output);
1799 if (token_tags[rparen + 1] == .Colon and
1800 token_tags[rparen + 2] == .Colon and
1801 token_tags[rparen + 3] == .StringLiteral)
1799 if (token_tags[rparen + 1] == .colon and
1800 token_tags[rparen + 2] == .colon and
1801 token_tags[rparen + 3] == .string_literal)
18021802 {
18031803 result.first_clobber = rparen + 3;
18041804 }
......@@ -1818,24 +1818,24 @@ pub const Tree = struct {
18181818 .error_token = null,
18191819 };
18201820 var tok_i = info.while_token - 1;
1821 if (token_tags[tok_i] == .Keyword_inline) {
1821 if (token_tags[tok_i] == .keyword_inline) {
18221822 result.inline_token = tok_i;
18231823 tok_i -= 1;
18241824 }
1825 if (token_tags[tok_i] == .Colon and
1826 token_tags[tok_i - 1] == .Identifier)
1825 if (token_tags[tok_i] == .colon and
1826 token_tags[tok_i - 1] == .identifier)
18271827 {
18281828 result.label_token = tok_i - 1;
18291829 }
18301830 const last_cond_token = tree.lastToken(info.cond_expr);
1831 if (token_tags[last_cond_token + 2] == .Pipe) {
1831 if (token_tags[last_cond_token + 2] == .pipe) {
18321832 result.payload_token = last_cond_token + 3;
18331833 }
18341834 if (info.else_expr != 0) {
18351835 // then_expr else |x|
18361836 // ^ ^
18371837 result.else_token = tree.lastToken(info.then_expr) + 1;
1838 if (token_tags[result.else_token + 1] == .Pipe) {
1838 if (token_tags[result.else_token + 1] == .pipe) {
18391839 result.error_token = result.else_token + 2;
18401840 }
18411841 }
......@@ -1849,7 +1849,7 @@ pub const Tree = struct {
18491849 .async_token = null,
18501850 };
18511851 const maybe_async_token = tree.firstToken(info.fn_expr) - 1;
1852 if (token_tags[maybe_async_token] == .Keyword_async) {
1852 if (token_tags[maybe_async_token] == .keyword_async) {
18531853 result.async_token = maybe_async_token;
18541854 }
18551855 return result;
......@@ -2120,7 +2120,7 @@ pub const Error = union(enum) {
21202120 pub const ExpectedVarDecl = SingleTokenError("Expected variable declaration, found '{s}'");
21212121 pub const ExpectedFn = SingleTokenError("Expected function, found '{s}'");
21222122 pub const ExpectedReturnType = SingleTokenError("Expected return type expression, found '{s}'");
2123 pub const ExpectedAggregateKw = SingleTokenError("Expected '" ++ Token.Tag.Keyword_struct.symbol() ++ "', '" ++ Token.Tag.Keyword_union.symbol() ++ "', '" ++ Token.Tag.Keyword_enum.symbol() ++ "', or '" ++ Token.Tag.Keyword_opaque.symbol() ++ "', found '{s}'");
2123 pub const ExpectedAggregateKw = SingleTokenError("Expected '" ++ Token.Tag.keyword_struct.symbol() ++ "', '" ++ Token.Tag.keyword_union.symbol() ++ "', '" ++ Token.Tag.keyword_enum.symbol() ++ "', or '" ++ Token.Tag.keyword_opaque.symbol() ++ "', found '{s}'");
21242124 pub const ExpectedEqOrSemi = SingleTokenError("Expected '=' or ';', found '{s}'");
21252125 pub const ExpectedSemiOrLBrace = SingleTokenError("Expected ';' or '{{', found '{s}'");
21262126 pub const ExpectedSemiOrElse = SingleTokenError("Expected ';' or 'else', found '{s}'");
......@@ -2129,7 +2129,7 @@ pub const Error = union(enum) {
21292129 pub const ExpectedColonOrRParen = SingleTokenError("Expected ':' or ')', found '{s}'");
21302130 pub const ExpectedLabelable = SingleTokenError("Expected 'while', 'for', 'inline', 'suspend', or '{{', found '{s}'");
21312131 pub const ExpectedInlinable = SingleTokenError("Expected 'while' or 'for', found '{s}'");
2132 pub const ExpectedAsmOutputReturnOrType = SingleTokenError("Expected '->' or '" ++ Token.Tag.Identifier.symbol() ++ "', found '{s}'");
2132 pub const ExpectedAsmOutputReturnOrType = SingleTokenError("Expected '->' or '" ++ Token.Tag.identifier.symbol() ++ "', found '{s}'");
21332133 pub const ExpectedSliceOrRBracket = SingleTokenError("Expected ']' or '..', found '{s}'");
21342134 pub const ExpectedTypeExpr = SingleTokenError("Expected type expression, found '{s}'");
21352135 pub const ExpectedPrimaryTypeExpr = SingleTokenError("Expected primary type expression, found '{s}'");
......@@ -2185,7 +2185,7 @@ pub const Error = union(enum) {
21852185 pub fn render(self: *const ExpectedToken, tokens: []const Token.Tag, stream: anytype) !void {
21862186 const found_token = tokens[self.token];
21872187 switch (found_token) {
2188 .Invalid => {
2188 .invalid => {
21892189 return stream.print("expected '{s}', found invalid bytes", .{self.expected_id.symbol()});
21902190 },
21912191 else => {
lib/std/zig/parse.zig+496-496
......@@ -32,7 +32,7 @@ pub fn parse(gpa: *Allocator, source: []const u8) Allocator.Error!Tree {
3232 .tag = token.tag,
3333 .start = @intCast(u32, token.loc.start),
3434 });
35 if (token.tag == .Eof) break;
35 if (token.tag == .eof) break;
3636 }
3737
3838 var parser: Parser = .{
......@@ -68,7 +68,7 @@ pub fn parse(gpa: *Allocator, source: []const u8) Allocator.Error!Tree {
6868 const root_decls = try root_members.toSpan(&parser);
6969 // parseContainerMembers will try to skip as much invalid tokens as
7070 // it can, so we are now at EOF.
71 assert(parser.token_tags[parser.tok_i] == .Eof);
71 assert(parser.token_tags[parser.tok_i] == .eof);
7272 parser.nodes.items(.data)[0] = .{
7373 .lhs = root_decls.start,
7474 .rhs = root_decls.end,
......@@ -186,14 +186,14 @@ const Parser = struct {
186186 } = .none;
187187
188188 // Skip container doc comments.
189 while (p.eatToken(.ContainerDocComment)) |_| {}
189 while (p.eatToken(.container_doc_comment)) |_| {}
190190
191191 var trailing_comma = false;
192192 while (true) {
193193 const doc_comment = p.eatDocComments();
194194
195195 switch (p.token_tags[p.tok_i]) {
196 .Keyword_test => {
196 .keyword_test => {
197197 const test_decl_node = try p.expectTestDeclRecoverable();
198198 if (test_decl_node != 0) {
199199 if (field_state == .seen) {
......@@ -203,8 +203,8 @@ const Parser = struct {
203203 }
204204 trailing_comma = false;
205205 },
206 .Keyword_comptime => switch (p.token_tags[p.tok_i + 1]) {
207 .Identifier => {
206 .keyword_comptime => switch (p.token_tags[p.tok_i + 1]) {
207 .identifier => {
208208 p.tok_i += 1;
209209 const container_field = try p.expectContainerFieldRecoverable();
210210 if (container_field != 0) {
......@@ -221,12 +221,12 @@ const Parser = struct {
221221 }
222222 try list.append(container_field);
223223 switch (p.token_tags[p.tok_i]) {
224 .Comma => {
224 .comma => {
225225 p.tok_i += 1;
226226 trailing_comma = true;
227227 continue;
228228 },
229 .RBrace, .Eof => {
229 .r_brace, .eof => {
230230 trailing_comma = false;
231231 break;
232232 },
......@@ -235,12 +235,12 @@ const Parser = struct {
235235 // There is not allowed to be a decl after a field with no comma.
236236 // Report error but recover parser.
237237 try p.warn(.{
238 .ExpectedToken = .{ .token = p.tok_i, .expected_id = .Comma },
238 .ExpectedToken = .{ .token = p.tok_i, .expected_id = .comma },
239239 });
240240 p.findNextContainerMember();
241241 }
242242 },
243 .LBrace => {
243 .l_brace => {
244244 const comptime_token = p.nextToken();
245245 const block = p.parseBlock() catch |err| switch (err) {
246246 error.OutOfMemory => return error.OutOfMemory,
......@@ -270,7 +270,7 @@ const Parser = struct {
270270 try p.warn(.{ .ExpectedBlockOrField = .{ .token = p.tok_i } });
271271 },
272272 },
273 .Keyword_pub => {
273 .keyword_pub => {
274274 p.tok_i += 1;
275275 const top_level_decl = try p.expectTopLevelDeclRecoverable();
276276 if (top_level_decl != 0) {
......@@ -281,7 +281,7 @@ const Parser = struct {
281281 }
282282 trailing_comma = false;
283283 },
284 .Keyword_usingnamespace => {
284 .keyword_usingnamespace => {
285285 const node = try p.expectUsingNamespaceRecoverable();
286286 if (node != 0) {
287287 if (field_state == .seen) {
......@@ -291,14 +291,14 @@ const Parser = struct {
291291 }
292292 trailing_comma = false;
293293 },
294 .Keyword_const,
295 .Keyword_var,
296 .Keyword_threadlocal,
297 .Keyword_export,
298 .Keyword_extern,
299 .Keyword_inline,
300 .Keyword_noinline,
301 .Keyword_fn,
294 .keyword_const,
295 .keyword_var,
296 .keyword_threadlocal,
297 .keyword_export,
298 .keyword_extern,
299 .keyword_inline,
300 .keyword_noinline,
301 .keyword_fn,
302302 => {
303303 const top_level_decl = try p.expectTopLevelDeclRecoverable();
304304 if (top_level_decl != 0) {
......@@ -309,7 +309,7 @@ const Parser = struct {
309309 }
310310 trailing_comma = false;
311311 },
312 .Identifier => {
312 .identifier => {
313313 const container_field = try p.expectContainerFieldRecoverable();
314314 if (container_field != 0) {
315315 switch (field_state) {
......@@ -325,12 +325,12 @@ const Parser = struct {
325325 }
326326 try list.append(container_field);
327327 switch (p.token_tags[p.tok_i]) {
328 .Comma => {
328 .comma => {
329329 p.tok_i += 1;
330330 trailing_comma = true;
331331 continue;
332332 },
333 .RBrace, .Eof => {
333 .r_brace, .eof => {
334334 trailing_comma = false;
335335 break;
336336 },
......@@ -339,12 +339,12 @@ const Parser = struct {
339339 // There is not allowed to be a decl after a field with no comma.
340340 // Report error but recover parser.
341341 try p.warn(.{
342 .ExpectedToken = .{ .token = p.tok_i, .expected_id = .Comma },
342 .ExpectedToken = .{ .token = p.tok_i, .expected_id = .comma },
343343 });
344344 p.findNextContainerMember();
345345 }
346346 },
347 .Eof, .RBrace => {
347 .eof, .r_brace => {
348348 if (doc_comment) |tok| {
349349 try p.warn(.{ .UnattachedDocComment = .{ .token = tok } });
350350 }
......@@ -396,36 +396,36 @@ const Parser = struct {
396396 const tok = p.nextToken();
397397 switch (p.token_tags[tok]) {
398398 // any of these can start a new top level declaration
399 .Keyword_test,
400 .Keyword_comptime,
401 .Keyword_pub,
402 .Keyword_export,
403 .Keyword_extern,
404 .Keyword_inline,
405 .Keyword_noinline,
406 .Keyword_usingnamespace,
407 .Keyword_threadlocal,
408 .Keyword_const,
409 .Keyword_var,
410 .Keyword_fn,
411 .Identifier,
399 .keyword_test,
400 .keyword_comptime,
401 .keyword_pub,
402 .keyword_export,
403 .keyword_extern,
404 .keyword_inline,
405 .keyword_noinline,
406 .keyword_usingnamespace,
407 .keyword_threadlocal,
408 .keyword_const,
409 .keyword_var,
410 .keyword_fn,
411 .identifier,
412412 => {
413413 if (level == 0) {
414414 p.tok_i -= 1;
415415 return;
416416 }
417417 },
418 .Comma, .Semicolon => {
418 .comma, .semicolon => {
419419 // this decl was likely meant to end here
420420 if (level == 0) {
421421 return;
422422 }
423423 },
424 .LParen, .LBracket, .LBrace => level += 1,
425 .RParen, .RBracket => {
424 .l_paren, .l_bracket, .l_brace => level += 1,
425 .r_paren, .r_bracket => {
426426 if (level != 0) level -= 1;
427427 },
428 .RBrace => {
428 .r_brace => {
429429 if (level == 0) {
430430 // end of container, exit
431431 p.tok_i -= 1;
......@@ -433,7 +433,7 @@ const Parser = struct {
433433 }
434434 level -= 1;
435435 },
436 .Eof => {
436 .eof => {
437437 p.tok_i -= 1;
438438 return;
439439 },
......@@ -448,20 +448,20 @@ const Parser = struct {
448448 while (true) {
449449 const tok = p.nextToken();
450450 switch (p.token_tags[tok]) {
451 .LBrace => level += 1,
452 .RBrace => {
451 .l_brace => level += 1,
452 .r_brace => {
453453 if (level == 0) {
454454 p.tok_i -= 1;
455455 return;
456456 }
457457 level -= 1;
458458 },
459 .Semicolon => {
459 .semicolon => {
460460 if (level == 0) {
461461 return;
462462 }
463463 },
464 .Eof => {
464 .eof => {
465465 p.tok_i -= 1;
466466 return;
467467 },
......@@ -472,8 +472,8 @@ const Parser = struct {
472472
473473 /// TestDecl <- KEYWORD_test STRINGLITERALSINGLE? Block
474474 fn expectTestDecl(p: *Parser) !Node.Index {
475 const test_token = p.assertToken(.Keyword_test);
476 const name_token = p.eatToken(.StringLiteral);
475 const test_token = p.assertToken(.keyword_test);
476 const name_token = p.eatToken(.string_literal);
477477 const block_node = try p.parseBlock();
478478 if (block_node == 0) return p.fail(.{ .ExpectedLBrace = .{ .token = p.tok_i } });
479479 return p.addNode(.{
......@@ -505,15 +505,15 @@ const Parser = struct {
505505 var expect_fn: bool = false;
506506 var exported: bool = false;
507507 switch (p.token_tags[extern_export_inline_token]) {
508 .Keyword_extern => _ = p.eatToken(.StringLiteral),
509 .Keyword_export => exported = true,
510 .Keyword_inline, .Keyword_noinline => expect_fn = true,
508 .keyword_extern => _ = p.eatToken(.string_literal),
509 .keyword_export => exported = true,
510 .keyword_inline, .keyword_noinline => expect_fn = true,
511511 else => p.tok_i -= 1,
512512 }
513513 const fn_proto = try p.parseFnProto();
514514 if (fn_proto != 0) {
515515 switch (p.token_tags[p.tok_i]) {
516 .Semicolon => {
516 .semicolon => {
517517 const semicolon_token = p.nextToken();
518518 try p.parseAppendedDocComment(semicolon_token);
519519 return p.addNode(.{
......@@ -525,7 +525,7 @@ const Parser = struct {
525525 },
526526 });
527527 },
528 .LBrace => {
528 .l_brace => {
529529 const body_block = try p.parseBlock();
530530 assert(body_block != 0);
531531 return p.addNode(.{
......@@ -553,10 +553,10 @@ const Parser = struct {
553553 return error.ParseError;
554554 }
555555
556 const thread_local_token = p.eatToken(.Keyword_threadlocal);
556 const thread_local_token = p.eatToken(.keyword_threadlocal);
557557 const var_decl = try p.parseVarDecl();
558558 if (var_decl != 0) {
559 const semicolon_token = try p.expectToken(.Semicolon);
559 const semicolon_token = try p.expectToken(.semicolon);
560560 try p.parseAppendedDocComment(semicolon_token);
561561 return var_decl;
562562 }
......@@ -582,9 +582,9 @@ const Parser = struct {
582582 }
583583
584584 fn expectUsingNamespace(p: *Parser) !Node.Index {
585 const usingnamespace_token = try p.expectToken(.Keyword_usingnamespace);
585 const usingnamespace_token = try p.expectToken(.keyword_usingnamespace);
586586 const expr = try p.expectExpr();
587 const semicolon_token = try p.expectToken(.Semicolon);
587 const semicolon_token = try p.expectToken(.semicolon);
588588 try p.parseAppendedDocComment(semicolon_token);
589589 return p.addNode(.{
590590 .tag = .UsingNamespace,
......@@ -608,14 +608,14 @@ const Parser = struct {
608608
609609 /// FnProto <- KEYWORD_fn IDENTIFIER? LPAREN ParamDeclList RPAREN ByteAlign? LinkSection? CallConv? EXCLAMATIONMARK? (Keyword_anytype / TypeExpr)
610610 fn parseFnProto(p: *Parser) !Node.Index {
611 const fn_token = p.eatToken(.Keyword_fn) orelse return null_node;
612 _ = p.eatToken(.Identifier);
611 const fn_token = p.eatToken(.keyword_fn) orelse return null_node;
612 _ = p.eatToken(.identifier);
613613 const params = try p.parseParamDeclList();
614614 defer params.deinit(p.gpa);
615615 const align_expr = try p.parseByteAlign();
616616 const section_expr = try p.parseLinkSection();
617617 const callconv_expr = try p.parseCallconv();
618 const bang_token = p.eatToken(.Bang);
618 const bang_token = p.eatToken(.bang);
619619
620620 const return_type_expr = try p.parseTypeExpr();
621621 if (return_type_expr == 0) {
......@@ -686,15 +686,15 @@ const Parser = struct {
686686
687687 /// VarDecl <- (KEYWORD_const / KEYWORD_var) IDENTIFIER (COLON TypeExpr)? ByteAlign? LinkSection? (EQUAL Expr)? SEMICOLON
688688 fn parseVarDecl(p: *Parser) !Node.Index {
689 const mut_token = p.eatToken(.Keyword_const) orelse
690 p.eatToken(.Keyword_var) orelse
689 const mut_token = p.eatToken(.keyword_const) orelse
690 p.eatToken(.keyword_var) orelse
691691 return null_node;
692692
693 _ = try p.expectToken(.Identifier);
694 const type_node: Node.Index = if (p.eatToken(.Colon) == null) 0 else try p.expectTypeExpr();
693 _ = try p.expectToken(.identifier);
694 const type_node: Node.Index = if (p.eatToken(.colon) == null) 0 else try p.expectTypeExpr();
695695 const align_node = try p.parseByteAlign();
696696 const section_node = try p.parseLinkSection();
697 const init_node: Node.Index = if (p.eatToken(.Equal) == null) 0 else try p.expectExpr();
697 const init_node: Node.Index = if (p.eatToken(.equal) == null) 0 else try p.expectExpr();
698698 if (section_node == 0) {
699699 if (align_node == 0) {
700700 return p.addNode(.{
......@@ -745,13 +745,13 @@ const Parser = struct {
745745
746746 /// ContainerField <- KEYWORD_comptime? IDENTIFIER (COLON TypeExpr ByteAlign?)? (EQUAL Expr)?
747747 fn expectContainerField(p: *Parser) !Node.Index {
748 const comptime_token = p.eatToken(.Keyword_comptime);
749 const name_token = p.assertToken(.Identifier);
748 const comptime_token = p.eatToken(.keyword_comptime);
749 const name_token = p.assertToken(.identifier);
750750
751751 var align_expr: Node.Index = 0;
752752 var type_expr: Node.Index = 0;
753 if (p.eatToken(.Colon)) |_| {
754 if (p.eatToken(.Keyword_anytype)) |anytype_tok| {
753 if (p.eatToken(.colon)) |_| {
754 if (p.eatToken(.keyword_anytype)) |anytype_tok| {
755755 type_expr = try p.addNode(.{
756756 .tag = .AnyType,
757757 .main_token = anytype_tok,
......@@ -766,7 +766,7 @@ const Parser = struct {
766766 }
767767 }
768768
769 const value_expr: Node.Index = if (p.eatToken(.Equal) == null) 0 else try p.expectExpr();
769 const value_expr: Node.Index = if (p.eatToken(.equal) == null) 0 else try p.expectExpr();
770770
771771 if (align_expr == 0) {
772772 return p.addNode(.{
......@@ -823,11 +823,11 @@ const Parser = struct {
823823 /// / SwitchExpr
824824 /// / AssignExpr SEMICOLON
825825 fn parseStatement(p: *Parser) Error!Node.Index {
826 const comptime_token = p.eatToken(.Keyword_comptime);
826 const comptime_token = p.eatToken(.keyword_comptime);
827827
828828 const var_decl = try p.parseVarDecl();
829829 if (var_decl != 0) {
830 _ = try p.expectTokenRecoverable(.Semicolon);
830 _ = try p.expectTokenRecoverable(.semicolon);
831831 return var_decl;
832832 }
833833
......@@ -843,7 +843,7 @@ const Parser = struct {
843843 }
844844
845845 switch (p.token_tags[p.tok_i]) {
846 .Keyword_nosuspend => {
846 .keyword_nosuspend => {
847847 return p.addNode(.{
848848 .tag = .Nosuspend,
849849 .main_token = p.nextToken(),
......@@ -853,9 +853,9 @@ const Parser = struct {
853853 },
854854 });
855855 },
856 .Keyword_suspend => {
856 .keyword_suspend => {
857857 const token = p.nextToken();
858 const block_expr: Node.Index = if (p.eatToken(.Semicolon) != null)
858 const block_expr: Node.Index = if (p.eatToken(.semicolon) != null)
859859 0
860860 else
861861 try p.expectBlockExprStatement();
......@@ -868,7 +868,7 @@ const Parser = struct {
868868 },
869869 });
870870 },
871 .Keyword_defer => return p.addNode(.{
871 .keyword_defer => return p.addNode(.{
872872 .tag = .Defer,
873873 .main_token = p.nextToken(),
874874 .data = .{
......@@ -876,7 +876,7 @@ const Parser = struct {
876876 .rhs = try p.expectBlockExprStatement(),
877877 },
878878 }),
879 .Keyword_errdefer => return p.addNode(.{
879 .keyword_errdefer => return p.addNode(.{
880880 .tag = .ErrDefer,
881881 .main_token = p.nextToken(),
882882 .data = .{
......@@ -884,8 +884,8 @@ const Parser = struct {
884884 .rhs = try p.expectBlockExprStatement(),
885885 },
886886 }),
887 .Keyword_switch => return p.expectSwitchExpr(),
888 .Keyword_if => return p.expectIfStatement(),
887 .keyword_switch => return p.expectSwitchExpr(),
888 .keyword_if => return p.expectIfStatement(),
889889 else => {},
890890 }
891891
......@@ -894,7 +894,7 @@ const Parser = struct {
894894
895895 const assign_expr = try p.parseAssignExpr();
896896 if (assign_expr != 0) {
897 _ = try p.expectTokenRecoverable(.Semicolon);
897 _ = try p.expectTokenRecoverable(.semicolon);
898898 return assign_expr;
899899 }
900900
......@@ -918,7 +918,7 @@ const Parser = struct {
918918 error.OutOfMemory => return error.OutOfMemory,
919919 error.ParseError => {
920920 p.findNextStmt(); // Try to skip to the next statement.
921 if (p.token_tags[p.tok_i] == .RBrace) return null_node;
921 if (p.token_tags[p.tok_i] == .r_brace) return null_node;
922922 continue;
923923 },
924924 };
......@@ -929,10 +929,10 @@ const Parser = struct {
929929 /// <- IfPrefix BlockExpr ( KEYWORD_else Payload? Statement )?
930930 /// / IfPrefix AssignExpr ( SEMICOLON / KEYWORD_else Payload? Statement )
931931 fn expectIfStatement(p: *Parser) !Node.Index {
932 const if_token = p.assertToken(.Keyword_if);
933 _ = try p.expectToken(.LParen);
932 const if_token = p.assertToken(.keyword_if);
933 _ = try p.expectToken(.l_paren);
934934 const condition = try p.expectExpr();
935 _ = try p.expectToken(.RParen);
935 _ = try p.expectToken(.r_paren);
936936 const then_payload = try p.parsePtrPayload();
937937
938938 // TODO propose to change the syntax so that semicolons are always required
......@@ -945,7 +945,7 @@ const Parser = struct {
945945 if (assign_expr == 0) {
946946 return p.fail(.{ .ExpectedBlockOrAssignment = .{ .token = p.tok_i } });
947947 }
948 if (p.eatToken(.Semicolon)) |_| {
948 if (p.eatToken(.semicolon)) |_| {
949949 return p.addNode(.{
950950 .tag = .IfSimple,
951951 .main_token = if_token,
......@@ -958,7 +958,7 @@ const Parser = struct {
958958 else_required = true;
959959 break :blk assign_expr;
960960 };
961 const else_token = p.eatToken(.Keyword_else) orelse {
961 const else_token = p.eatToken(.keyword_else) orelse {
962962 if (else_required) {
963963 return p.fail(.{ .ExpectedSemiOrElse = .{ .token = p.tok_i } });
964964 }
......@@ -1004,7 +1004,7 @@ const Parser = struct {
10041004
10051005 /// LoopStatement <- KEYWORD_inline? (ForStatement / WhileStatement)
10061006 fn parseLoopStatement(p: *Parser) !Node.Index {
1007 const inline_token = p.eatToken(.Keyword_inline);
1007 const inline_token = p.eatToken(.keyword_inline);
10081008
10091009 const for_statement = try p.parseForStatement();
10101010 if (for_statement != 0) return for_statement;
......@@ -1023,10 +1023,10 @@ const Parser = struct {
10231023 /// <- ForPrefix BlockExpr ( KEYWORD_else Statement )?
10241024 /// / ForPrefix AssignExpr ( SEMICOLON / KEYWORD_else Statement )
10251025 fn parseForStatement(p: *Parser) !Node.Index {
1026 const for_token = p.eatToken(.Keyword_for) orelse return null_node;
1027 _ = try p.expectToken(.LParen);
1026 const for_token = p.eatToken(.keyword_for) orelse return null_node;
1027 _ = try p.expectToken(.l_paren);
10281028 const array_expr = try p.expectExpr();
1029 _ = try p.expectToken(.RParen);
1029 _ = try p.expectToken(.r_paren);
10301030 _ = try p.parsePtrIndexPayload();
10311031
10321032 // TODO propose to change the syntax so that semicolons are always required
......@@ -1039,7 +1039,7 @@ const Parser = struct {
10391039 if (assign_expr == 0) {
10401040 return p.fail(.{ .ExpectedBlockOrAssignment = .{ .token = p.tok_i } });
10411041 }
1042 if (p.eatToken(.Semicolon)) |_| {
1042 if (p.eatToken(.semicolon)) |_| {
10431043 return p.addNode(.{
10441044 .tag = .ForSimple,
10451045 .main_token = for_token,
......@@ -1052,7 +1052,7 @@ const Parser = struct {
10521052 else_required = true;
10531053 break :blk assign_expr;
10541054 };
1055 const else_token = p.eatToken(.Keyword_else) orelse {
1055 const else_token = p.eatToken(.keyword_else) orelse {
10561056 if (else_required) {
10571057 return p.fail(.{ .ExpectedSemiOrElse = .{ .token = p.tok_i } });
10581058 }
......@@ -1083,10 +1083,10 @@ const Parser = struct {
10831083 /// <- WhilePrefix BlockExpr ( KEYWORD_else Payload? Statement )?
10841084 /// / WhilePrefix AssignExpr ( SEMICOLON / KEYWORD_else Payload? Statement )
10851085 fn parseWhileStatement(p: *Parser) !Node.Index {
1086 const while_token = p.eatToken(.Keyword_while) orelse return null_node;
1087 _ = try p.expectToken(.LParen);
1086 const while_token = p.eatToken(.keyword_while) orelse return null_node;
1087 _ = try p.expectToken(.l_paren);
10881088 const condition = try p.expectExpr();
1089 _ = try p.expectToken(.RParen);
1089 _ = try p.expectToken(.r_paren);
10901090 const then_payload = try p.parsePtrPayload();
10911091 const cont_expr = try p.parseWhileContinueExpr();
10921092
......@@ -1100,7 +1100,7 @@ const Parser = struct {
11001100 if (assign_expr == 0) {
11011101 return p.fail(.{ .ExpectedBlockOrAssignment = .{ .token = p.tok_i } });
11021102 }
1103 if (p.eatToken(.Semicolon)) |_| {
1103 if (p.eatToken(.semicolon)) |_| {
11041104 if (cont_expr == 0) {
11051105 return p.addNode(.{
11061106 .tag = .WhileSimple,
......@@ -1127,7 +1127,7 @@ const Parser = struct {
11271127 else_required = true;
11281128 break :blk assign_expr;
11291129 };
1130 const else_token = p.eatToken(.Keyword_else) orelse {
1130 const else_token = p.eatToken(.keyword_else) orelse {
11311131 if (else_required) {
11321132 return p.fail(.{ .ExpectedSemiOrElse = .{ .token = p.tok_i } });
11331133 }
......@@ -1180,7 +1180,7 @@ const Parser = struct {
11801180 }
11811181 const assign_expr = try p.parseAssignExpr();
11821182 if (assign_expr != 0) {
1183 _ = try p.expectTokenRecoverable(.Semicolon);
1183 _ = try p.expectTokenRecoverable(.semicolon);
11841184 return assign_expr;
11851185 }
11861186 return null_node;
......@@ -1197,9 +1197,9 @@ const Parser = struct {
11971197 /// BlockExpr <- BlockLabel? Block
11981198 fn parseBlockExpr(p: *Parser) Error!Node.Index {
11991199 switch (p.token_tags[p.tok_i]) {
1200 .Identifier => {
1201 if (p.token_tags[p.tok_i + 1] == .Colon and
1202 p.token_tags[p.tok_i + 2] == .LBrace)
1200 .identifier => {
1201 if (p.token_tags[p.tok_i + 1] == .colon and
1202 p.token_tags[p.tok_i + 2] == .l_brace)
12031203 {
12041204 p.tok_i += 2;
12051205 return p.parseBlock();
......@@ -1207,7 +1207,7 @@ const Parser = struct {
12071207 return null_node;
12081208 }
12091209 },
1210 .LBrace => return p.parseBlock(),
1210 .l_brace => return p.parseBlock(),
12111211 else => return null_node,
12121212 }
12131213 }
......@@ -1233,20 +1233,20 @@ const Parser = struct {
12331233 if (expr == 0) return null_node;
12341234
12351235 const tag: Node.Tag = switch (p.token_tags[p.tok_i]) {
1236 .AsteriskEqual => .AssignMul,
1237 .SlashEqual => .AssignDiv,
1238 .PercentEqual => .AssignMod,
1239 .PlusEqual => .AssignAdd,
1240 .MinusEqual => .AssignSub,
1241 .AngleBracketAngleBracketLeftEqual => .AssignBitShiftLeft,
1242 .AngleBracketAngleBracketRightEqual => .AssignBitShiftRight,
1243 .AmpersandEqual => .AssignBitAnd,
1244 .CaretEqual => .AssignBitXor,
1245 .PipeEqual => .AssignBitOr,
1246 .AsteriskPercentEqual => .AssignMulWrap,
1247 .PlusPercentEqual => .AssignAddWrap,
1248 .MinusPercentEqual => .AssignSubWrap,
1249 .Equal => .Assign,
1236 .asterisk_equal => .AssignMul,
1237 .slash_equal => .AssignDiv,
1238 .percent_equal => .AssignMod,
1239 .plus_equal => .AssignAdd,
1240 .minus_equal => .AssignSub,
1241 .angle_bracket_angle_bracket_left_equal => .AssignBitShiftLeft,
1242 .angle_bracket_angle_bracket_right_equal => .AssignBitShiftRight,
1243 .ampersand_equal => .AssignBitAnd,
1244 .caret_equal => .AssignBitXor,
1245 .pipe_equal => .AssignBitOr,
1246 .asterisk_percent_equal => .AssignMulWrap,
1247 .plus_percent_equal => .AssignAddWrap,
1248 .minus_percent_equal => .AssignSubWrap,
1249 .equal => .Assign,
12501250 else => return expr,
12511251 };
12521252 return p.addNode(.{
......@@ -1288,7 +1288,7 @@ const Parser = struct {
12881288
12891289 while (true) {
12901290 switch (p.token_tags[p.tok_i]) {
1291 .Keyword_or => {
1291 .keyword_or => {
12921292 const or_token = p.nextToken();
12931293 const rhs = try p.parseBoolAndExpr();
12941294 if (rhs == 0) {
......@@ -1315,7 +1315,7 @@ const Parser = struct {
13151315
13161316 while (true) {
13171317 switch (p.token_tags[p.tok_i]) {
1318 .Keyword_and => {
1318 .keyword_and => {
13191319 const and_token = p.nextToken();
13201320 const rhs = try p.parseCompareExpr();
13211321 if (rhs == 0) {
......@@ -1348,12 +1348,12 @@ const Parser = struct {
13481348 if (expr == 0) return null_node;
13491349
13501350 const tag: Node.Tag = switch (p.token_tags[p.tok_i]) {
1351 .EqualEqual => .EqualEqual,
1352 .BangEqual => .BangEqual,
1353 .AngleBracketLeft => .LessThan,
1354 .AngleBracketRight => .GreaterThan,
1355 .AngleBracketLeftEqual => .LessOrEqual,
1356 .AngleBracketRightEqual => .GreaterOrEqual,
1351 .equal_equal => .EqualEqual,
1352 .bang_equal => .BangEqual,
1353 .angle_bracket_left => .LessThan,
1354 .angle_bracket_right => .GreaterThan,
1355 .angle_bracket_left_equal => .LessOrEqual,
1356 .angle_bracket_right_equal => .GreaterOrEqual,
13571357 else => return expr,
13581358 };
13591359 return p.addNode(.{
......@@ -1379,11 +1379,11 @@ const Parser = struct {
13791379
13801380 while (true) {
13811381 const tag: Node.Tag = switch (p.token_tags[p.tok_i]) {
1382 .Ampersand => .BitAnd,
1383 .Caret => .BitXor,
1384 .Pipe => .BitOr,
1385 .Keyword_orelse => .OrElse,
1386 .Keyword_catch => {
1382 .ampersand => .BitAnd,
1383 .caret => .BitXor,
1384 .pipe => .BitOr,
1385 .keyword_orelse => .OrElse,
1386 .keyword_catch => {
13871387 const catch_token = p.nextToken();
13881388 _ = try p.parsePayload();
13891389 const rhs = try p.parseBitShiftExpr();
......@@ -1432,8 +1432,8 @@ const Parser = struct {
14321432
14331433 while (true) {
14341434 const tag: Node.Tag = switch (p.token_tags[p.tok_i]) {
1435 .AngleBracketAngleBracketLeft => .BitShiftLeft,
1436 .AngleBracketAngleBracketRight => .BitShiftRight,
1435 .angle_bracket_angle_bracket_left => .BitShiftLeft,
1436 .angle_bracket_angle_bracket_right => .BitShiftRight,
14371437 else => return res,
14381438 };
14391439 res = try p.addNode(.{
......@@ -1469,11 +1469,11 @@ const Parser = struct {
14691469
14701470 while (true) {
14711471 const tag: Node.Tag = switch (p.token_tags[p.tok_i]) {
1472 .Plus => .Add,
1473 .Minus => .Sub,
1474 .PlusPlus => .ArrayCat,
1475 .PlusPercent => .AddWrap,
1476 .MinusPercent => .SubWrap,
1472 .plus => .Add,
1473 .minus => .Sub,
1474 .plus_plus => .ArrayCat,
1475 .plus_percent => .AddWrap,
1476 .minus_percent => .SubWrap,
14771477 else => return res,
14781478 };
14791479 res = try p.addNode(.{
......@@ -1509,12 +1509,12 @@ const Parser = struct {
15091509
15101510 while (true) {
15111511 const tag: Node.Tag = switch (p.token_tags[p.tok_i]) {
1512 .PipePipe => .MergeErrorSets,
1513 .Asterisk => .Mul,
1514 .Slash => .Div,
1515 .Percent => .Mod,
1516 .AsteriskAsterisk => .ArrayMult,
1517 .AsteriskPercent => .MulWrap,
1512 .pipe_pipe => .MergeErrorSets,
1513 .asterisk => .Mul,
1514 .slash => .Div,
1515 .percent => .Mod,
1516 .asterisk_asterisk => .ArrayMult,
1517 .asterisk_percent => .MulWrap,
15181518 else => return res,
15191519 };
15201520 res = try p.addNode(.{
......@@ -1547,13 +1547,13 @@ const Parser = struct {
15471547 /// / KEYWORD_await
15481548 fn parsePrefixExpr(p: *Parser) Error!Node.Index {
15491549 const tag: Node.Tag = switch (p.token_tags[p.tok_i]) {
1550 .Bang => .BoolNot,
1551 .Minus => .Negation,
1552 .Tilde => .BitNot,
1553 .MinusPercent => .NegationWrap,
1554 .Ampersand => .AddressOf,
1555 .Keyword_try => .Try,
1556 .Keyword_await => .Await,
1550 .bang => .BoolNot,
1551 .minus => .Negation,
1552 .tilde => .BitNot,
1553 .minus_percent => .NegationWrap,
1554 .ampersand => .AddressOf,
1555 .keyword_try => .Try,
1556 .keyword_await => .Await,
15571557 else => return p.parsePrimaryExpr(),
15581558 };
15591559 return p.addNode(.{
......@@ -1587,7 +1587,7 @@ const Parser = struct {
15871587 /// ArrayTypeStart <- LBRACKET Expr? (COLON Expr)? RBRACKET
15881588 fn parseTypeExpr(p: *Parser) Error!Node.Index {
15891589 switch (p.token_tags[p.tok_i]) {
1590 .QuestionMark => return p.addNode(.{
1590 .question_mark => return p.addNode(.{
15911591 .tag = .OptionalType,
15921592 .main_token = p.nextToken(),
15931593 .data = .{
......@@ -1595,8 +1595,8 @@ const Parser = struct {
15951595 .rhs = undefined,
15961596 },
15971597 }),
1598 .Keyword_anyframe => switch (p.token_tags[p.tok_i + 1]) {
1599 .Arrow => return p.addNode(.{
1598 .keyword_anyframe => switch (p.token_tags[p.tok_i + 1]) {
1599 .arrow => return p.addNode(.{
16001600 .tag = .AnyFrameType,
16011601 .main_token = p.nextToken(),
16021602 .data = .{
......@@ -1606,7 +1606,7 @@ const Parser = struct {
16061606 }),
16071607 else => return p.parseErrorUnionExpr(),
16081608 },
1609 .Asterisk => {
1609 .asterisk => {
16101610 const asterisk = p.nextToken();
16111611 const mods = try p.parsePtrModifiers();
16121612 const elem_type = try p.expectTypeExpr();
......@@ -1635,7 +1635,7 @@ const Parser = struct {
16351635 });
16361636 }
16371637 },
1638 .AsteriskAsterisk => {
1638 .asterisk_asterisk => {
16391639 const asterisk = p.nextToken();
16401640 const mods = try p.parsePtrModifiers();
16411641 const elem_type = try p.expectTypeExpr();
......@@ -1674,13 +1674,13 @@ const Parser = struct {
16741674 },
16751675 });
16761676 },
1677 .LBracket => switch (p.token_tags[p.tok_i + 1]) {
1678 .Asterisk => {
1677 .l_bracket => switch (p.token_tags[p.tok_i + 1]) {
1678 .asterisk => {
16791679 const lbracket = p.nextToken();
16801680 const asterisk = p.nextToken();
16811681 var sentinel: Node.Index = 0;
16821682 prefix: {
1683 if (p.eatToken(.Identifier)) |ident| {
1683 if (p.eatToken(.identifier)) |ident| {
16841684 const token_slice = p.source[p.token_starts[ident]..][0..2];
16851685 if (!std.mem.eql(u8, token_slice, "c]")) {
16861686 p.tok_i -= 1;
......@@ -1688,11 +1688,11 @@ const Parser = struct {
16881688 break :prefix;
16891689 }
16901690 }
1691 if (p.eatToken(.Colon)) |_| {
1691 if (p.eatToken(.colon)) |_| {
16921692 sentinel = try p.expectExpr();
16931693 }
16941694 }
1695 _ = try p.expectToken(.RBracket);
1695 _ = try p.expectToken(.r_bracket);
16961696 const mods = try p.parsePtrModifiers();
16971697 const elem_type = try p.expectTypeExpr();
16981698 if (mods.bit_range_start == 0) {
......@@ -1746,11 +1746,11 @@ const Parser = struct {
17461746 else => {
17471747 const lbracket = p.nextToken();
17481748 const len_expr = try p.parseExpr();
1749 const sentinel: Node.Index = if (p.eatToken(.Colon)) |_|
1749 const sentinel: Node.Index = if (p.eatToken(.colon)) |_|
17501750 try p.expectExpr()
17511751 else
17521752 0;
1753 _ = try p.expectToken(.RBracket);
1753 _ = try p.expectToken(.r_bracket);
17541754 const mods = try p.parsePtrModifiers();
17551755 const elem_type = try p.expectTypeExpr();
17561756 if (mods.bit_range_start != 0) {
......@@ -1849,9 +1849,9 @@ const Parser = struct {
18491849 /// / CurlySuffixExpr
18501850 fn parsePrimaryExpr(p: *Parser) !Node.Index {
18511851 switch (p.token_tags[p.tok_i]) {
1852 .Keyword_asm => return p.expectAsmExpr(),
1853 .Keyword_if => return p.parseIfExpr(),
1854 .Keyword_break => {
1852 .keyword_asm => return p.expectAsmExpr(),
1853 .keyword_if => return p.parseIfExpr(),
1854 .keyword_break => {
18551855 p.tok_i += 1;
18561856 return p.addNode(.{
18571857 .tag = .Break,
......@@ -1862,7 +1862,7 @@ const Parser = struct {
18621862 },
18631863 });
18641864 },
1865 .Keyword_continue => {
1865 .keyword_continue => {
18661866 p.tok_i += 1;
18671867 return p.addNode(.{
18681868 .tag = .Continue,
......@@ -1873,7 +1873,7 @@ const Parser = struct {
18731873 },
18741874 });
18751875 },
1876 .Keyword_comptime => {
1876 .keyword_comptime => {
18771877 p.tok_i += 1;
18781878 return p.addNode(.{
18791879 .tag = .Comptime,
......@@ -1884,7 +1884,7 @@ const Parser = struct {
18841884 },
18851885 });
18861886 },
1887 .Keyword_nosuspend => {
1887 .keyword_nosuspend => {
18881888 p.tok_i += 1;
18891889 return p.addNode(.{
18901890 .tag = .Nosuspend,
......@@ -1895,7 +1895,7 @@ const Parser = struct {
18951895 },
18961896 });
18971897 },
1898 .Keyword_resume => {
1898 .keyword_resume => {
18991899 p.tok_i += 1;
19001900 return p.addNode(.{
19011901 .tag = .Resume,
......@@ -1906,7 +1906,7 @@ const Parser = struct {
19061906 },
19071907 });
19081908 },
1909 .Keyword_return => {
1909 .keyword_return => {
19101910 p.tok_i += 1;
19111911 return p.addNode(.{
19121912 .tag = .Return,
......@@ -1917,28 +1917,28 @@ const Parser = struct {
19171917 },
19181918 });
19191919 },
1920 .Identifier => {
1921 if (p.token_tags[p.tok_i + 1] == .Colon) {
1920 .identifier => {
1921 if (p.token_tags[p.tok_i + 1] == .colon) {
19221922 switch (p.token_tags[p.tok_i + 2]) {
1923 .Keyword_inline => {
1923 .keyword_inline => {
19241924 p.tok_i += 3;
19251925 switch (p.token_tags[p.tok_i]) {
1926 .Keyword_for => return p.parseForExpr(),
1927 .Keyword_while => return p.parseWhileExpr(),
1926 .keyword_for => return p.parseForExpr(),
1927 .keyword_while => return p.parseWhileExpr(),
19281928 else => return p.fail(.{
19291929 .ExpectedInlinable = .{ .token = p.tok_i },
19301930 }),
19311931 }
19321932 },
1933 .Keyword_for => {
1933 .keyword_for => {
19341934 p.tok_i += 2;
19351935 return p.parseForExpr();
19361936 },
1937 .Keyword_while => {
1937 .keyword_while => {
19381938 p.tok_i += 2;
19391939 return p.parseWhileExpr();
19401940 },
1941 .LBrace => {
1941 .l_brace => {
19421942 p.tok_i += 2;
19431943 return p.parseBlock();
19441944 },
......@@ -1948,19 +1948,19 @@ const Parser = struct {
19481948 return p.parseCurlySuffixExpr();
19491949 }
19501950 },
1951 .Keyword_inline => {
1951 .keyword_inline => {
19521952 p.tok_i += 2;
19531953 switch (p.token_tags[p.tok_i]) {
1954 .Keyword_for => return p.parseForExpr(),
1955 .Keyword_while => return p.parseWhileExpr(),
1954 .keyword_for => return p.parseForExpr(),
1955 .keyword_while => return p.parseWhileExpr(),
19561956 else => return p.fail(.{
19571957 .ExpectedInlinable = .{ .token = p.tok_i },
19581958 }),
19591959 }
19601960 },
1961 .Keyword_for => return p.parseForExpr(),
1962 .Keyword_while => return p.parseWhileExpr(),
1963 .LBrace => return p.parseBlock(),
1961 .keyword_for => return p.parseForExpr(),
1962 .keyword_while => return p.parseWhileExpr(),
1963 .l_brace => return p.parseBlock(),
19641964 else => return p.parseCurlySuffixExpr(),
19651965 }
19661966 }
......@@ -1972,9 +1972,9 @@ const Parser = struct {
19721972
19731973 /// Block <- LBRACE Statement* RBRACE
19741974 fn parseBlock(p: *Parser) !Node.Index {
1975 const lbrace = p.eatToken(.LBrace) orelse return null_node;
1975 const lbrace = p.eatToken(.l_brace) orelse return null_node;
19761976
1977 if (p.eatToken(.RBrace)) |_| {
1977 if (p.eatToken(.r_brace)) |_| {
19781978 return p.addNode(.{
19791979 .tag = .BlockTwo,
19801980 .main_token = lbrace,
......@@ -1986,8 +1986,8 @@ const Parser = struct {
19861986 }
19871987
19881988 const stmt_one = try p.expectStatementRecoverable();
1989 if (p.eatToken(.RBrace)) |_| {
1990 const semicolon = p.token_tags[p.tok_i - 2] == .Semicolon;
1989 if (p.eatToken(.r_brace)) |_| {
1990 const semicolon = p.token_tags[p.tok_i - 2] == .semicolon;
19911991 return p.addNode(.{
19921992 .tag = if (semicolon) .BlockTwoSemicolon else .BlockTwo,
19931993 .main_token = lbrace,
......@@ -1998,8 +1998,8 @@ const Parser = struct {
19981998 });
19991999 }
20002000 const stmt_two = try p.expectStatementRecoverable();
2001 if (p.eatToken(.RBrace)) |_| {
2002 const semicolon = p.token_tags[p.tok_i - 2] == .Semicolon;
2001 if (p.eatToken(.r_brace)) |_| {
2002 const semicolon = p.token_tags[p.tok_i - 2] == .semicolon;
20032003 return p.addNode(.{
20042004 .tag = if (semicolon) .BlockTwoSemicolon else .BlockTwo,
20052005 .main_token = lbrace,
......@@ -2013,16 +2013,16 @@ const Parser = struct {
20132013 var statements = std.ArrayList(Node.Index).init(p.gpa);
20142014 defer statements.deinit();
20152015
2016 try statements.appendSlice(&[_]Node.Index{ stmt_one, stmt_two });
2016 try statements.appendSlice(&.{ stmt_one, stmt_two });
20172017
20182018 while (true) {
20192019 const statement = try p.expectStatementRecoverable();
20202020 if (statement == 0) break;
20212021 try statements.append(statement);
2022 if (p.token_tags[p.tok_i] == .RBrace) break;
2022 if (p.token_tags[p.tok_i] == .r_brace) break;
20232023 }
2024 _ = try p.expectToken(.RBrace);
2025 const semicolon = p.token_tags[p.tok_i - 2] == .Semicolon;
2024 _ = try p.expectToken(.r_brace);
2025 const semicolon = p.token_tags[p.tok_i - 2] == .semicolon;
20262026 const statements_span = try p.listToSpan(statements.items);
20272027 return p.addNode(.{
20282028 .tag = if (semicolon) .BlockSemicolon else .Block,
......@@ -2037,14 +2037,14 @@ const Parser = struct {
20372037 /// ForPrefix <- KEYWORD_for LPAREN Expr RPAREN PtrIndexPayload
20382038 /// ForExpr <- ForPrefix Expr (KEYWORD_else Expr)?
20392039 fn parseForExpr(p: *Parser) !Node.Index {
2040 const for_token = p.eatToken(.Keyword_for) orelse return null_node;
2041 _ = try p.expectToken(.LParen);
2040 const for_token = p.eatToken(.keyword_for) orelse return null_node;
2041 _ = try p.expectToken(.l_paren);
20422042 const array_expr = try p.expectExpr();
2043 _ = try p.expectToken(.RParen);
2043 _ = try p.expectToken(.r_paren);
20442044 _ = try p.parsePtrIndexPayload();
20452045
20462046 const then_expr = try p.expectExpr();
2047 const else_token = p.eatToken(.Keyword_else) orelse {
2047 const else_token = p.eatToken(.keyword_else) orelse {
20482048 return p.addNode(.{
20492049 .tag = .ForSimple,
20502050 .main_token = for_token,
......@@ -2071,15 +2071,15 @@ const Parser = struct {
20712071 /// WhilePrefix <- KEYWORD_while LPAREN Expr RPAREN PtrPayload? WhileContinueExpr?
20722072 /// WhileExpr <- WhilePrefix Expr (KEYWORD_else Payload? Expr)?
20732073 fn parseWhileExpr(p: *Parser) !Node.Index {
2074 const while_token = p.eatToken(.Keyword_while) orelse return null_node;
2075 _ = try p.expectToken(.LParen);
2074 const while_token = p.eatToken(.keyword_while) orelse return null_node;
2075 _ = try p.expectToken(.l_paren);
20762076 const condition = try p.expectExpr();
2077 _ = try p.expectToken(.RParen);
2077 _ = try p.expectToken(.r_paren);
20782078 const then_payload = try p.parsePtrPayload();
20792079 const cont_expr = try p.parseWhileContinueExpr();
20802080
20812081 const then_expr = try p.expectExpr();
2082 const else_token = p.eatToken(.Keyword_else) orelse {
2082 const else_token = p.eatToken(.keyword_else) orelse {
20832083 if (cont_expr == 0) {
20842084 return p.addNode(.{
20852085 .tag = .WhileSimple,
......@@ -2127,12 +2127,12 @@ const Parser = struct {
21272127 fn parseCurlySuffixExpr(p: *Parser) !Node.Index {
21282128 const lhs = try p.parseTypeExpr();
21292129 if (lhs == 0) return null_node;
2130 const lbrace = p.eatToken(.LBrace) orelse return lhs;
2130 const lbrace = p.eatToken(.l_brace) orelse return lhs;
21312131
21322132 // If there are 0 or 1 items, we can use ArrayInitOne/StructInitOne;
21332133 // otherwise we use the full ArrayInit/StructInit.
21342134
2135 if (p.eatToken(.RBrace)) |_| {
2135 if (p.eatToken(.r_brace)) |_| {
21362136 return p.addNode(.{
21372137 .tag = .StructInitOne,
21382138 .main_token = lbrace,
......@@ -2144,8 +2144,8 @@ const Parser = struct {
21442144 }
21452145 const field_init = try p.parseFieldInit();
21462146 if (field_init != 0) {
2147 const comma_one = p.eatToken(.Comma);
2148 if (p.eatToken(.RBrace)) |_| {
2147 const comma_one = p.eatToken(.comma);
2148 if (p.eatToken(.r_brace)) |_| {
21492149 return p.addNode(.{
21502150 .tag = if (comma_one != null) .StructInitOneComma else .StructInitOne,
21512151 .main_token = lbrace,
......@@ -2166,17 +2166,17 @@ const Parser = struct {
21662166 try init_list.append(next);
21672167
21682168 switch (p.token_tags[p.nextToken()]) {
2169 .Comma => {
2170 if (p.eatToken(.RBrace)) |_| break;
2169 .comma => {
2170 if (p.eatToken(.r_brace)) |_| break;
21712171 continue;
21722172 },
2173 .RBrace => break,
2174 .Colon, .RParen, .RBracket => {
2173 .r_brace => break,
2174 .colon, .r_paren, .r_bracket => {
21752175 p.tok_i -= 1;
21762176 return p.fail(.{
21772177 .ExpectedToken = .{
21782178 .token = p.tok_i,
2179 .expected_id = .RBrace,
2179 .expected_id = .r_brace,
21802180 },
21812181 });
21822182 },
......@@ -2185,14 +2185,14 @@ const Parser = struct {
21852185 // give an error but continue parsing this list.
21862186 p.tok_i -= 1;
21872187 try p.warn(.{
2188 .ExpectedToken = .{ .token = p.tok_i, .expected_id = .Comma },
2188 .ExpectedToken = .{ .token = p.tok_i, .expected_id = .comma },
21892189 });
21902190 },
21912191 }
21922192 }
21932193 const span = try p.listToSpan(init_list.items);
21942194 return p.addNode(.{
2195 .tag = if (p.token_tags[p.tok_i - 2] == .Comma) .StructInitComma else .StructInit,
2195 .tag = if (p.token_tags[p.tok_i - 2] == .comma) .StructInitComma else .StructInit,
21962196 .main_token = lbrace,
21972197 .data = .{
21982198 .lhs = lhs,
......@@ -2205,8 +2205,8 @@ const Parser = struct {
22052205 }
22062206
22072207 const elem_init = try p.expectExpr();
2208 const comma_one = p.eatToken(.Comma);
2209 if (p.eatToken(.RBrace)) |_| {
2208 const comma_one = p.eatToken(.comma);
2209 if (p.eatToken(.r_brace)) |_| {
22102210 return p.addNode(.{
22112211 .tag = if (comma_one != null) .ArrayInitOneComma else .ArrayInitOne,
22122212 .main_token = lbrace,
......@@ -2218,7 +2218,7 @@ const Parser = struct {
22182218 }
22192219 if (comma_one == null) {
22202220 try p.warn(.{
2221 .ExpectedToken = .{ .token = p.tok_i, .expected_id = .Comma },
2221 .ExpectedToken = .{ .token = p.tok_i, .expected_id = .comma },
22222222 });
22232223 }
22242224
......@@ -2231,12 +2231,12 @@ const Parser = struct {
22312231 var next = try p.parseExpr();
22322232 while (next != 0) : (next = try p.parseExpr()) {
22332233 try init_list.append(next);
2234 if (p.eatToken(.Comma) == null) {
2234 if (p.eatToken(.comma) == null) {
22352235 trailing_comma = false;
22362236 break;
22372237 }
22382238 }
2239 _ = try p.expectToken(.RBrace);
2239 _ = try p.expectToken(.r_brace);
22402240 const span = try p.listToSpan(init_list.items);
22412241 return p.addNode(.{
22422242 .tag = if (trailing_comma) .ArrayInitComma else .ArrayInit,
......@@ -2255,7 +2255,7 @@ const Parser = struct {
22552255 fn parseErrorUnionExpr(p: *Parser) !Node.Index {
22562256 const suffix_expr = try p.parseSuffixExpr();
22572257 if (suffix_expr == 0) return null_node;
2258 const bang = p.eatToken(.Bang) orelse return suffix_expr;
2258 const bang = p.eatToken(.bang) orelse return suffix_expr;
22592259 return p.addNode(.{
22602260 .tag = .ErrorUnion,
22612261 .main_token = bang,
......@@ -2272,7 +2272,7 @@ const Parser = struct {
22722272 /// FnCallArguments <- LPAREN ExprList RPAREN
22732273 /// ExprList <- (Expr COMMA)* Expr?
22742274 fn parseSuffixExpr(p: *Parser) !Node.Index {
2275 if (p.eatToken(.Keyword_async)) |async_token| {
2275 if (p.eatToken(.keyword_async)) |async_token| {
22762276 var res = try p.expectPrimaryTypeExpr();
22772277
22782278 while (true) {
......@@ -2280,11 +2280,11 @@ const Parser = struct {
22802280 if (node == 0) break;
22812281 res = node;
22822282 }
2283 const lparen = (try p.expectTokenRecoverable(.LParen)) orelse {
2283 const lparen = (try p.expectTokenRecoverable(.l_paren)) orelse {
22842284 try p.warn(.{ .ExpectedParamList = .{ .token = p.tok_i } });
22852285 return res;
22862286 };
2287 if (p.eatToken(.RParen)) |_| {
2287 if (p.eatToken(.r_paren)) |_| {
22882288 return p.addNode(.{
22892289 .tag = .AsyncCallOne,
22902290 .main_token = lparen,
......@@ -2295,8 +2295,8 @@ const Parser = struct {
22952295 });
22962296 }
22972297 const param_one = try p.expectExpr();
2298 const comma_one = p.eatToken(.Comma);
2299 if (p.eatToken(.RParen)) |_| {
2298 const comma_one = p.eatToken(.comma);
2299 if (p.eatToken(.r_paren)) |_| {
23002300 return p.addNode(.{
23012301 .tag = if (comma_one == null) .AsyncCallOne else .AsyncCallOneComma,
23022302 .main_token = lparen,
......@@ -2308,7 +2308,7 @@ const Parser = struct {
23082308 }
23092309 if (comma_one == null) {
23102310 try p.warn(.{
2311 .ExpectedToken = .{ .token = p.tok_i, .expected_id = .Comma },
2311 .ExpectedToken = .{ .token = p.tok_i, .expected_id = .comma },
23122312 });
23132313 }
23142314
......@@ -2321,8 +2321,8 @@ const Parser = struct {
23212321 const next = try p.expectExpr();
23222322 try param_list.append(next);
23232323 switch (p.token_tags[p.nextToken()]) {
2324 .Comma => {
2325 if (p.eatToken(.RParen)) |_| {
2324 .comma => {
2325 if (p.eatToken(.r_paren)) |_| {
23262326 const span = try p.listToSpan(param_list.items);
23272327 return p.addNode(.{
23282328 .tag = .AsyncCallComma,
......@@ -2339,7 +2339,7 @@ const Parser = struct {
23392339 continue;
23402340 }
23412341 },
2342 .RParen => {
2342 .r_paren => {
23432343 const span = try p.listToSpan(param_list.items);
23442344 return p.addNode(.{
23452345 .tag = .AsyncCall,
......@@ -2353,12 +2353,12 @@ const Parser = struct {
23532353 },
23542354 });
23552355 },
2356 .Colon, .RBrace, .RBracket => {
2356 .colon, .r_brace, .r_bracket => {
23572357 p.tok_i -= 1;
23582358 return p.fail(.{
23592359 .ExpectedToken = .{
23602360 .token = p.tok_i,
2361 .expected_id = .RParen,
2361 .expected_id = .r_paren,
23622362 },
23632363 });
23642364 },
......@@ -2367,7 +2367,7 @@ const Parser = struct {
23672367 try p.warn(.{
23682368 .ExpectedToken = .{
23692369 .token = p.tok_i,
2370 .expected_id = .Comma,
2370 .expected_id = .comma,
23712371 },
23722372 });
23732373 },
......@@ -2384,8 +2384,8 @@ const Parser = struct {
23842384 continue;
23852385 }
23862386 res = res: {
2387 const lparen = p.eatToken(.LParen) orelse return res;
2388 if (p.eatToken(.RParen)) |_| {
2387 const lparen = p.eatToken(.l_paren) orelse return res;
2388 if (p.eatToken(.r_paren)) |_| {
23892389 break :res try p.addNode(.{
23902390 .tag = .CallOne,
23912391 .main_token = lparen,
......@@ -2396,8 +2396,8 @@ const Parser = struct {
23962396 });
23972397 }
23982398 const param_one = try p.expectExpr();
2399 const comma_one = p.eatToken(.Comma);
2400 if (p.eatToken(.RParen)) |_| {
2399 const comma_one = p.eatToken(.comma);
2400 if (p.eatToken(.r_paren)) |_| {
24012401 break :res try p.addNode(.{
24022402 .tag = if (comma_one == null) .CallOne else .CallOneComma,
24032403 .main_token = lparen,
......@@ -2409,7 +2409,7 @@ const Parser = struct {
24092409 }
24102410 if (comma_one == null) {
24112411 try p.warn(.{
2412 .ExpectedToken = .{ .token = p.tok_i, .expected_id = .Comma },
2412 .ExpectedToken = .{ .token = p.tok_i, .expected_id = .comma },
24132413 });
24142414 }
24152415
......@@ -2422,8 +2422,8 @@ const Parser = struct {
24222422 const next = try p.expectExpr();
24232423 try param_list.append(next);
24242424 switch (p.token_tags[p.nextToken()]) {
2425 .Comma => {
2426 if (p.eatToken(.RParen)) |_| {
2425 .comma => {
2426 if (p.eatToken(.r_paren)) |_| {
24272427 const span = try p.listToSpan(param_list.items);
24282428 break :res try p.addNode(.{
24292429 .tag = .CallComma,
......@@ -2440,7 +2440,7 @@ const Parser = struct {
24402440 continue;
24412441 }
24422442 },
2443 .RParen => {
2443 .r_paren => {
24442444 const span = try p.listToSpan(param_list.items);
24452445 break :res try p.addNode(.{
24462446 .tag = .Call,
......@@ -2454,12 +2454,12 @@ const Parser = struct {
24542454 },
24552455 });
24562456 },
2457 .Colon, .RBrace, .RBracket => {
2457 .colon, .r_brace, .r_bracket => {
24582458 p.tok_i -= 1;
24592459 return p.fail(.{
24602460 .ExpectedToken = .{
24612461 .token = p.tok_i,
2462 .expected_id = .RParen,
2462 .expected_id = .r_paren,
24632463 },
24642464 });
24652465 },
......@@ -2468,7 +2468,7 @@ const Parser = struct {
24682468 try p.warn(.{
24692469 .ExpectedToken = .{
24702470 .token = p.tok_i,
2471 .expected_id = .Comma,
2471 .expected_id = .comma,
24722472 },
24732473 });
24742474 },
......@@ -2517,7 +2517,7 @@ const Parser = struct {
25172517 /// LoopTypeExpr <- KEYWORD_inline? (ForTypeExpr / WhileTypeExpr)
25182518 fn parsePrimaryTypeExpr(p: *Parser) !Node.Index {
25192519 switch (p.token_tags[p.tok_i]) {
2520 .CharLiteral => return p.addNode(.{
2520 .char_literal => return p.addNode(.{
25212521 .tag = .CharLiteral,
25222522 .main_token = p.nextToken(),
25232523 .data = .{
......@@ -2525,7 +2525,7 @@ const Parser = struct {
25252525 .rhs = undefined,
25262526 },
25272527 }),
2528 .IntegerLiteral => return p.addNode(.{
2528 .integer_literal => return p.addNode(.{
25292529 .tag = .IntegerLiteral,
25302530 .main_token = p.nextToken(),
25312531 .data = .{
......@@ -2533,7 +2533,7 @@ const Parser = struct {
25332533 .rhs = undefined,
25342534 },
25352535 }),
2536 .FloatLiteral => return p.addNode(.{
2536 .float_literal => return p.addNode(.{
25372537 .tag = .FloatLiteral,
25382538 .main_token = p.nextToken(),
25392539 .data = .{
......@@ -2541,7 +2541,7 @@ const Parser = struct {
25412541 .rhs = undefined,
25422542 },
25432543 }),
2544 .Keyword_false => return p.addNode(.{
2544 .keyword_false => return p.addNode(.{
25452545 .tag = .FalseLiteral,
25462546 .main_token = p.nextToken(),
25472547 .data = .{
......@@ -2549,7 +2549,7 @@ const Parser = struct {
25492549 .rhs = undefined,
25502550 },
25512551 }),
2552 .Keyword_true => return p.addNode(.{
2552 .keyword_true => return p.addNode(.{
25532553 .tag = .TrueLiteral,
25542554 .main_token = p.nextToken(),
25552555 .data = .{
......@@ -2557,7 +2557,7 @@ const Parser = struct {
25572557 .rhs = undefined,
25582558 },
25592559 }),
2560 .Keyword_null => return p.addNode(.{
2560 .keyword_null => return p.addNode(.{
25612561 .tag = .NullLiteral,
25622562 .main_token = p.nextToken(),
25632563 .data = .{
......@@ -2565,7 +2565,7 @@ const Parser = struct {
25652565 .rhs = undefined,
25662566 },
25672567 }),
2568 .Keyword_undefined => return p.addNode(.{
2568 .keyword_undefined => return p.addNode(.{
25692569 .tag = .UndefinedLiteral,
25702570 .main_token = p.nextToken(),
25712571 .data = .{
......@@ -2573,7 +2573,7 @@ const Parser = struct {
25732573 .rhs = undefined,
25742574 },
25752575 }),
2576 .Keyword_unreachable => return p.addNode(.{
2576 .keyword_unreachable => return p.addNode(.{
25772577 .tag = .UnreachableLiteral,
25782578 .main_token = p.nextToken(),
25792579 .data = .{
......@@ -2581,7 +2581,7 @@ const Parser = struct {
25812581 .rhs = undefined,
25822582 },
25832583 }),
2584 .Keyword_anyframe => return p.addNode(.{
2584 .keyword_anyframe => return p.addNode(.{
25852585 .tag = .AnyFrameLiteral,
25862586 .main_token = p.nextToken(),
25872587 .data = .{
......@@ -2589,7 +2589,7 @@ const Parser = struct {
25892589 .rhs = undefined,
25902590 },
25912591 }),
2592 .StringLiteral => {
2592 .string_literal => {
25932593 const main_token = p.nextToken();
25942594 return p.addNode(.{
25952595 .tag = .StringLiteral,
......@@ -2601,25 +2601,25 @@ const Parser = struct {
26012601 });
26022602 },
26032603
2604 .Builtin => return p.parseBuiltinCall(),
2605 .Keyword_fn => return p.parseFnProto(),
2606 .Keyword_if => return p.parseIf(parseTypeExpr),
2607 .Keyword_switch => return p.expectSwitchExpr(),
2604 .builtin => return p.parseBuiltinCall(),
2605 .keyword_fn => return p.parseFnProto(),
2606 .keyword_if => return p.parseIf(parseTypeExpr),
2607 .keyword_switch => return p.expectSwitchExpr(),
26082608
2609 .Keyword_extern,
2610 .Keyword_packed,
2609 .keyword_extern,
2610 .keyword_packed,
26112611 => {
26122612 p.tok_i += 1;
26132613 return p.parseContainerDeclAuto();
26142614 },
26152615
2616 .Keyword_struct,
2617 .Keyword_opaque,
2618 .Keyword_enum,
2619 .Keyword_union,
2616 .keyword_struct,
2617 .keyword_opaque,
2618 .keyword_enum,
2619 .keyword_union,
26202620 => return p.parseContainerDeclAuto(),
26212621
2622 .Keyword_comptime => return p.addNode(.{
2622 .keyword_comptime => return p.addNode(.{
26232623 .tag = .Comptime,
26242624 .main_token = p.nextToken(),
26252625 .data = .{
......@@ -2627,9 +2627,9 @@ const Parser = struct {
26272627 .rhs = undefined,
26282628 },
26292629 }),
2630 .MultilineStringLiteralLine => {
2630 .multiline_string_literal_line => {
26312631 const first_line = p.nextToken();
2632 while (p.token_tags[p.tok_i] == .MultilineStringLiteralLine) {
2632 while (p.token_tags[p.tok_i] == .multiline_string_literal_line) {
26332633 p.tok_i += 1;
26342634 }
26352635 return p.addNode(.{
......@@ -2641,23 +2641,23 @@ const Parser = struct {
26412641 },
26422642 });
26432643 },
2644 .Identifier => switch (p.token_tags[p.tok_i + 1]) {
2645 .Colon => switch (p.token_tags[p.tok_i + 2]) {
2646 .Keyword_inline => {
2644 .identifier => switch (p.token_tags[p.tok_i + 1]) {
2645 .colon => switch (p.token_tags[p.tok_i + 2]) {
2646 .keyword_inline => {
26472647 p.tok_i += 3;
26482648 switch (p.token_tags[p.tok_i]) {
2649 .Keyword_for => return p.parseForTypeExpr(),
2650 .Keyword_while => return p.parseWhileTypeExpr(),
2649 .keyword_for => return p.parseForTypeExpr(),
2650 .keyword_while => return p.parseWhileTypeExpr(),
26512651 else => return p.fail(.{
26522652 .ExpectedInlinable = .{ .token = p.tok_i },
26532653 }),
26542654 }
26552655 },
2656 .Keyword_for => {
2656 .keyword_for => {
26572657 p.tok_i += 2;
26582658 return p.parseForTypeExpr();
26592659 },
2660 .Keyword_while => {
2660 .keyword_while => {
26612661 p.tok_i += 2;
26622662 return p.parseWhileTypeExpr();
26632663 },
......@@ -2679,8 +2679,8 @@ const Parser = struct {
26792679 },
26802680 }),
26812681 },
2682 .Period => switch (p.token_tags[p.tok_i + 1]) {
2683 .Identifier => return p.addNode(.{
2682 .period => switch (p.token_tags[p.tok_i + 1]) {
2683 .identifier => return p.addNode(.{
26842684 .tag = .EnumLiteral,
26852685 .data = .{
26862686 .lhs = p.nextToken(), // dot
......@@ -2688,14 +2688,14 @@ const Parser = struct {
26882688 },
26892689 .main_token = p.nextToken(), // identifier
26902690 }),
2691 .LBrace => {
2691 .l_brace => {
26922692 const lbrace = p.tok_i + 1;
26932693 p.tok_i = lbrace + 1;
26942694
26952695 // If there are 0, 1, or 2 items, we can use ArrayInitDotTwo/StructInitDotTwo;
26962696 // otherwise we use the full ArrayInitDot/StructInitDot.
26972697
2698 if (p.eatToken(.RBrace)) |_| {
2698 if (p.eatToken(.r_brace)) |_| {
26992699 return p.addNode(.{
27002700 .tag = .StructInitDotTwo,
27012701 .main_token = lbrace,
......@@ -2707,8 +2707,8 @@ const Parser = struct {
27072707 }
27082708 const field_init_one = try p.parseFieldInit();
27092709 if (field_init_one != 0) {
2710 const comma_one = p.eatToken(.Comma);
2711 if (p.eatToken(.RBrace)) |_| {
2710 const comma_one = p.eatToken(.comma);
2711 if (p.eatToken(.r_brace)) |_| {
27122712 return p.addNode(.{
27132713 .tag = if (comma_one != null) .StructInitDotTwoComma else .StructInitDotTwo,
27142714 .main_token = lbrace,
......@@ -2720,12 +2720,12 @@ const Parser = struct {
27202720 }
27212721 if (comma_one == null) {
27222722 try p.warn(.{
2723 .ExpectedToken = .{ .token = p.tok_i, .expected_id = .Comma },
2723 .ExpectedToken = .{ .token = p.tok_i, .expected_id = .comma },
27242724 });
27252725 }
27262726 const field_init_two = try p.expectFieldInit();
2727 const comma_two = p.eatToken(.Comma);
2728 if (p.eatToken(.RBrace)) |_| {
2727 const comma_two = p.eatToken(.comma);
2728 if (p.eatToken(.r_brace)) |_| {
27292729 return p.addNode(.{
27302730 .tag = if (comma_two != null) .StructInitDotTwoComma else .StructInitDotTwo,
27312731 .main_token = lbrace,
......@@ -2737,30 +2737,30 @@ const Parser = struct {
27372737 }
27382738 if (comma_two == null) {
27392739 try p.warn(.{
2740 .ExpectedToken = .{ .token = p.tok_i, .expected_id = .Comma },
2740 .ExpectedToken = .{ .token = p.tok_i, .expected_id = .comma },
27412741 });
27422742 }
27432743 var init_list = std.ArrayList(Node.Index).init(p.gpa);
27442744 defer init_list.deinit();
27452745
2746 try init_list.appendSlice(&[_]Node.Index{ field_init_one, field_init_two });
2746 try init_list.appendSlice(&.{ field_init_one, field_init_two });
27472747
27482748 while (true) {
27492749 const next = try p.expectFieldInit();
27502750 assert(next != 0);
27512751 try init_list.append(next);
27522752 switch (p.token_tags[p.nextToken()]) {
2753 .Comma => {
2754 if (p.eatToken(.RBrace)) |_| break;
2753 .comma => {
2754 if (p.eatToken(.r_brace)) |_| break;
27552755 continue;
27562756 },
2757 .RBrace => break,
2758 .Colon, .RParen, .RBracket => {
2757 .r_brace => break,
2758 .colon, .r_paren, .r_bracket => {
27592759 p.tok_i -= 1;
27602760 return p.fail(.{
27612761 .ExpectedToken = .{
27622762 .token = p.tok_i,
2763 .expected_id = .RBrace,
2763 .expected_id = .r_brace,
27642764 },
27652765 });
27662766 },
......@@ -2769,14 +2769,14 @@ const Parser = struct {
27692769 try p.warn(.{
27702770 .ExpectedToken = .{
27712771 .token = p.tok_i,
2772 .expected_id = .Comma,
2772 .expected_id = .comma,
27732773 },
27742774 });
27752775 },
27762776 }
27772777 }
27782778 const span = try p.listToSpan(init_list.items);
2779 const trailing_comma = p.token_tags[p.tok_i - 2] == .Comma;
2779 const trailing_comma = p.token_tags[p.tok_i - 2] == .comma;
27802780 return p.addNode(.{
27812781 .tag = if (trailing_comma) .StructInitDotComma else .StructInitDot,
27822782 .main_token = lbrace,
......@@ -2788,8 +2788,8 @@ const Parser = struct {
27882788 }
27892789
27902790 const elem_init_one = try p.expectExpr();
2791 const comma_one = p.eatToken(.Comma);
2792 if (p.eatToken(.RBrace)) |_| {
2791 const comma_one = p.eatToken(.comma);
2792 if (p.eatToken(.r_brace)) |_| {
27932793 return p.addNode(.{
27942794 .tag = if (comma_one != null) .ArrayInitDotTwoComma else .ArrayInitDotTwo,
27952795 .main_token = lbrace,
......@@ -2801,12 +2801,12 @@ const Parser = struct {
28012801 }
28022802 if (comma_one == null) {
28032803 try p.warn(.{
2804 .ExpectedToken = .{ .token = p.tok_i, .expected_id = .Comma },
2804 .ExpectedToken = .{ .token = p.tok_i, .expected_id = .comma },
28052805 });
28062806 }
28072807 const elem_init_two = try p.expectExpr();
2808 const comma_two = p.eatToken(.Comma);
2809 if (p.eatToken(.RBrace)) |_| {
2808 const comma_two = p.eatToken(.comma);
2809 if (p.eatToken(.r_brace)) |_| {
28102810 return p.addNode(.{
28112811 .tag = if (comma_two != null) .ArrayInitDotTwoComma else .ArrayInitDotTwo,
28122812 .main_token = lbrace,
......@@ -2818,30 +2818,30 @@ const Parser = struct {
28182818 }
28192819 if (comma_two == null) {
28202820 try p.warn(.{
2821 .ExpectedToken = .{ .token = p.tok_i, .expected_id = .Comma },
2821 .ExpectedToken = .{ .token = p.tok_i, .expected_id = .comma },
28222822 });
28232823 }
28242824 var init_list = std.ArrayList(Node.Index).init(p.gpa);
28252825 defer init_list.deinit();
28262826
2827 try init_list.appendSlice(&[_]Node.Index{ elem_init_one, elem_init_two });
2827 try init_list.appendSlice(&.{ elem_init_one, elem_init_two });
28282828
28292829 while (true) {
28302830 const next = try p.expectExpr();
28312831 if (next == 0) break;
28322832 try init_list.append(next);
28332833 switch (p.token_tags[p.nextToken()]) {
2834 .Comma => {
2835 if (p.eatToken(.RBrace)) |_| break;
2834 .comma => {
2835 if (p.eatToken(.r_brace)) |_| break;
28362836 continue;
28372837 },
2838 .RBrace => break,
2839 .Colon, .RParen, .RBracket => {
2838 .r_brace => break,
2839 .colon, .r_paren, .r_bracket => {
28402840 p.tok_i -= 1;
28412841 return p.fail(.{
28422842 .ExpectedToken = .{
28432843 .token = p.tok_i,
2844 .expected_id = .RBrace,
2844 .expected_id = .r_brace,
28452845 },
28462846 });
28472847 },
......@@ -2850,7 +2850,7 @@ const Parser = struct {
28502850 try p.warn(.{
28512851 .ExpectedToken = .{
28522852 .token = p.tok_i,
2853 .expected_id = .Comma,
2853 .expected_id = .comma,
28542854 },
28552855 });
28562856 },
......@@ -2858,7 +2858,7 @@ const Parser = struct {
28582858 }
28592859 const span = try p.listToSpan(init_list.items);
28602860 return p.addNode(.{
2861 .tag = if (p.token_tags[p.tok_i - 2] == .Comma) .ArrayInitDotComma else .ArrayInitDot,
2861 .tag = if (p.token_tags[p.tok_i - 2] == .comma) .ArrayInitDotComma else .ArrayInitDot,
28622862 .main_token = lbrace,
28632863 .data = .{
28642864 .lhs = span.start,
......@@ -2868,12 +2868,12 @@ const Parser = struct {
28682868 },
28692869 else => return null_node,
28702870 },
2871 .Keyword_error => switch (p.token_tags[p.tok_i + 1]) {
2872 .LBrace => {
2871 .keyword_error => switch (p.token_tags[p.tok_i + 1]) {
2872 .l_brace => {
28732873 const error_token = p.tok_i;
28742874 p.tok_i += 2;
28752875
2876 if (p.eatToken(.RBrace)) |rbrace| {
2876 if (p.eatToken(.r_brace)) |rbrace| {
28772877 return p.addNode(.{
28782878 .tag = .ErrorSetDecl,
28792879 .main_token = error_token,
......@@ -2886,19 +2886,19 @@ const Parser = struct {
28862886
28872887 while (true) {
28882888 const doc_comment = p.eatDocComments();
2889 const identifier = try p.expectToken(.Identifier);
2889 const identifier = try p.expectToken(.identifier);
28902890 switch (p.token_tags[p.nextToken()]) {
2891 .Comma => {
2892 if (p.eatToken(.RBrace)) |_| break;
2891 .comma => {
2892 if (p.eatToken(.r_brace)) |_| break;
28932893 continue;
28942894 },
2895 .RBrace => break,
2896 .Colon, .RParen, .RBracket => {
2895 .r_brace => break,
2896 .colon, .r_paren, .r_bracket => {
28972897 p.tok_i -= 1;
28982898 return p.fail(.{
28992899 .ExpectedToken = .{
29002900 .token = p.tok_i,
2901 .expected_id = .RBrace,
2901 .expected_id = .r_brace,
29022902 },
29032903 });
29042904 },
......@@ -2907,7 +2907,7 @@ const Parser = struct {
29072907 // give an error but continue parsing this list.
29082908 p.tok_i -= 1;
29092909 try p.warn(.{
2910 .ExpectedToken = .{ .token = p.tok_i, .expected_id = .Comma },
2910 .ExpectedToken = .{ .token = p.tok_i, .expected_id = .comma },
29112911 });
29122912 },
29132913 }
......@@ -2925,17 +2925,17 @@ const Parser = struct {
29252925 .tag = .ErrorValue,
29262926 .main_token = p.nextToken(),
29272927 .data = .{
2928 .lhs = try p.expectToken(.Period),
2929 .rhs = try p.expectToken(.Identifier),
2928 .lhs = try p.expectToken(.period),
2929 .rhs = try p.expectToken(.identifier),
29302930 },
29312931 }),
29322932 },
2933 .LParen => return p.addNode(.{
2933 .l_paren => return p.addNode(.{
29342934 .tag = .GroupedExpression,
29352935 .main_token = p.nextToken(),
29362936 .data = .{
29372937 .lhs = try p.expectExpr(),
2938 .rhs = try p.expectToken(.RParen),
2938 .rhs = try p.expectToken(.r_paren),
29392939 },
29402940 }),
29412941 else => return null_node,
......@@ -2953,14 +2953,14 @@ const Parser = struct {
29532953 /// ForPrefix <- KEYWORD_for LPAREN Expr RPAREN PtrIndexPayload
29542954 /// ForTypeExpr <- ForPrefix TypeExpr (KEYWORD_else TypeExpr)?
29552955 fn parseForTypeExpr(p: *Parser) !Node.Index {
2956 const for_token = p.eatToken(.Keyword_for) orelse return null_node;
2957 _ = try p.expectToken(.LParen);
2956 const for_token = p.eatToken(.keyword_for) orelse return null_node;
2957 _ = try p.expectToken(.l_paren);
29582958 const array_expr = try p.expectTypeExpr();
2959 _ = try p.expectToken(.RParen);
2959 _ = try p.expectToken(.r_paren);
29602960 _ = try p.parsePtrIndexPayload();
29612961
29622962 const then_expr = try p.expectExpr();
2963 const else_token = p.eatToken(.Keyword_else) orelse {
2963 const else_token = p.eatToken(.keyword_else) orelse {
29642964 return p.addNode(.{
29652965 .tag = .ForSimple,
29662966 .main_token = for_token,
......@@ -2987,15 +2987,15 @@ const Parser = struct {
29872987 /// WhilePrefix <- KEYWORD_while LPAREN Expr RPAREN PtrPayload? WhileContinueExpr?
29882988 /// WhileTypeExpr <- WhilePrefix TypeExpr (KEYWORD_else Payload? TypeExpr)?
29892989 fn parseWhileTypeExpr(p: *Parser) !Node.Index {
2990 const while_token = p.eatToken(.Keyword_while) orelse return null_node;
2991 _ = try p.expectToken(.LParen);
2990 const while_token = p.eatToken(.keyword_while) orelse return null_node;
2991 _ = try p.expectToken(.l_paren);
29922992 const condition = try p.expectExpr();
2993 _ = try p.expectToken(.RParen);
2993 _ = try p.expectToken(.r_paren);
29942994 const then_payload = try p.parsePtrPayload();
29952995 const cont_expr = try p.parseWhileContinueExpr();
29962996
29972997 const then_expr = try p.expectTypeExpr();
2998 const else_token = p.eatToken(.Keyword_else) orelse {
2998 const else_token = p.eatToken(.keyword_else) orelse {
29992999 if (cont_expr == 0) {
30003000 return p.addNode(.{
30013001 .tag = .WhileSimple,
......@@ -3037,14 +3037,14 @@ const Parser = struct {
30373037
30383038 /// SwitchExpr <- KEYWORD_switch LPAREN Expr RPAREN LBRACE SwitchProngList RBRACE
30393039 fn expectSwitchExpr(p: *Parser) !Node.Index {
3040 const switch_token = p.assertToken(.Keyword_switch);
3041 _ = try p.expectToken(.LParen);
3040 const switch_token = p.assertToken(.keyword_switch);
3041 _ = try p.expectToken(.l_paren);
30423042 const expr_node = try p.expectExpr();
3043 _ = try p.expectToken(.RParen);
3044 _ = try p.expectToken(.LBrace);
3043 _ = try p.expectToken(.r_paren);
3044 _ = try p.expectToken(.l_brace);
30453045 const cases = try p.parseSwitchProngList();
3046 const trailing_comma = p.token_tags[p.tok_i - 1] == .Comma;
3047 _ = try p.expectToken(.RBrace);
3046 const trailing_comma = p.token_tags[p.tok_i - 1] == .comma;
3047 _ = try p.expectToken(.r_brace);
30483048
30493049 return p.addNode(.{
30503050 .tag = if (trailing_comma) .SwitchComma else .Switch,
......@@ -3067,12 +3067,12 @@ const Parser = struct {
30673067 /// AsmOutputList <- (AsmOutputItem COMMA)* AsmOutputItem?
30683068 /// AsmInputList <- (AsmInputItem COMMA)* AsmInputItem?
30693069 fn expectAsmExpr(p: *Parser) !Node.Index {
3070 const asm_token = p.assertToken(.Keyword_asm);
3071 _ = p.eatToken(.Keyword_volatile);
3072 _ = try p.expectToken(.LParen);
3070 const asm_token = p.assertToken(.keyword_asm);
3071 _ = p.eatToken(.keyword_volatile);
3072 _ = try p.expectToken(.l_paren);
30733073 const template = try p.expectExpr();
30743074
3075 if (p.eatToken(.RParen)) |rparen| {
3075 if (p.eatToken(.r_paren)) |rparen| {
30763076 return p.addNode(.{
30773077 .tag = .AsmSimple,
30783078 .main_token = asm_token,
......@@ -3083,7 +3083,7 @@ const Parser = struct {
30833083 });
30843084 }
30853085
3086 _ = try p.expectToken(.Colon);
3086 _ = try p.expectToken(.colon);
30873087
30883088 var list = std.ArrayList(Node.Index).init(p.gpa);
30893089 defer list.deinit();
......@@ -3093,51 +3093,51 @@ const Parser = struct {
30933093 if (output_item == 0) break;
30943094 try list.append(output_item);
30953095 switch (p.token_tags[p.tok_i]) {
3096 .Comma => p.tok_i += 1,
3097 .Colon, .RParen, .RBrace, .RBracket => break, // All possible delimiters.
3096 .comma => p.tok_i += 1,
3097 .colon, .r_paren, .r_brace, .r_bracket => break, // All possible delimiters.
30983098 else => {
30993099 // This is likely just a missing comma;
31003100 // give an error but continue parsing this list.
31013101 try p.warn(.{
3102 .ExpectedToken = .{ .token = p.tok_i, .expected_id = .Comma },
3102 .ExpectedToken = .{ .token = p.tok_i, .expected_id = .comma },
31033103 });
31043104 },
31053105 }
31063106 }
3107 if (p.eatToken(.Colon)) |_| {
3107 if (p.eatToken(.colon)) |_| {
31083108 while (true) {
31093109 const input_item = try p.parseAsmInputItem();
31103110 if (input_item == 0) break;
31113111 try list.append(input_item);
31123112 switch (p.token_tags[p.tok_i]) {
3113 .Comma => p.tok_i += 1,
3114 .Colon, .RParen, .RBrace, .RBracket => break, // All possible delimiters.
3113 .comma => p.tok_i += 1,
3114 .colon, .r_paren, .r_brace, .r_bracket => break, // All possible delimiters.
31153115 else => {
31163116 // This is likely just a missing comma;
31173117 // give an error but continue parsing this list.
31183118 try p.warn(.{
3119 .ExpectedToken = .{ .token = p.tok_i, .expected_id = .Comma },
3119 .ExpectedToken = .{ .token = p.tok_i, .expected_id = .comma },
31203120 });
31213121 },
31223122 }
31233123 }
3124 if (p.eatToken(.Colon)) |_| {
3125 while (p.eatToken(.StringLiteral)) |_| {
3124 if (p.eatToken(.colon)) |_| {
3125 while (p.eatToken(.string_literal)) |_| {
31263126 switch (p.token_tags[p.tok_i]) {
3127 .Comma => p.tok_i += 1,
3128 .Colon, .RParen, .RBrace, .RBracket => break,
3127 .comma => p.tok_i += 1,
3128 .colon, .r_paren, .r_brace, .r_bracket => break,
31293129 else => {
31303130 // This is likely just a missing comma;
31313131 // give an error but continue parsing this list.
31323132 try p.warn(.{
3133 .ExpectedToken = .{ .token = p.tok_i, .expected_id = .Comma },
3133 .ExpectedToken = .{ .token = p.tok_i, .expected_id = .comma },
31343134 });
31353135 },
31363136 }
31373137 }
31383138 }
31393139 }
3140 const rparen = try p.expectToken(.RParen);
3140 const rparen = try p.expectToken(.r_paren);
31413141 const span = try p.listToSpan(list.items);
31423142 return p.addNode(.{
31433143 .tag = .Asm,
......@@ -3155,20 +3155,20 @@ const Parser = struct {
31553155
31563156 /// AsmOutputItem <- LBRACKET IDENTIFIER RBRACKET STRINGLITERAL LPAREN (MINUSRARROW TypeExpr / IDENTIFIER) RPAREN
31573157 fn parseAsmOutputItem(p: *Parser) !Node.Index {
3158 _ = p.eatToken(.LBracket) orelse return null_node;
3159 const identifier = try p.expectToken(.Identifier);
3160 _ = try p.expectToken(.RBracket);
3161 _ = try p.expectToken(.StringLiteral);
3162 _ = try p.expectToken(.LParen);
3158 _ = p.eatToken(.l_bracket) orelse return null_node;
3159 const identifier = try p.expectToken(.identifier);
3160 _ = try p.expectToken(.r_bracket);
3161 _ = try p.expectToken(.string_literal);
3162 _ = try p.expectToken(.l_paren);
31633163 const type_expr: Node.Index = blk: {
3164 if (p.eatToken(.Arrow)) |_| {
3164 if (p.eatToken(.arrow)) |_| {
31653165 break :blk try p.expectTypeExpr();
31663166 } else {
3167 _ = try p.expectToken(.Identifier);
3167 _ = try p.expectToken(.identifier);
31683168 break :blk null_node;
31693169 }
31703170 };
3171 const rparen = try p.expectToken(.RParen);
3171 const rparen = try p.expectToken(.r_paren);
31723172 return p.addNode(.{
31733173 .tag = .AsmOutput,
31743174 .main_token = identifier,
......@@ -3181,13 +3181,13 @@ const Parser = struct {
31813181
31823182 /// AsmInputItem <- LBRACKET IDENTIFIER RBRACKET STRINGLITERAL LPAREN Expr RPAREN
31833183 fn parseAsmInputItem(p: *Parser) !Node.Index {
3184 _ = p.eatToken(.LBracket) orelse return null_node;
3185 const identifier = try p.expectToken(.Identifier);
3186 _ = try p.expectToken(.RBracket);
3187 _ = try p.expectToken(.StringLiteral);
3188 _ = try p.expectToken(.LParen);
3184 _ = p.eatToken(.l_bracket) orelse return null_node;
3185 const identifier = try p.expectToken(.identifier);
3186 _ = try p.expectToken(.r_bracket);
3187 _ = try p.expectToken(.string_literal);
3188 _ = try p.expectToken(.l_paren);
31893189 const expr = try p.expectExpr();
3190 const rparen = try p.expectToken(.RParen);
3190 const rparen = try p.expectToken(.r_paren);
31913191 return p.addNode(.{
31923192 .tag = .AsmInput,
31933193 .main_token = identifier,
......@@ -3200,14 +3200,14 @@ const Parser = struct {
32003200
32013201 /// BreakLabel <- COLON IDENTIFIER
32023202 fn parseBreakLabel(p: *Parser) !TokenIndex {
3203 _ = p.eatToken(.Colon) orelse return @as(TokenIndex, 0);
3204 return p.expectToken(.Identifier);
3203 _ = p.eatToken(.colon) orelse return @as(TokenIndex, 0);
3204 return p.expectToken(.identifier);
32053205 }
32063206
32073207 /// BlockLabel <- IDENTIFIER COLON
32083208 fn parseBlockLabel(p: *Parser) TokenIndex {
3209 if (p.token_tags[p.tok_i] == .Identifier and
3210 p.token_tags[p.tok_i + 1] == .Colon)
3209 if (p.token_tags[p.tok_i] == .identifier and
3210 p.token_tags[p.tok_i + 1] == .colon)
32113211 {
32123212 const identifier = p.tok_i;
32133213 p.tok_i += 2;
......@@ -3218,9 +3218,9 @@ const Parser = struct {
32183218
32193219 /// FieldInit <- DOT IDENTIFIER EQUAL Expr
32203220 fn parseFieldInit(p: *Parser) !Node.Index {
3221 if (p.token_tags[p.tok_i + 0] == .Period and
3222 p.token_tags[p.tok_i + 1] == .Identifier and
3223 p.token_tags[p.tok_i + 2] == .Equal)
3221 if (p.token_tags[p.tok_i + 0] == .period and
3222 p.token_tags[p.tok_i + 1] == .identifier and
3223 p.token_tags[p.tok_i + 2] == .equal)
32243224 {
32253225 p.tok_i += 3;
32263226 return p.expectExpr();
......@@ -3230,37 +3230,37 @@ const Parser = struct {
32303230 }
32313231
32323232 fn expectFieldInit(p: *Parser) !Node.Index {
3233 _ = try p.expectToken(.Period);
3234 _ = try p.expectToken(.Identifier);
3235 _ = try p.expectToken(.Equal);
3233 _ = try p.expectToken(.period);
3234 _ = try p.expectToken(.identifier);
3235 _ = try p.expectToken(.equal);
32363236 return p.expectExpr();
32373237 }
32383238
32393239 /// WhileContinueExpr <- COLON LPAREN AssignExpr RPAREN
32403240 fn parseWhileContinueExpr(p: *Parser) !Node.Index {
3241 _ = p.eatToken(.Colon) orelse return null_node;
3242 _ = try p.expectToken(.LParen);
3241 _ = p.eatToken(.colon) orelse return null_node;
3242 _ = try p.expectToken(.l_paren);
32433243 const node = try p.parseAssignExpr();
32443244 if (node == 0) return p.fail(.{ .ExpectedExprOrAssignment = .{ .token = p.tok_i } });
3245 _ = try p.expectToken(.RParen);
3245 _ = try p.expectToken(.r_paren);
32463246 return node;
32473247 }
32483248
32493249 /// LinkSection <- KEYWORD_linksection LPAREN Expr RPAREN
32503250 fn parseLinkSection(p: *Parser) !Node.Index {
3251 _ = p.eatToken(.Keyword_linksection) orelse return null_node;
3252 _ = try p.expectToken(.LParen);
3251 _ = p.eatToken(.keyword_linksection) orelse return null_node;
3252 _ = try p.expectToken(.l_paren);
32533253 const expr_node = try p.expectExpr();
3254 _ = try p.expectToken(.RParen);
3254 _ = try p.expectToken(.r_paren);
32553255 return expr_node;
32563256 }
32573257
32583258 /// CallConv <- KEYWORD_callconv LPAREN Expr RPAREN
32593259 fn parseCallconv(p: *Parser) !Node.Index {
3260 _ = p.eatToken(.Keyword_callconv) orelse return null_node;
3261 _ = try p.expectToken(.LParen);
3260 _ = p.eatToken(.keyword_callconv) orelse return null_node;
3261 _ = try p.expectToken(.l_paren);
32623262 const expr_node = try p.expectExpr();
3263 _ = try p.expectToken(.RParen);
3263 _ = try p.expectToken(.r_paren);
32643264 return expr_node;
32653265 }
32663266
......@@ -3276,20 +3276,20 @@ const Parser = struct {
32763276 fn expectParamDecl(p: *Parser) !Node.Index {
32773277 _ = p.eatDocComments();
32783278 switch (p.token_tags[p.tok_i]) {
3279 .Keyword_noalias, .Keyword_comptime => p.tok_i += 1,
3280 .Ellipsis3 => {
3279 .keyword_noalias, .keyword_comptime => p.tok_i += 1,
3280 .ellipsis3 => {
32813281 p.tok_i += 1;
32823282 return null_node;
32833283 },
32843284 else => {},
32853285 }
3286 if (p.token_tags[p.tok_i] == .Identifier and
3287 p.token_tags[p.tok_i + 1] == .Colon)
3286 if (p.token_tags[p.tok_i] == .identifier and
3287 p.token_tags[p.tok_i + 1] == .colon)
32883288 {
32893289 p.tok_i += 2;
32903290 }
32913291 switch (p.token_tags[p.tok_i]) {
3292 .Keyword_anytype => {
3292 .keyword_anytype => {
32933293 p.tok_i += 1;
32943294 return null_node;
32953295 },
......@@ -3299,31 +3299,31 @@ const Parser = struct {
32993299
33003300 /// Payload <- PIPE IDENTIFIER PIPE
33013301 fn parsePayload(p: *Parser) !TokenIndex {
3302 _ = p.eatToken(.Pipe) orelse return @as(TokenIndex, 0);
3303 const identifier = try p.expectToken(.Identifier);
3304 _ = try p.expectToken(.Pipe);
3302 _ = p.eatToken(.pipe) orelse return @as(TokenIndex, 0);
3303 const identifier = try p.expectToken(.identifier);
3304 _ = try p.expectToken(.pipe);
33053305 return identifier;
33063306 }
33073307
33083308 /// PtrPayload <- PIPE ASTERISK? IDENTIFIER PIPE
33093309 fn parsePtrPayload(p: *Parser) !TokenIndex {
3310 _ = p.eatToken(.Pipe) orelse return @as(TokenIndex, 0);
3311 _ = p.eatToken(.Asterisk);
3312 const identifier = try p.expectToken(.Identifier);
3313 _ = try p.expectToken(.Pipe);
3310 _ = p.eatToken(.pipe) orelse return @as(TokenIndex, 0);
3311 _ = p.eatToken(.asterisk);
3312 const identifier = try p.expectToken(.identifier);
3313 _ = try p.expectToken(.pipe);
33143314 return identifier;
33153315 }
33163316
33173317 /// PtrIndexPayload <- PIPE ASTERISK? IDENTIFIER (COMMA IDENTIFIER)? PIPE
33183318 /// Returns the first identifier token, if any.
33193319 fn parsePtrIndexPayload(p: *Parser) !TokenIndex {
3320 _ = p.eatToken(.Pipe) orelse return @as(TokenIndex, 0);
3321 _ = p.eatToken(.Asterisk);
3322 const identifier = try p.expectToken(.Identifier);
3323 if (p.eatToken(.Comma) != null) {
3324 _ = try p.expectToken(.Identifier);
3320 _ = p.eatToken(.pipe) orelse return @as(TokenIndex, 0);
3321 _ = p.eatToken(.asterisk);
3322 const identifier = try p.expectToken(.identifier);
3323 if (p.eatToken(.comma) != null) {
3324 _ = try p.expectToken(.identifier);
33253325 }
3326 _ = try p.expectToken(.Pipe);
3326 _ = try p.expectToken(.pipe);
33273327 return identifier;
33283328 }
33293329
......@@ -3332,8 +3332,8 @@ const Parser = struct {
33323332 /// <- SwitchItem (COMMA SwitchItem)* COMMA?
33333333 /// / KEYWORD_else
33343334 fn parseSwitchProng(p: *Parser) !Node.Index {
3335 if (p.eatToken(.Keyword_else)) |_| {
3336 const arrow_token = try p.expectToken(.EqualAngleBracketRight);
3335 if (p.eatToken(.keyword_else)) |_| {
3336 const arrow_token = try p.expectToken(.equal_angle_bracket_right);
33373337 _ = try p.parsePtrPayload();
33383338 return p.addNode(.{
33393339 .tag = .SwitchCaseOne,
......@@ -3347,7 +3347,7 @@ const Parser = struct {
33473347 const first_item = try p.parseSwitchItem();
33483348 if (first_item == 0) return null_node;
33493349
3350 if (p.eatToken(.EqualAngleBracketRight)) |arrow_token| {
3350 if (p.eatToken(.equal_angle_bracket_right)) |arrow_token| {
33513351 _ = try p.parsePtrPayload();
33523352 return p.addNode(.{
33533353 .tag = .SwitchCaseOne,
......@@ -3363,13 +3363,13 @@ const Parser = struct {
33633363 defer list.deinit();
33643364
33653365 try list.append(first_item);
3366 while (p.eatToken(.Comma)) |_| {
3366 while (p.eatToken(.comma)) |_| {
33673367 const next_item = try p.parseSwitchItem();
33683368 if (next_item == 0) break;
33693369 try list.append(next_item);
33703370 }
33713371 const span = try p.listToSpan(list.items);
3372 const arrow_token = try p.expectToken(.EqualAngleBracketRight);
3372 const arrow_token = try p.expectToken(.equal_angle_bracket_right);
33733373 _ = try p.parsePtrPayload();
33743374 return p.addNode(.{
33753375 .tag = .SwitchCase,
......@@ -3389,7 +3389,7 @@ const Parser = struct {
33893389 const expr = try p.parseExpr();
33903390 if (expr == 0) return null_node;
33913391
3392 if (p.eatToken(.Ellipsis3)) |token| {
3392 if (p.eatToken(.ellipsis3)) |token| {
33933393 return p.addNode(.{
33943394 .tag = .SwitchRange,
33953395 .main_token = token,
......@@ -3419,25 +3419,25 @@ const Parser = struct {
34193419 var saw_allowzero = false;
34203420 while (true) {
34213421 switch (p.token_tags[p.tok_i]) {
3422 .Keyword_align => {
3422 .keyword_align => {
34233423 if (result.align_node != 0) {
34243424 try p.warn(.{
34253425 .ExtraAlignQualifier = .{ .token = p.tok_i },
34263426 });
34273427 }
34283428 p.tok_i += 1;
3429 _ = try p.expectToken(.LParen);
3429 _ = try p.expectToken(.l_paren);
34303430 result.align_node = try p.expectExpr();
34313431
3432 if (p.eatToken(.Colon)) |_| {
3432 if (p.eatToken(.colon)) |_| {
34333433 result.bit_range_start = try p.expectExpr();
3434 _ = try p.expectToken(.Colon);
3434 _ = try p.expectToken(.colon);
34353435 result.bit_range_end = try p.expectExpr();
34363436 }
34373437
3438 _ = try p.expectToken(.RParen);
3438 _ = try p.expectToken(.r_paren);
34393439 },
3440 .Keyword_const => {
3440 .keyword_const => {
34413441 if (saw_const) {
34423442 try p.warn(.{
34433443 .ExtraConstQualifier = .{ .token = p.tok_i },
......@@ -3446,7 +3446,7 @@ const Parser = struct {
34463446 p.tok_i += 1;
34473447 saw_const = true;
34483448 },
3449 .Keyword_volatile => {
3449 .keyword_volatile => {
34503450 if (saw_volatile) {
34513451 try p.warn(.{
34523452 .ExtraVolatileQualifier = .{ .token = p.tok_i },
......@@ -3455,7 +3455,7 @@ const Parser = struct {
34553455 p.tok_i += 1;
34563456 saw_volatile = true;
34573457 },
3458 .Keyword_allowzero => {
3458 .keyword_allowzero => {
34593459 if (saw_allowzero) {
34603460 try p.warn(.{
34613461 .ExtraAllowZeroQualifier = .{ .token = p.tok_i },
......@@ -3476,14 +3476,14 @@ const Parser = struct {
34763476 /// / DOTQUESTIONMARK
34773477 fn parseSuffixOp(p: *Parser, lhs: Node.Index) !Node.Index {
34783478 switch (p.token_tags[p.tok_i]) {
3479 .LBracket => {
3479 .l_bracket => {
34803480 const lbracket = p.nextToken();
34813481 const index_expr = try p.expectExpr();
34823482
3483 if (p.eatToken(.Ellipsis2)) |_| {
3483 if (p.eatToken(.ellipsis2)) |_| {
34843484 const end_expr = try p.parseExpr();
34853485 if (end_expr == 0) {
3486 _ = try p.expectToken(.RBracket);
3486 _ = try p.expectToken(.r_bracket);
34873487 return p.addNode(.{
34883488 .tag = .SliceOpen,
34893489 .main_token = lbracket,
......@@ -3493,9 +3493,9 @@ const Parser = struct {
34933493 },
34943494 });
34953495 }
3496 if (p.eatToken(.Colon)) |_| {
3496 if (p.eatToken(.colon)) |_| {
34973497 const sentinel = try p.parseExpr();
3498 _ = try p.expectToken(.RBracket);
3498 _ = try p.expectToken(.r_bracket);
34993499 return p.addNode(.{
35003500 .tag = .SliceSentinel,
35013501 .main_token = lbracket,
......@@ -3509,7 +3509,7 @@ const Parser = struct {
35093509 },
35103510 });
35113511 } else {
3512 _ = try p.expectToken(.RBracket);
3512 _ = try p.expectToken(.r_bracket);
35133513 return p.addNode(.{
35143514 .tag = .Slice,
35153515 .main_token = lbracket,
......@@ -3523,7 +3523,7 @@ const Parser = struct {
35233523 });
35243524 }
35253525 }
3526 _ = try p.expectToken(.RBracket);
3526 _ = try p.expectToken(.r_bracket);
35273527 return p.addNode(.{
35283528 .tag = .ArrayAccess,
35293529 .main_token = lbracket,
......@@ -3533,7 +3533,7 @@ const Parser = struct {
35333533 },
35343534 });
35353535 },
3536 .PeriodAsterisk => return p.addNode(.{
3536 .period_asterisk => return p.addNode(.{
35373537 .tag = .Deref,
35383538 .main_token = p.nextToken(),
35393539 .data = .{
......@@ -3541,7 +3541,7 @@ const Parser = struct {
35413541 .rhs = undefined,
35423542 },
35433543 }),
3544 .Invalid_periodasterisks => {
3544 .invalid_periodasterisks => {
35453545 const period_asterisk = p.nextToken();
35463546 try p.warn(.{ .AsteriskAfterPointerDereference = .{ .token = period_asterisk } });
35473547 return p.addNode(.{
......@@ -3553,8 +3553,8 @@ const Parser = struct {
35533553 },
35543554 });
35553555 },
3556 .Period => switch (p.token_tags[p.tok_i + 1]) {
3557 .Identifier => return p.addNode(.{
3556 .period => switch (p.token_tags[p.tok_i + 1]) {
3557 .identifier => return p.addNode(.{
35583558 .tag = .FieldAccess,
35593559 .main_token = p.nextToken(),
35603560 .data = .{
......@@ -3562,7 +3562,7 @@ const Parser = struct {
35623562 .rhs = p.nextToken(),
35633563 },
35643564 }),
3565 .QuestionMark => return p.addNode(.{
3565 .question_mark => return p.addNode(.{
35663566 .tag = .UnwrapOptional,
35673567 .main_token = p.nextToken(),
35683568 .data = .{
......@@ -3589,28 +3589,28 @@ const Parser = struct {
35893589 fn parseContainerDeclAuto(p: *Parser) !Node.Index {
35903590 const main_token = p.nextToken();
35913591 const arg_expr = switch (p.token_tags[main_token]) {
3592 .Keyword_struct, .Keyword_opaque => null_node,
3593 .Keyword_enum => blk: {
3594 if (p.eatToken(.LParen)) |_| {
3592 .keyword_struct, .keyword_opaque => null_node,
3593 .keyword_enum => blk: {
3594 if (p.eatToken(.l_paren)) |_| {
35953595 const expr = try p.expectExpr();
3596 _ = try p.expectToken(.RParen);
3596 _ = try p.expectToken(.r_paren);
35973597 break :blk expr;
35983598 } else {
35993599 break :blk null_node;
36003600 }
36013601 },
3602 .Keyword_union => blk: {
3603 if (p.eatToken(.LParen)) |_| {
3604 if (p.eatToken(.Keyword_enum)) |_| {
3605 if (p.eatToken(.LParen)) |_| {
3602 .keyword_union => blk: {
3603 if (p.eatToken(.l_paren)) |_| {
3604 if (p.eatToken(.keyword_enum)) |_| {
3605 if (p.eatToken(.l_paren)) |_| {
36063606 const enum_tag_expr = try p.expectExpr();
3607 _ = try p.expectToken(.RParen);
3608 _ = try p.expectToken(.RParen);
3607 _ = try p.expectToken(.r_paren);
3608 _ = try p.expectToken(.r_paren);
36093609
3610 _ = try p.expectToken(.LBrace);
3610 _ = try p.expectToken(.l_brace);
36113611 const members = try p.parseContainerMembers();
36123612 const members_span = try members.toSpan(p);
3613 _ = try p.expectToken(.RBrace);
3613 _ = try p.expectToken(.r_brace);
36143614 return p.addNode(.{
36153615 .tag = switch (members.trailing_comma) {
36163616 true => .TaggedUnionEnumTagComma,
......@@ -3623,11 +3623,11 @@ const Parser = struct {
36233623 },
36243624 });
36253625 } else {
3626 _ = try p.expectToken(.RParen);
3626 _ = try p.expectToken(.r_paren);
36273627
3628 _ = try p.expectToken(.LBrace);
3628 _ = try p.expectToken(.l_brace);
36293629 const members = try p.parseContainerMembers();
3630 _ = try p.expectToken(.RBrace);
3630 _ = try p.expectToken(.r_brace);
36313631 if (members.len <= 2) {
36323632 return p.addNode(.{
36333633 .tag = switch (members.trailing_comma) {
......@@ -3657,7 +3657,7 @@ const Parser = struct {
36573657 }
36583658 } else {
36593659 const expr = try p.expectExpr();
3660 _ = try p.expectToken(.RParen);
3660 _ = try p.expectToken(.r_paren);
36613661 break :blk expr;
36623662 }
36633663 } else {
......@@ -3666,9 +3666,9 @@ const Parser = struct {
36663666 },
36673667 else => unreachable,
36683668 };
3669 _ = try p.expectToken(.LBrace);
3669 _ = try p.expectToken(.l_brace);
36703670 const members = try p.parseContainerMembers();
3671 _ = try p.expectToken(.RBrace);
3671 _ = try p.expectToken(.r_brace);
36723672 if (arg_expr == 0) {
36733673 if (members.len <= 2) {
36743674 return p.addNode(.{
......@@ -3718,10 +3718,10 @@ const Parser = struct {
37183718 /// Holds temporary data until we are ready to construct the full ContainerDecl AST node.
37193719 /// ByteAlign <- KEYWORD_align LPAREN Expr RPAREN
37203720 fn parseByteAlign(p: *Parser) !Node.Index {
3721 _ = p.eatToken(.Keyword_align) orelse return null_node;
3722 _ = try p.expectToken(.LParen);
3721 _ = p.eatToken(.keyword_align) orelse return null_node;
3722 _ = try p.expectToken(.l_paren);
37233723 const expr = try p.expectExpr();
3724 _ = try p.expectToken(.RParen);
3724 _ = try p.expectToken(.r_paren);
37253725 return expr;
37263726 }
37273727
......@@ -3732,22 +3732,22 @@ const Parser = struct {
37323732
37333733 /// ParamDeclList <- (ParamDecl COMMA)* ParamDecl?
37343734 fn parseParamDeclList(p: *Parser) !SmallSpan {
3735 _ = try p.expectToken(.LParen);
3736 if (p.eatToken(.RParen)) |_| {
3735 _ = try p.expectToken(.l_paren);
3736 if (p.eatToken(.r_paren)) |_| {
37373737 return SmallSpan{ .zero_or_one = 0 };
37383738 }
37393739 const param_one = while (true) {
37403740 const param = try p.expectParamDecl();
37413741 if (param != 0) break param;
37423742 switch (p.token_tags[p.nextToken()]) {
3743 .Comma => continue,
3744 .RParen => return SmallSpan{ .zero_or_one = 0 },
3743 .comma => continue,
3744 .r_paren => return SmallSpan{ .zero_or_one = 0 },
37453745 else => {
37463746 // This is likely just a missing comma;
37473747 // give an error but continue parsing this list.
37483748 p.tok_i -= 1;
37493749 try p.warn(.{
3750 .ExpectedToken = .{ .token = p.tok_i, .expected_id = .Comma },
3750 .ExpectedToken = .{ .token = p.tok_i, .expected_id = .comma },
37513751 });
37523752 },
37533753 }
......@@ -3755,19 +3755,19 @@ const Parser = struct {
37553755
37563756 const param_two = while (true) {
37573757 switch (p.token_tags[p.nextToken()]) {
3758 .Comma => {
3759 if (p.eatToken(.RParen)) |_| {
3758 .comma => {
3759 if (p.eatToken(.r_paren)) |_| {
37603760 return SmallSpan{ .zero_or_one = param_one };
37613761 }
37623762 const param = try p.expectParamDecl();
37633763 if (param != 0) break param;
37643764 continue;
37653765 },
3766 .RParen => return SmallSpan{ .zero_or_one = param_one },
3767 .Colon, .RBrace, .RBracket => {
3766 .r_paren => return SmallSpan{ .zero_or_one = param_one },
3767 .colon, .r_brace, .r_bracket => {
37683768 p.tok_i -= 1;
37693769 return p.fail(.{
3770 .ExpectedToken = .{ .token = p.tok_i, .expected_id = .RParen },
3770 .ExpectedToken = .{ .token = p.tok_i, .expected_id = .r_paren },
37713771 });
37723772 },
37733773 else => {
......@@ -3775,7 +3775,7 @@ const Parser = struct {
37753775 // give an error but continue parsing this list.
37763776 p.tok_i -= 1;
37773777 try p.warn(.{
3778 .ExpectedToken = .{ .token = p.tok_i, .expected_id = .Comma },
3778 .ExpectedToken = .{ .token = p.tok_i, .expected_id = .comma },
37793779 });
37803780 },
37813781 }
......@@ -3784,12 +3784,12 @@ const Parser = struct {
37843784 var list = std.ArrayList(Node.Index).init(p.gpa);
37853785 defer list.deinit();
37863786
3787 try list.appendSlice(&[_]Node.Index{ param_one, param_two });
3787 try list.appendSlice(&.{ param_one, param_two });
37883788
37893789 while (true) {
37903790 switch (p.token_tags[p.nextToken()]) {
3791 .Comma => {
3792 if (p.token_tags[p.tok_i] == .RParen) {
3791 .comma => {
3792 if (p.token_tags[p.tok_i] == .r_paren) {
37933793 p.tok_i += 1;
37943794 return SmallSpan{ .multi = list.toOwnedSlice() };
37953795 }
......@@ -3799,11 +3799,11 @@ const Parser = struct {
37993799 }
38003800 continue;
38013801 },
3802 .RParen => return SmallSpan{ .multi = list.toOwnedSlice() },
3803 .Colon, .RBrace, .RBracket => {
3802 .r_paren => return SmallSpan{ .multi = list.toOwnedSlice() },
3803 .colon, .r_brace, .r_bracket => {
38043804 p.tok_i -= 1;
38053805 return p.fail(.{
3806 .ExpectedToken = .{ .token = p.tok_i, .expected_id = .RParen },
3806 .ExpectedToken = .{ .token = p.tok_i, .expected_id = .r_paren },
38073807 });
38083808 },
38093809 else => {
......@@ -3811,7 +3811,7 @@ const Parser = struct {
38113811 // give an error but continue parsing this list.
38123812 p.tok_i -= 1;
38133813 try p.warn(.{
3814 .ExpectedToken = .{ .token = p.tok_i, .expected_id = .Comma },
3814 .ExpectedToken = .{ .token = p.tok_i, .expected_id = .comma },
38153815 });
38163816 },
38173817 }
......@@ -3833,14 +3833,14 @@ const Parser = struct {
38333833 try list.append(item);
38343834
38353835 switch (p.token_tags[p.tok_i]) {
3836 .Comma => p.tok_i += 1,
3836 .comma => p.tok_i += 1,
38373837 // all possible delimiters
3838 .Colon, .RParen, .RBrace, .RBracket => break,
3838 .colon, .r_paren, .r_brace, .r_bracket => break,
38393839 else => {
38403840 // This is likely just a missing comma;
38413841 // give an error but continue parsing this list.
38423842 try p.warn(.{
3843 .ExpectedToken = .{ .token = p.tok_i, .expected_id = .Comma },
3843 .ExpectedToken = .{ .token = p.tok_i, .expected_id = .comma },
38443844 });
38453845 },
38463846 }
......@@ -3853,8 +3853,8 @@ const Parser = struct {
38533853 /// FnCallArguments <- LPAREN ExprList RPAREN
38543854 /// ExprList <- (Expr COMMA)* Expr?
38553855 fn parseBuiltinCall(p: *Parser) !Node.Index {
3856 const builtin_token = p.assertToken(.Builtin);
3857 _ = (try p.expectTokenRecoverable(.LParen)) orelse {
3856 const builtin_token = p.assertToken(.builtin);
3857 _ = (try p.expectTokenRecoverable(.l_paren)) orelse {
38583858 try p.warn(.{
38593859 .ExpectedParamList = .{ .token = p.tok_i },
38603860 });
......@@ -3868,7 +3868,7 @@ const Parser = struct {
38683868 },
38693869 });
38703870 };
3871 if (p.eatToken(.RParen)) |_| {
3871 if (p.eatToken(.r_paren)) |_| {
38723872 return p.addNode(.{
38733873 .tag = .BuiltinCallTwo,
38743874 .main_token = builtin_token,
......@@ -3880,8 +3880,8 @@ const Parser = struct {
38803880 }
38813881 const param_one = try p.expectExpr();
38823882 switch (p.token_tags[p.nextToken()]) {
3883 .Comma => {
3884 if (p.eatToken(.RParen)) |_| {
3883 .comma => {
3884 if (p.eatToken(.r_paren)) |_| {
38853885 return p.addNode(.{
38863886 .tag = .BuiltinCallTwoComma,
38873887 .main_token = builtin_token,
......@@ -3892,7 +3892,7 @@ const Parser = struct {
38923892 });
38933893 }
38943894 },
3895 .RParen => return p.addNode(.{
3895 .r_paren => return p.addNode(.{
38963896 .tag = .BuiltinCallTwo,
38973897 .main_token = builtin_token,
38983898 .data = .{
......@@ -3905,14 +3905,14 @@ const Parser = struct {
39053905 // give an error but continue parsing this list.
39063906 p.tok_i -= 1;
39073907 try p.warn(.{
3908 .ExpectedToken = .{ .token = p.tok_i, .expected_id = .Comma },
3908 .ExpectedToken = .{ .token = p.tok_i, .expected_id = .comma },
39093909 });
39103910 },
39113911 }
39123912 const param_two = try p.expectExpr();
39133913 switch (p.token_tags[p.nextToken()]) {
3914 .Comma => {
3915 if (p.eatToken(.RParen)) |_| {
3914 .comma => {
3915 if (p.eatToken(.r_paren)) |_| {
39163916 return p.addNode(.{
39173917 .tag = .BuiltinCallTwoComma,
39183918 .main_token = builtin_token,
......@@ -3923,7 +3923,7 @@ const Parser = struct {
39233923 });
39243924 }
39253925 },
3926 .RParen => return p.addNode(.{
3926 .r_paren => return p.addNode(.{
39273927 .tag = .BuiltinCallTwo,
39283928 .main_token = builtin_token,
39293929 .data = .{
......@@ -3936,7 +3936,7 @@ const Parser = struct {
39363936 // give an error but continue parsing this list.
39373937 p.tok_i -= 1;
39383938 try p.warn(.{
3939 .ExpectedToken = .{ .token = p.tok_i, .expected_id = .Comma },
3939 .ExpectedToken = .{ .token = p.tok_i, .expected_id = .comma },
39403940 });
39413941 },
39423942 }
......@@ -3944,14 +3944,14 @@ const Parser = struct {
39443944 var list = std.ArrayList(Node.Index).init(p.gpa);
39453945 defer list.deinit();
39463946
3947 try list.appendSlice(&[_]Node.Index{ param_one, param_two });
3947 try list.appendSlice(&.{ param_one, param_two });
39483948
39493949 while (true) {
39503950 const param = try p.expectExpr();
39513951 try list.append(param);
39523952 switch (p.token_tags[p.nextToken()]) {
3953 .Comma => {
3954 if (p.eatToken(.RParen)) |_| {
3953 .comma => {
3954 if (p.eatToken(.r_paren)) |_| {
39553955 const params = try p.listToSpan(list.items);
39563956 return p.addNode(.{
39573957 .tag = .BuiltinCallComma,
......@@ -3964,7 +3964,7 @@ const Parser = struct {
39643964 }
39653965 continue;
39663966 },
3967 .RParen => {
3967 .r_paren => {
39683968 const params = try p.listToSpan(list.items);
39693969 return p.addNode(.{
39703970 .tag = .BuiltinCall,
......@@ -3980,7 +3980,7 @@ const Parser = struct {
39803980 // give an error but continue parsing this list.
39813981 p.tok_i -= 1;
39823982 try p.warn(.{
3983 .ExpectedToken = .{ .token = p.tok_i, .expected_id = .Comma },
3983 .ExpectedToken = .{ .token = p.tok_i, .expected_id = .comma },
39843984 });
39853985 },
39863986 }
......@@ -3990,7 +3990,7 @@ const Parser = struct {
39903990 // string literal or multiline string literal
39913991 fn parseStringLiteral(p: *Parser) !Node.Index {
39923992 switch (p.token_tags[p.tok_i]) {
3993 .StringLiteral => {
3993 .string_literal => {
39943994 const main_token = p.nextToken();
39953995 return p.addNode(.{
39963996 .tag = .StringLiteral,
......@@ -4001,9 +4001,9 @@ const Parser = struct {
40014001 },
40024002 });
40034003 },
4004 .MultilineStringLiteralLine => {
4004 .multiline_string_literal_line => {
40054005 const first_line = p.nextToken();
4006 while (p.token_tags[p.tok_i] == .MultilineStringLiteralLine) {
4006 while (p.token_tags[p.tok_i] == .multiline_string_literal_line) {
40074007 p.tok_i += 1;
40084008 }
40094009 return p.addNode(.{
......@@ -4030,7 +4030,7 @@ const Parser = struct {
40304030 fn expectIntegerLiteral(p: *Parser) !Node.Index {
40314031 return p.addNode(.{
40324032 .tag = .IntegerLiteral,
4033 .main_token = try p.expectToken(.IntegerLiteral),
4033 .main_token = try p.expectToken(.integer_literal),
40344034 .data = .{
40354035 .lhs = undefined,
40364036 .rhs = undefined,
......@@ -4040,16 +4040,16 @@ const Parser = struct {
40404040
40414041 /// KEYWORD_if LPAREN Expr RPAREN PtrPayload? Body (KEYWORD_else Payload? Body)?
40424042 fn parseIf(p: *Parser, bodyParseFn: NodeParseFn) !Node.Index {
4043 const if_token = p.eatToken(.Keyword_if) orelse return null_node;
4044 _ = try p.expectToken(.LParen);
4043 const if_token = p.eatToken(.keyword_if) orelse return null_node;
4044 _ = try p.expectToken(.l_paren);
40454045 const condition = try p.expectExpr();
4046 _ = try p.expectToken(.RParen);
4046 _ = try p.expectToken(.r_paren);
40474047 const then_payload = try p.parsePtrPayload();
40484048
40494049 const then_expr = try bodyParseFn(p);
40504050 if (then_expr == 0) return p.fail(.{ .InvalidToken = .{ .token = p.tok_i } });
40514051
4052 const else_token = p.eatToken(.Keyword_else) orelse return p.addNode(.{
4052 const else_token = p.eatToken(.keyword_else) orelse return p.addNode(.{
40534053 .tag = .IfSimple,
40544054 .main_token = if_token,
40554055 .data = .{
......@@ -4076,8 +4076,8 @@ const Parser = struct {
40764076
40774077 /// Skips over doc comment tokens. Returns the first one, if any.
40784078 fn eatDocComments(p: *Parser) ?TokenIndex {
4079 if (p.eatToken(.DocComment)) |first_line| {
4080 while (p.eatToken(.DocComment)) |_| {}
4079 if (p.eatToken(.doc_comment)) |first_line| {
4080 while (p.eatToken(.doc_comment)) |_| {}
40814081 return first_line;
40824082 }
40834083 return null;
......@@ -4089,7 +4089,7 @@ const Parser = struct {
40894089
40904090 /// Eat a single-line doc comment on the same line as another node
40914091 fn parseAppendedDocComment(p: *Parser, after_token: TokenIndex) !void {
4092 const comment_token = p.eatToken(.DocComment) orelse return;
4092 const comment_token = p.eatToken(.doc_comment) orelse return;
40934093 if (!p.tokensOnSameLine(after_token, comment_token)) {
40944094 p.tok_i -= 1;
40954095 }
lib/std/zig/render.zig+77-77
......@@ -107,12 +107,12 @@ fn renderMember(ais: *Ais, tree: ast.Tree, decl: ast.Node.Index, space: Space) E
107107 while (i > 0) {
108108 i -= 1;
109109 switch (token_tags[i]) {
110 .Keyword_extern,
111 .Keyword_export,
112 .Keyword_pub,
113 .StringLiteral,
114 .Keyword_inline,
115 .Keyword_noinline,
110 .keyword_extern,
111 .keyword_export,
112 .keyword_pub,
113 .string_literal,
114 .keyword_inline,
115 .keyword_noinline,
116116 => continue,
117117
118118 else => {
......@@ -144,7 +144,7 @@ fn renderMember(ais: *Ais, tree: ast.Tree, decl: ast.Node.Index, space: Space) E
144144 .UsingNamespace => {
145145 const main_token = main_tokens[decl];
146146 const expr = datas[decl].lhs;
147 if (main_token > 0 and token_tags[main_token - 1] == .Keyword_pub) {
147 if (main_token > 0 and token_tags[main_token - 1] == .keyword_pub) {
148148 try renderToken(ais, tree, main_token - 1, .Space); // pub
149149 }
150150 try renderToken(ais, tree, main_token, .Space); // usingnamespace
......@@ -160,7 +160,7 @@ fn renderMember(ais: *Ais, tree: ast.Tree, decl: ast.Node.Index, space: Space) E
160160 .TestDecl => {
161161 const test_token = main_tokens[decl];
162162 try renderToken(ais, tree, test_token, .Space);
163 if (token_tags[test_token + 1] == .StringLiteral) {
163 if (token_tags[test_token + 1] == .string_literal) {
164164 try renderToken(ais, tree, test_token + 1, .Space);
165165 }
166166 try renderExpression(ais, tree, datas[decl].rhs, space);
......@@ -269,13 +269,13 @@ fn renderExpression(ais: *Ais, tree: ast.Tree, node: ast.Node.Index, space: Spac
269269
270270 try renderExpression(ais, tree, datas[node].lhs, .Space); // target
271271
272 if (token_tags[fallback_first - 1] == .Pipe) {
272 if (token_tags[fallback_first - 1] == .pipe) {
273273 try renderToken(ais, tree, main_token, .Space); // catch keyword
274274 try renderToken(ais, tree, main_token + 1, .None); // pipe
275275 try renderToken(ais, tree, main_token + 2, .None); // payload identifier
276276 try renderToken(ais, tree, main_token + 3, after_op_space); // pipe
277277 } else {
278 assert(token_tags[fallback_first - 1] == .Keyword_catch);
278 assert(token_tags[fallback_first - 1] == .keyword_catch);
279279 try renderToken(ais, tree, main_token, after_op_space); // catch keyword
280280 }
281281
......@@ -532,22 +532,22 @@ fn renderExpression(ais: *Ais, tree: ast.Tree, node: ast.Node.Index, space: Spac
532532 // There is nothing between the braces so render condensed: `error{}`
533533 try renderToken(ais, tree, lbrace, .None);
534534 return renderToken(ais, tree, rbrace, space);
535 } else if (lbrace + 2 == rbrace and token_tags[lbrace + 1] == .Identifier) {
535 } else if (lbrace + 2 == rbrace and token_tags[lbrace + 1] == .identifier) {
536536 // There is exactly one member and no trailing comma or
537537 // comments, so render without surrounding spaces: `error{Foo}`
538538 try renderToken(ais, tree, lbrace, .None);
539539 try renderToken(ais, tree, lbrace + 1, .None); // identifier
540540 return renderToken(ais, tree, rbrace, space);
541 } else if (token_tags[rbrace - 1] == .Comma) {
541 } else if (token_tags[rbrace - 1] == .comma) {
542542 // There is a trailing comma so render each member on a new line.
543543 try renderToken(ais, tree, lbrace, .Newline);
544544 ais.pushIndent();
545545 var i = lbrace + 1;
546546 while (i < rbrace) : (i += 1) {
547547 switch (token_tags[i]) {
548 .DocComment => try renderToken(ais, tree, i, .Newline),
549 .Identifier => try renderToken(ais, tree, i, .Comma),
550 .Comma => {},
548 .doc_comment => try renderToken(ais, tree, i, .Newline),
549 .identifier => try renderToken(ais, tree, i, .Comma),
550 .comma => {},
551551 else => unreachable,
552552 }
553553 }
......@@ -559,9 +559,9 @@ fn renderExpression(ais: *Ais, tree: ast.Tree, node: ast.Node.Index, space: Spac
559559 var i = lbrace + 1;
560560 while (i < rbrace) : (i += 1) {
561561 switch (token_tags[i]) {
562 .DocComment => unreachable, // TODO
563 .Identifier => try renderToken(ais, tree, i, .CommaSpace),
564 .Comma => {},
562 .doc_comment => unreachable, // TODO
563 .identifier => try renderToken(ais, tree, i, .CommaSpace),
564 .comma => {},
565565 else => unreachable,
566566 }
567567 }
......@@ -701,7 +701,7 @@ fn renderPtrType(
701701 // in such a relationship. If so, skip rendering anything for
702702 // this pointer type and rely on the child to render our asterisk
703703 // as well when it renders the ** token.
704 if (tree.tokens.items(.tag)[ptr_type.ast.main_token] == .AsteriskAsterisk and
704 if (tree.tokens.items(.tag)[ptr_type.ast.main_token] == .asterisk_asterisk and
705705 ptr_type.ast.main_token == tree.nodes.items(.main_token)[ptr_type.ast.child_type])
706706 {
707707 return renderExpression(ais, tree, ptr_type.ast.child_type, space);
......@@ -823,7 +823,7 @@ fn renderAsmOutput(
823823 try renderToken(ais, tree, symbolic_name + 2, .Space); // "constraint"
824824 try renderToken(ais, tree, symbolic_name + 3, .None); // lparen
825825
826 if (token_tags[symbolic_name + 4] == .Arrow) {
826 if (token_tags[symbolic_name + 4] == .arrow) {
827827 try renderToken(ais, tree, symbolic_name + 4, .Space); // ->
828828 try renderExpression(ais, tree, datas[asm_output].lhs, Space.None);
829829 return renderToken(ais, tree, datas[asm_output].rhs, space); // rparen
......@@ -982,7 +982,7 @@ fn renderWhile(ais: *Ais, tree: ast.Tree, while_node: ast.full.While, space: Spa
982982 try renderToken(ais, tree, payload_token - 2, .Space); // )
983983 try renderToken(ais, tree, payload_token - 1, .None); // |
984984 const ident = blk: {
985 if (token_tags[payload_token] == .Asterisk) {
985 if (token_tags[payload_token] == .asterisk) {
986986 try renderToken(ais, tree, payload_token, .None); // *
987987 break :blk payload_token + 1;
988988 } else {
......@@ -991,7 +991,7 @@ fn renderWhile(ais: *Ais, tree: ast.Tree, while_node: ast.full.While, space: Spa
991991 };
992992 try renderToken(ais, tree, ident, .None); // identifier
993993 const pipe = blk: {
994 if (token_tags[ident + 1] == .Comma) {
994 if (token_tags[ident + 1] == .comma) {
995995 try renderToken(ais, tree, ident + 1, .Space); // ,
996996 try renderToken(ais, tree, ident + 2, .None); // index
997997 break :blk payload_token + 3;
......@@ -1035,7 +1035,7 @@ fn renderWhile(ais: *Ais, tree: ast.Tree, while_node: ast.full.While, space: Spa
10351035 try renderToken(ais, tree, payload_token - 2, .Space); // )
10361036 try renderToken(ais, tree, payload_token - 1, .None); // |
10371037 const ident = blk: {
1038 if (token_tags[payload_token] == .Asterisk) {
1038 if (token_tags[payload_token] == .asterisk) {
10391039 try renderToken(ais, tree, payload_token, .None); // *
10401040 break :blk payload_token + 1;
10411041 } else {
......@@ -1044,7 +1044,7 @@ fn renderWhile(ais: *Ais, tree: ast.Tree, while_node: ast.full.While, space: Spa
10441044 };
10451045 try renderToken(ais, tree, ident, .None); // identifier
10461046 const pipe = blk: {
1047 if (token_tags[ident + 1] == .Comma) {
1047 if (token_tags[ident + 1] == .comma) {
10481048 try renderToken(ais, tree, ident + 1, .Space); // ,
10491049 try renderToken(ais, tree, ident + 2, .None); // index
10501050 break :blk payload_token + 3;
......@@ -1108,7 +1108,7 @@ fn renderWhile(ais: *Ais, tree: ast.Tree, while_node: ast.full.While, space: Spa
11081108 try renderToken(ais, tree, payload_token - 2, .Space); // )
11091109 try renderToken(ais, tree, payload_token - 1, .None); // |
11101110 const ident = blk: {
1111 if (token_tags[payload_token] == .Asterisk) {
1111 if (token_tags[payload_token] == .asterisk) {
11121112 try renderToken(ais, tree, payload_token, .None); // *
11131113 break :blk payload_token + 1;
11141114 } else {
......@@ -1117,7 +1117,7 @@ fn renderWhile(ais: *Ais, tree: ast.Tree, while_node: ast.full.While, space: Spa
11171117 };
11181118 try renderToken(ais, tree, ident, .None); // identifier
11191119 const pipe = blk: {
1120 if (token_tags[ident + 1] == .Comma) {
1120 if (token_tags[ident + 1] == .comma) {
11211121 try renderToken(ais, tree, ident + 1, .Space); // ,
11221122 try renderToken(ais, tree, ident + 2, .None); // index
11231123 break :blk payload_token + 3;
......@@ -1227,7 +1227,7 @@ fn renderBuiltinCall(
12271227 const last_param = params[params.len - 1];
12281228 const after_last_param_token = tree.lastToken(last_param) + 1;
12291229
1230 if (token_tags[after_last_param_token] != .Comma) {
1230 if (token_tags[after_last_param_token] != .comma) {
12311231 // Render all on one line, no trailing comma.
12321232 try renderToken(ais, tree, builtin_token + 1, .None); // (
12331233
......@@ -1259,7 +1259,7 @@ fn renderFnProto(ais: *Ais, tree: ast.Tree, fn_proto: ast.full.FnProto, space: S
12591259 const token_starts = tree.tokens.items(.start);
12601260
12611261 const after_fn_token = fn_proto.ast.fn_token + 1;
1262 const lparen = if (token_tags[after_fn_token] == .Identifier) blk: {
1262 const lparen = if (token_tags[after_fn_token] == .identifier) blk: {
12631263 try renderToken(ais, tree, fn_proto.ast.fn_token, .Space); // fn
12641264 try renderToken(ais, tree, after_fn_token, .None); // name
12651265 break :blk after_fn_token + 1;
......@@ -1267,7 +1267,7 @@ fn renderFnProto(ais: *Ais, tree: ast.Tree, fn_proto: ast.full.FnProto, space: S
12671267 try renderToken(ais, tree, fn_proto.ast.fn_token, .Space); // fn
12681268 break :blk fn_proto.ast.fn_token + 1;
12691269 };
1270 assert(token_tags[lparen] == .LParen);
1270 assert(token_tags[lparen] == .l_paren);
12711271
12721272 const maybe_bang = tree.firstToken(fn_proto.ast.return_type) - 1;
12731273 const rparen = blk: {
......@@ -1301,11 +1301,11 @@ fn renderFnProto(ais: *Ais, tree: ast.Tree, fn_proto: ast.full.FnProto, space: S
13011301 }
13021302 break :blk rparen;
13031303 };
1304 assert(token_tags[rparen] == .RParen);
1304 assert(token_tags[rparen] == .r_paren);
13051305
13061306 // The params list is a sparse set that does *not* include anytype or ... parameters.
13071307
1308 if (token_tags[rparen - 1] != .Comma) {
1308 if (token_tags[rparen - 1] != .comma) {
13091309 // Render all on one line, no trailing comma.
13101310 try renderToken(ais, tree, lparen, .None); // (
13111311
......@@ -1314,39 +1314,39 @@ fn renderFnProto(ais: *Ais, tree: ast.Tree, fn_proto: ast.full.FnProto, space: S
13141314 while (true) {
13151315 last_param_token += 1;
13161316 switch (token_tags[last_param_token]) {
1317 .DocComment => {
1317 .doc_comment => {
13181318 try renderToken(ais, tree, last_param_token, .Newline);
13191319 continue;
13201320 },
1321 .Ellipsis3 => {
1321 .ellipsis3 => {
13221322 try renderToken(ais, tree, last_param_token, .None); // ...
13231323 break;
13241324 },
1325 .Keyword_noalias, .Keyword_comptime => {
1325 .keyword_noalias, .keyword_comptime => {
13261326 try renderToken(ais, tree, last_param_token, .Space);
13271327 last_param_token += 1;
13281328 },
1329 .Identifier => {},
1330 .Keyword_anytype => {
1329 .identifier => {},
1330 .keyword_anytype => {
13311331 try renderToken(ais, tree, last_param_token, .None); // anytype
13321332 continue;
13331333 },
1334 .RParen => break,
1335 .Comma => {
1334 .r_paren => break,
1335 .comma => {
13361336 try renderToken(ais, tree, last_param_token, .Space); // ,
13371337 last_param_token += 1;
13381338 },
13391339 else => {}, // Parameter type without a name.
13401340 }
1341 if (token_tags[last_param_token] == .Identifier and
1342 token_tags[last_param_token + 1] == .Colon)
1341 if (token_tags[last_param_token] == .identifier and
1342 token_tags[last_param_token + 1] == .colon)
13431343 {
13441344 try renderToken(ais, tree, last_param_token, .None); // name
13451345 last_param_token += 1;
13461346 try renderToken(ais, tree, last_param_token, .Space); // :
13471347 last_param_token += 1;
13481348 }
1349 if (token_tags[last_param_token] == .Keyword_anytype) {
1349 if (token_tags[last_param_token] == .keyword_anytype) {
13501350 try renderToken(ais, tree, last_param_token, .None); // anytype
13511351 continue;
13521352 }
......@@ -1365,33 +1365,33 @@ fn renderFnProto(ais: *Ais, tree: ast.Tree, fn_proto: ast.full.FnProto, space: S
13651365 while (true) {
13661366 last_param_token += 1;
13671367 switch (token_tags[last_param_token]) {
1368 .DocComment => {
1368 .doc_comment => {
13691369 try renderToken(ais, tree, last_param_token, .Newline);
13701370 continue;
13711371 },
1372 .Ellipsis3 => {
1372 .ellipsis3 => {
13731373 try renderToken(ais, tree, last_param_token, .Comma); // ...
13741374 break;
13751375 },
1376 .Keyword_noalias, .Keyword_comptime => {
1376 .keyword_noalias, .keyword_comptime => {
13771377 try renderToken(ais, tree, last_param_token, .Space);
13781378 last_param_token += 1;
13791379 },
1380 .Identifier => {},
1381 .Keyword_anytype => {
1380 .identifier => {},
1381 .keyword_anytype => {
13821382 try renderToken(ais, tree, last_param_token, .Comma); // anytype
13831383 continue;
13841384 },
1385 .RParen => break,
1385 .r_paren => break,
13861386 else => unreachable,
13871387 }
1388 if (token_tags[last_param_token] == .Identifier) {
1388 if (token_tags[last_param_token] == .identifier) {
13891389 try renderToken(ais, tree, last_param_token, .None); // name
13901390 last_param_token += 1;
13911391 try renderToken(ais, tree, last_param_token, .Space); // :
13921392 last_param_token += 1;
13931393 }
1394 if (token_tags[last_param_token] == .Keyword_anytype) {
1394 if (token_tags[last_param_token] == .keyword_anytype) {
13951395 try renderToken(ais, tree, last_param_token, .Comma); // anytype
13961396 continue;
13971397 }
......@@ -1435,7 +1435,7 @@ fn renderFnProto(ais: *Ais, tree: ast.Tree, fn_proto: ast.full.FnProto, space: S
14351435 try renderToken(ais, tree, callconv_rparen, .Space); // )
14361436 }
14371437
1438 if (token_tags[maybe_bang] == .Bang) {
1438 if (token_tags[maybe_bang] == .bang) {
14391439 try renderToken(ais, tree, maybe_bang, .None); // !
14401440 }
14411441 return renderExpression(ais, tree, fn_proto.ast.return_type, space);
......@@ -1448,7 +1448,7 @@ fn renderSwitchCase(
14481448 space: Space,
14491449) Error!void {
14501450 const token_tags = tree.tokens.items(.tag);
1451 const trailing_comma = token_tags[switch_case.ast.arrow_token - 1] == .Comma;
1451 const trailing_comma = token_tags[switch_case.ast.arrow_token - 1] == .comma;
14521452
14531453 // Render everything before the arrow
14541454 if (switch_case.ast.values.len == 0) {
......@@ -1473,7 +1473,7 @@ fn renderSwitchCase(
14731473
14741474 if (switch_case.payload_token) |payload_token| {
14751475 try renderToken(ais, tree, payload_token - 1, .None); // pipe
1476 if (token_tags[payload_token] == .Asterisk) {
1476 if (token_tags[payload_token] == .asterisk) {
14771477 try renderToken(ais, tree, payload_token, .None); // asterisk
14781478 try renderToken(ais, tree, payload_token + 1, .None); // identifier
14791479 try renderToken(ais, tree, payload_token + 2, .Space); // pipe
......@@ -1498,8 +1498,8 @@ fn renderBlock(
14981498 const nodes_data = tree.nodes.items(.data);
14991499 const lbrace = tree.nodes.items(.main_token)[block_node];
15001500
1501 if (token_tags[lbrace - 1] == .Colon and
1502 token_tags[lbrace - 2] == .Identifier)
1501 if (token_tags[lbrace - 1] == .colon and
1502 token_tags[lbrace - 2] == .identifier)
15031503 {
15041504 try renderToken(ais, tree, lbrace - 2, .None);
15051505 try renderToken(ais, tree, lbrace - 1, .Space);
......@@ -1547,7 +1547,7 @@ fn renderStructInit(
15471547 }
15481548 const last_field = struct_init.ast.fields[struct_init.ast.fields.len - 1];
15491549 const last_field_token = tree.lastToken(last_field);
1550 if (token_tags[last_field_token + 1] == .Comma) {
1550 if (token_tags[last_field_token + 1] == .comma) {
15511551 // Render one field init per line.
15521552 ais.pushIndent();
15531553 try renderToken(ais, tree, struct_init.ast.lbrace, .Newline);
......@@ -1597,7 +1597,7 @@ fn renderArrayInit(
15971597 }
15981598 const last_elem = array_init.ast.elements[array_init.ast.elements.len - 1];
15991599 const last_elem_token = tree.lastToken(last_elem);
1600 if (token_tags[last_elem_token + 1] == .Comma) {
1600 if (token_tags[last_elem_token + 1] == .comma) {
16011601 // Render one element per line.
16021602 ais.pushIndent();
16031603 try renderToken(ais, tree, array_init.ast.lbrace, .Newline);
......@@ -1673,16 +1673,16 @@ fn renderContainerDecl(
16731673 const last_member = container_decl.ast.members[container_decl.ast.members.len - 1];
16741674 const last_member_token = tree.lastToken(last_member);
16751675 const rbrace = switch (token_tags[last_member_token + 1]) {
1676 .DocComment => last_member_token + 2,
1677 .Comma, .Semicolon => switch (token_tags[last_member_token + 2]) {
1678 .DocComment => last_member_token + 3,
1679 .RBrace => last_member_token + 2,
1676 .doc_comment => last_member_token + 2,
1677 .comma, .semicolon => switch (token_tags[last_member_token + 2]) {
1678 .doc_comment => last_member_token + 3,
1679 .r_brace => last_member_token + 2,
16801680 else => unreachable,
16811681 },
1682 .RBrace => last_member_token + 1,
1682 .r_brace => last_member_token + 1,
16831683 else => unreachable,
16841684 };
1685 const src_has_trailing_comma = token_tags[last_member_token + 1] == .Comma;
1685 const src_has_trailing_comma = token_tags[last_member_token + 1] == .comma;
16861686
16871687 if (!src_has_trailing_comma) one_line: {
16881688 // We can only print all the members in-line if all the members are fields.
......@@ -1734,8 +1734,8 @@ fn renderAsm(
17341734 try renderToken(ais, tree, tok_i, .None);
17351735 tok_i += 1;
17361736 switch (token_tags[tok_i]) {
1737 .RParen => return renderToken(ais, tree, tok_i, space),
1738 .Comma => try renderToken(ais, tree, tok_i, .Space),
1737 .r_paren => return renderToken(ais, tree, tok_i, space),
1738 .comma => try renderToken(ais, tree, tok_i, .Space),
17391739 else => unreachable,
17401740 }
17411741 }
......@@ -1775,7 +1775,7 @@ fn renderAsm(
17751775 const comma_or_colon = tree.lastToken(asm_output) + 1;
17761776 ais.popIndent();
17771777 break :colon2 switch (token_tags[comma_or_colon]) {
1778 .Comma => comma_or_colon + 1,
1778 .comma => comma_or_colon + 1,
17791779 else => comma_or_colon,
17801780 };
17811781 }
......@@ -1806,7 +1806,7 @@ fn renderAsm(
18061806 const comma_or_colon = tree.lastToken(asm_input) + 1;
18071807 ais.popIndent();
18081808 break :colon3 switch (token_tags[comma_or_colon]) {
1809 .Comma => comma_or_colon + 1,
1809 .comma => comma_or_colon + 1,
18101810 else => comma_or_colon,
18111811 };
18121812 }
......@@ -1819,13 +1819,13 @@ fn renderAsm(
18191819 var tok_i = first_clobber;
18201820 while (true) {
18211821 switch (token_tags[tok_i + 1]) {
1822 .RParen => {
1822 .r_paren => {
18231823 ais.setIndentDelta(indent_delta);
18241824 ais.popIndent();
18251825 try renderToken(ais, tree, tok_i, .Newline);
18261826 return renderToken(ais, tree, tok_i + 1, space);
18271827 },
1828 .Comma => {
1828 .comma => {
18291829 try renderToken(ais, tree, tok_i, .None);
18301830 try renderToken(ais, tree, tok_i + 1, .Space);
18311831 tok_i += 2;
......@@ -1859,7 +1859,7 @@ fn renderCall(
18591859
18601860 const last_param = params[params.len - 1];
18611861 const after_last_param_tok = tree.lastToken(last_param) + 1;
1862 if (token_tags[after_last_param_tok] == .Comma) {
1862 if (token_tags[after_last_param_tok] == .comma) {
18631863 ais.pushIndent();
18641864 try renderToken(ais, tree, lparen, Space.Newline); // (
18651865 for (params) |param_node, i| {
......@@ -1868,7 +1868,7 @@ fn renderCall(
18681868
18691869 // Unindent the comma for multiline string literals
18701870 const is_multiline_string = node_tags[param_node] == .StringLiteral and
1871 token_tags[main_tokens[param_node]] == .MultilineStringLiteralLine;
1871 token_tags[main_tokens[param_node]] == .multiline_string_literal_line;
18721872 if (is_multiline_string) ais.popIndent();
18731873
18741874 const comma = tree.lastToken(param_node) + 1;
......@@ -1900,7 +1900,7 @@ fn renderCall(
19001900fn renderExpressionComma(ais: *Ais, tree: ast.Tree, node: ast.Node.Index, space: Space) Error!void {
19011901 const token_tags = tree.tokens.items(.tag);
19021902 const maybe_comma = tree.lastToken(node) + 1;
1903 if (token_tags[maybe_comma] == .Comma) {
1903 if (token_tags[maybe_comma] == .comma) {
19041904 try renderExpression(ais, tree, node, .None);
19051905 return renderToken(ais, tree, maybe_comma, space);
19061906 } else {
......@@ -1911,7 +1911,7 @@ fn renderExpressionComma(ais: *Ais, tree: ast.Tree, node: ast.Node.Index, space:
19111911fn renderTokenComma(ais: *Ais, tree: ast.Tree, token: ast.TokenIndex, space: Space) Error!void {
19121912 const token_tags = tree.tokens.items(.tag);
19131913 const maybe_comma = token + 1;
1914 if (token_tags[maybe_comma] == .Comma) {
1914 if (token_tags[maybe_comma] == .comma) {
19151915 try renderToken(ais, tree, token, .None);
19161916 return renderToken(ais, tree, maybe_comma, space);
19171917 } else {
......@@ -1962,7 +1962,7 @@ fn renderToken(ais: *Ais, tree: ast.Tree, token_index: ast.TokenIndex, space: Sp
19621962 .None => _ = try renderCommentsAndNewlines(ais, tree, token_start + lexeme.len, token_starts[token_index + 1]),
19631963 .Comma => {
19641964 const comment = try renderCommentsAndNewlines(ais, tree, token_start + lexeme.len, token_starts[token_index + 1]);
1965 if (token_tags[token_index + 1] == .Comma) {
1965 if (token_tags[token_index + 1] == .comma) {
19661966 return renderToken(ais, tree, token_index + 1, .Newline);
19671967 } else if (!comment) {
19681968 return ais.insertNewline();
......@@ -1970,7 +1970,7 @@ fn renderToken(ais: *Ais, tree: ast.Tree, token_index: ast.TokenIndex, space: Sp
19701970 },
19711971 .CommaSpace => {
19721972 const comment = try renderCommentsAndNewlines(ais, tree, token_start + lexeme.len, token_starts[token_index + 1]);
1973 if (token_tags[token_index + 1] == .Comma) {
1973 if (token_tags[token_index + 1] == .comma) {
19741974 return renderToken(ais, tree, token_index + 1, .Space);
19751975 } else if (!comment) {
19761976 return ais.writer().writeByte(' ');
......@@ -1978,7 +1978,7 @@ fn renderToken(ais: *Ais, tree: ast.Tree, token_index: ast.TokenIndex, space: Sp
19781978 },
19791979 .Semicolon => {
19801980 const comment = try renderCommentsAndNewlines(ais, tree, token_start + lexeme.len, token_starts[token_index + 1]);
1981 if (token_tags[token_index + 1] == .Semicolon) {
1981 if (token_tags[token_index + 1] == .semicolon) {
19821982 return renderToken(ais, tree, token_index + 1, .Newline);
19831983 } else if (!comment) {
19841984 return ais.insertNewline();
......@@ -2005,7 +2005,7 @@ fn renderDocComments(ais: *Ais, tree: ast.Tree, end_token: ast.TokenIndex) Error
20052005 const token_tags = tree.tokens.items(.tag);
20062006 if (end_token == 0) return;
20072007 var tok = end_token - 1;
2008 while (token_tags[tok] == .DocComment) {
2008 while (token_tags[tok] == .doc_comment) {
20092009 if (tok == 0) break;
20102010 tok -= 1;
20112011 } else {
......@@ -2016,7 +2016,7 @@ fn renderDocComments(ais: *Ais, tree: ast.Tree, end_token: ast.TokenIndex) Error
20162016
20172017 while (true) : (tok += 1) {
20182018 switch (token_tags[tok]) {
2019 .DocComment => {
2019 .doc_comment => {
20202020 if (first_tok < end_token) {
20212021 try renderToken(ais, tree, tok, .Newline);
20222022 } else {
lib/std/zig/tokenizer.zig+786-786
......@@ -16,58 +16,58 @@ pub const Token = struct {
1616 };
1717
1818 pub const keywords = std.ComptimeStringMap(Tag, .{
19 .{ "align", .Keyword_align },
20 .{ "allowzero", .Keyword_allowzero },
21 .{ "and", .Keyword_and },
22 .{ "anyframe", .Keyword_anyframe },
23 .{ "anytype", .Keyword_anytype },
24 .{ "asm", .Keyword_asm },
25 .{ "async", .Keyword_async },
26 .{ "await", .Keyword_await },
27 .{ "break", .Keyword_break },
28 .{ "callconv", .Keyword_callconv },
29 .{ "catch", .Keyword_catch },
30 .{ "comptime", .Keyword_comptime },
31 .{ "const", .Keyword_const },
32 .{ "continue", .Keyword_continue },
33 .{ "defer", .Keyword_defer },
34 .{ "else", .Keyword_else },
35 .{ "enum", .Keyword_enum },
36 .{ "errdefer", .Keyword_errdefer },
37 .{ "error", .Keyword_error },
38 .{ "export", .Keyword_export },
39 .{ "extern", .Keyword_extern },
40 .{ "false", .Keyword_false },
41 .{ "fn", .Keyword_fn },
42 .{ "for", .Keyword_for },
43 .{ "if", .Keyword_if },
44 .{ "inline", .Keyword_inline },
45 .{ "noalias", .Keyword_noalias },
46 .{ "noinline", .Keyword_noinline },
47 .{ "nosuspend", .Keyword_nosuspend },
48 .{ "null", .Keyword_null },
49 .{ "opaque", .Keyword_opaque },
50 .{ "or", .Keyword_or },
51 .{ "orelse", .Keyword_orelse },
52 .{ "packed", .Keyword_packed },
53 .{ "pub", .Keyword_pub },
54 .{ "resume", .Keyword_resume },
55 .{ "return", .Keyword_return },
56 .{ "linksection", .Keyword_linksection },
57 .{ "struct", .Keyword_struct },
58 .{ "suspend", .Keyword_suspend },
59 .{ "switch", .Keyword_switch },
60 .{ "test", .Keyword_test },
61 .{ "threadlocal", .Keyword_threadlocal },
62 .{ "true", .Keyword_true },
63 .{ "try", .Keyword_try },
64 .{ "undefined", .Keyword_undefined },
65 .{ "union", .Keyword_union },
66 .{ "unreachable", .Keyword_unreachable },
67 .{ "usingnamespace", .Keyword_usingnamespace },
68 .{ "var", .Keyword_var },
69 .{ "volatile", .Keyword_volatile },
70 .{ "while", .Keyword_while },
19 .{ "align", .keyword_align },
20 .{ "allowzero", .keyword_allowzero },
21 .{ "and", .keyword_and },
22 .{ "anyframe", .keyword_anyframe },
23 .{ "anytype", .keyword_anytype },
24 .{ "asm", .keyword_asm },
25 .{ "async", .keyword_async },
26 .{ "await", .keyword_await },
27 .{ "break", .keyword_break },
28 .{ "callconv", .keyword_callconv },
29 .{ "catch", .keyword_catch },
30 .{ "comptime", .keyword_comptime },
31 .{ "const", .keyword_const },
32 .{ "continue", .keyword_continue },
33 .{ "defer", .keyword_defer },
34 .{ "else", .keyword_else },
35 .{ "enum", .keyword_enum },
36 .{ "errdefer", .keyword_errdefer },
37 .{ "error", .keyword_error },
38 .{ "export", .keyword_export },
39 .{ "extern", .keyword_extern },
40 .{ "false", .keyword_false },
41 .{ "fn", .keyword_fn },
42 .{ "for", .keyword_for },
43 .{ "if", .keyword_if },
44 .{ "inline", .keyword_inline },
45 .{ "noalias", .keyword_noalias },
46 .{ "noinline", .keyword_noinline },
47 .{ "nosuspend", .keyword_nosuspend },
48 .{ "null", .keyword_null },
49 .{ "opaque", .keyword_opaque },
50 .{ "or", .keyword_or },
51 .{ "orelse", .keyword_orelse },
52 .{ "packed", .keyword_packed },
53 .{ "pub", .keyword_pub },
54 .{ "resume", .keyword_resume },
55 .{ "return", .keyword_return },
56 .{ "linksection", .keyword_linksection },
57 .{ "struct", .keyword_struct },
58 .{ "suspend", .keyword_suspend },
59 .{ "switch", .keyword_switch },
60 .{ "test", .keyword_test },
61 .{ "threadlocal", .keyword_threadlocal },
62 .{ "true", .keyword_true },
63 .{ "try", .keyword_try },
64 .{ "undefined", .keyword_undefined },
65 .{ "union", .keyword_union },
66 .{ "unreachable", .keyword_unreachable },
67 .{ "usingnamespace", .keyword_usingnamespace },
68 .{ "var", .keyword_var },
69 .{ "volatile", .keyword_volatile },
70 .{ "while", .keyword_while },
7171 });
7272
7373 pub fn getKeyword(bytes: []const u8) ?Tag {
......@@ -75,249 +75,249 @@ pub const Token = struct {
7575 }
7676
7777 pub const Tag = enum {
78 Invalid,
79 Invalid_ampersands,
80 Invalid_periodasterisks,
81 Identifier,
82 StringLiteral,
83 MultilineStringLiteralLine,
84 CharLiteral,
85 Eof,
86 Builtin,
87 Bang,
88 Pipe,
89 PipePipe,
90 PipeEqual,
91 Equal,
92 EqualEqual,
93 EqualAngleBracketRight,
94 BangEqual,
95 LParen,
96 RParen,
97 Semicolon,
98 Percent,
99 PercentEqual,
100 LBrace,
101 RBrace,
102 LBracket,
103 RBracket,
104 Period,
105 PeriodAsterisk,
106 Ellipsis2,
107 Ellipsis3,
108 Caret,
109 CaretEqual,
110 Plus,
111 PlusPlus,
112 PlusEqual,
113 PlusPercent,
114 PlusPercentEqual,
115 Minus,
116 MinusEqual,
117 MinusPercent,
118 MinusPercentEqual,
119 Asterisk,
120 AsteriskEqual,
121 AsteriskAsterisk,
122 AsteriskPercent,
123 AsteriskPercentEqual,
124 Arrow,
125 Colon,
126 Slash,
127 SlashEqual,
128 Comma,
129 Ampersand,
130 AmpersandEqual,
131 QuestionMark,
132 AngleBracketLeft,
133 AngleBracketLeftEqual,
134 AngleBracketAngleBracketLeft,
135 AngleBracketAngleBracketLeftEqual,
136 AngleBracketRight,
137 AngleBracketRightEqual,
138 AngleBracketAngleBracketRight,
139 AngleBracketAngleBracketRightEqual,
140 Tilde,
141 IntegerLiteral,
142 FloatLiteral,
143 DocComment,
144 ContainerDocComment,
145 Keyword_align,
146 Keyword_allowzero,
147 Keyword_and,
148 Keyword_anyframe,
149 Keyword_anytype,
150 Keyword_asm,
151 Keyword_async,
152 Keyword_await,
153 Keyword_break,
154 Keyword_callconv,
155 Keyword_catch,
156 Keyword_comptime,
157 Keyword_const,
158 Keyword_continue,
159 Keyword_defer,
160 Keyword_else,
161 Keyword_enum,
162 Keyword_errdefer,
163 Keyword_error,
164 Keyword_export,
165 Keyword_extern,
166 Keyword_false,
167 Keyword_fn,
168 Keyword_for,
169 Keyword_if,
170 Keyword_inline,
171 Keyword_noalias,
172 Keyword_noinline,
173 Keyword_nosuspend,
174 Keyword_null,
175 Keyword_opaque,
176 Keyword_or,
177 Keyword_orelse,
178 Keyword_packed,
179 Keyword_pub,
180 Keyword_resume,
181 Keyword_return,
182 Keyword_linksection,
183 Keyword_struct,
184 Keyword_suspend,
185 Keyword_switch,
186 Keyword_test,
187 Keyword_threadlocal,
188 Keyword_true,
189 Keyword_try,
190 Keyword_undefined,
191 Keyword_union,
192 Keyword_unreachable,
193 Keyword_usingnamespace,
194 Keyword_var,
195 Keyword_volatile,
196 Keyword_while,
78 invalid,
79 invalid_ampersands,
80 invalid_periodasterisks,
81 identifier,
82 string_literal,
83 multiline_string_literal_line,
84 char_literal,
85 eof,
86 builtin,
87 bang,
88 pipe,
89 pipe_pipe,
90 pipe_equal,
91 equal,
92 equal_equal,
93 equal_angle_bracket_right,
94 bang_equal,
95 l_paren,
96 r_paren,
97 semicolon,
98 percent,
99 percent_equal,
100 l_brace,
101 r_brace,
102 l_bracket,
103 r_bracket,
104 period,
105 period_asterisk,
106 ellipsis2,
107 ellipsis3,
108 caret,
109 caret_equal,
110 plus,
111 plus_plus,
112 plus_equal,
113 plus_percent,
114 plus_percent_equal,
115 minus,
116 minus_equal,
117 minus_percent,
118 minus_percent_equal,
119 asterisk,
120 asterisk_equal,
121 asterisk_asterisk,
122 asterisk_percent,
123 asterisk_percent_equal,
124 arrow,
125 colon,
126 slash,
127 slash_equal,
128 comma,
129 ampersand,
130 ampersand_equal,
131 question_mark,
132 angle_bracket_left,
133 angle_bracket_left_equal,
134 angle_bracket_angle_bracket_left,
135 angle_bracket_angle_bracket_left_equal,
136 angle_bracket_right,
137 angle_bracket_right_equal,
138 angle_bracket_angle_bracket_right,
139 angle_bracket_angle_bracket_right_equal,
140 tilde,
141 integer_literal,
142 float_literal,
143 doc_comment,
144 container_doc_comment,
145 keyword_align,
146 keyword_allowzero,
147 keyword_and,
148 keyword_anyframe,
149 keyword_anytype,
150 keyword_asm,
151 keyword_async,
152 keyword_await,
153 keyword_break,
154 keyword_callconv,
155 keyword_catch,
156 keyword_comptime,
157 keyword_const,
158 keyword_continue,
159 keyword_defer,
160 keyword_else,
161 keyword_enum,
162 keyword_errdefer,
163 keyword_error,
164 keyword_export,
165 keyword_extern,
166 keyword_false,
167 keyword_fn,
168 keyword_for,
169 keyword_if,
170 keyword_inline,
171 keyword_noalias,
172 keyword_noinline,
173 keyword_nosuspend,
174 keyword_null,
175 keyword_opaque,
176 keyword_or,
177 keyword_orelse,
178 keyword_packed,
179 keyword_pub,
180 keyword_resume,
181 keyword_return,
182 keyword_linksection,
183 keyword_struct,
184 keyword_suspend,
185 keyword_switch,
186 keyword_test,
187 keyword_threadlocal,
188 keyword_true,
189 keyword_try,
190 keyword_undefined,
191 keyword_union,
192 keyword_unreachable,
193 keyword_usingnamespace,
194 keyword_var,
195 keyword_volatile,
196 keyword_while,
197197
198198 pub fn lexeme(tag: Tag) ?[]const u8 {
199199 return switch (tag) {
200 .Invalid,
201 .Identifier,
202 .StringLiteral,
203 .MultilineStringLiteralLine,
204 .CharLiteral,
205 .Eof,
206 .Builtin,
207 .IntegerLiteral,
208 .FloatLiteral,
209 .DocComment,
210 .ContainerDocComment,
200 .invalid,
201 .identifier,
202 .string_literal,
203 .multiline_string_literal_line,
204 .char_literal,
205 .eof,
206 .builtin,
207 .integer_literal,
208 .float_literal,
209 .doc_comment,
210 .container_doc_comment,
211211 => null,
212212
213 .Invalid_ampersands => "&&",
214 .Invalid_periodasterisks => ".**",
215 .Bang => "!",
216 .Pipe => "|",
217 .PipePipe => "||",
218 .PipeEqual => "|=",
219 .Equal => "=",
220 .EqualEqual => "==",
221 .EqualAngleBracketRight => "=>",
222 .BangEqual => "!=",
223 .LParen => "(",
224 .RParen => ")",
225 .Semicolon => ";",
226 .Percent => "%",
227 .PercentEqual => "%=",
228 .LBrace => "{",
229 .RBrace => "}",
230 .LBracket => "[",
231 .RBracket => "]",
232 .Period => ".",
233 .PeriodAsterisk => ".*",
234 .Ellipsis2 => "..",
235 .Ellipsis3 => "...",
236 .Caret => "^",
237 .CaretEqual => "^=",
238 .Plus => "+",
239 .PlusPlus => "++",
240 .PlusEqual => "+=",
241 .PlusPercent => "+%",
242 .PlusPercentEqual => "+%=",
243 .Minus => "-",
244 .MinusEqual => "-=",
245 .MinusPercent => "-%",
246 .MinusPercentEqual => "-%=",
247 .Asterisk => "*",
248 .AsteriskEqual => "*=",
249 .AsteriskAsterisk => "**",
250 .AsteriskPercent => "*%",
251 .AsteriskPercentEqual => "*%=",
252 .Arrow => "->",
253 .Colon => ":",
254 .Slash => "/",
255 .SlashEqual => "/=",
256 .Comma => ",",
257 .Ampersand => "&",
258 .AmpersandEqual => "&=",
259 .QuestionMark => "?",
260 .AngleBracketLeft => "<",
261 .AngleBracketLeftEqual => "<=",
262 .AngleBracketAngleBracketLeft => "<<",
263 .AngleBracketAngleBracketLeftEqual => "<<=",
264 .AngleBracketRight => ">",
265 .AngleBracketRightEqual => ">=",
266 .AngleBracketAngleBracketRight => ">>",
267 .AngleBracketAngleBracketRightEqual => ">>=",
268 .Tilde => "~",
269 .Keyword_align => "align",
270 .Keyword_allowzero => "allowzero",
271 .Keyword_and => "and",
272 .Keyword_anyframe => "anyframe",
273 .Keyword_anytype => "anytype",
274 .Keyword_asm => "asm",
275 .Keyword_async => "async",
276 .Keyword_await => "await",
277 .Keyword_break => "break",
278 .Keyword_callconv => "callconv",
279 .Keyword_catch => "catch",
280 .Keyword_comptime => "comptime",
281 .Keyword_const => "const",
282 .Keyword_continue => "continue",
283 .Keyword_defer => "defer",
284 .Keyword_else => "else",
285 .Keyword_enum => "enum",
286 .Keyword_errdefer => "errdefer",
287 .Keyword_error => "error",
288 .Keyword_export => "export",
289 .Keyword_extern => "extern",
290 .Keyword_false => "false",
291 .Keyword_fn => "fn",
292 .Keyword_for => "for",
293 .Keyword_if => "if",
294 .Keyword_inline => "inline",
295 .Keyword_noalias => "noalias",
296 .Keyword_noinline => "noinline",
297 .Keyword_nosuspend => "nosuspend",
298 .Keyword_null => "null",
299 .Keyword_opaque => "opaque",
300 .Keyword_or => "or",
301 .Keyword_orelse => "orelse",
302 .Keyword_packed => "packed",
303 .Keyword_pub => "pub",
304 .Keyword_resume => "resume",
305 .Keyword_return => "return",
306 .Keyword_linksection => "linksection",
307 .Keyword_struct => "struct",
308 .Keyword_suspend => "suspend",
309 .Keyword_switch => "switch",
310 .Keyword_test => "test",
311 .Keyword_threadlocal => "threadlocal",
312 .Keyword_true => "true",
313 .Keyword_try => "try",
314 .Keyword_undefined => "undefined",
315 .Keyword_union => "union",
316 .Keyword_unreachable => "unreachable",
317 .Keyword_usingnamespace => "usingnamespace",
318 .Keyword_var => "var",
319 .Keyword_volatile => "volatile",
320 .Keyword_while => "while",
213 .invalid_ampersands => "&&",
214 .invalid_periodasterisks => ".**",
215 .bang => "!",
216 .pipe => "|",
217 .pipe_pipe => "||",
218 .pipe_equal => "|=",
219 .equal => "=",
220 .equal_equal => "==",
221 .equal_angle_bracket_right => "=>",
222 .bang_equal => "!=",
223 .l_paren => "(",
224 .r_paren => ")",
225 .semicolon => ";",
226 .percent => "%",
227 .percent_equal => "%=",
228 .l_brace => "{",
229 .r_brace => "}",
230 .l_bracket => "[",
231 .r_bracket => "]",
232 .period => ".",
233 .period_asterisk => ".*",
234 .ellipsis2 => "..",
235 .ellipsis3 => "...",
236 .caret => "^",
237 .caret_equal => "^=",
238 .plus => "+",
239 .plus_plus => "++",
240 .plus_equal => "+=",
241 .plus_percent => "+%",
242 .plus_percent_equal => "+%=",
243 .minus => "-",
244 .minus_equal => "-=",
245 .minus_percent => "-%",
246 .minus_percent_equal => "-%=",
247 .asterisk => "*",
248 .asterisk_equal => "*=",
249 .asterisk_asterisk => "**",
250 .asterisk_percent => "*%",
251 .asterisk_percent_equal => "*%=",
252 .arrow => "->",
253 .colon => ":",
254 .slash => "/",
255 .slash_equal => "/=",
256 .comma => ",",
257 .ampersand => "&",
258 .ampersand_equal => "&=",
259 .question_mark => "?",
260 .angle_bracket_left => "<",
261 .angle_bracket_left_equal => "<=",
262 .angle_bracket_angle_bracket_left => "<<",
263 .angle_bracket_angle_bracket_left_equal => "<<=",
264 .angle_bracket_right => ">",
265 .angle_bracket_right_equal => ">=",
266 .angle_bracket_angle_bracket_right => ">>",
267 .angle_bracket_angle_bracket_right_equal => ">>=",
268 .tilde => "~",
269 .keyword_align => "align",
270 .keyword_allowzero => "allowzero",
271 .keyword_and => "and",
272 .keyword_anyframe => "anyframe",
273 .keyword_anytype => "anytype",
274 .keyword_asm => "asm",
275 .keyword_async => "async",
276 .keyword_await => "await",
277 .keyword_break => "break",
278 .keyword_callconv => "callconv",
279 .keyword_catch => "catch",
280 .keyword_comptime => "comptime",
281 .keyword_const => "const",
282 .keyword_continue => "continue",
283 .keyword_defer => "defer",
284 .keyword_else => "else",
285 .keyword_enum => "enum",
286 .keyword_errdefer => "errdefer",
287 .keyword_error => "error",
288 .keyword_export => "export",
289 .keyword_extern => "extern",
290 .keyword_false => "false",
291 .keyword_fn => "fn",
292 .keyword_for => "for",
293 .keyword_if => "if",
294 .keyword_inline => "inline",
295 .keyword_noalias => "noalias",
296 .keyword_noinline => "noinline",
297 .keyword_nosuspend => "nosuspend",
298 .keyword_null => "null",
299 .keyword_opaque => "opaque",
300 .keyword_or => "or",
301 .keyword_orelse => "orelse",
302 .keyword_packed => "packed",
303 .keyword_pub => "pub",
304 .keyword_resume => "resume",
305 .keyword_return => "return",
306 .keyword_linksection => "linksection",
307 .keyword_struct => "struct",
308 .keyword_suspend => "suspend",
309 .keyword_switch => "switch",
310 .keyword_test => "test",
311 .keyword_threadlocal => "threadlocal",
312 .keyword_true => "true",
313 .keyword_try => "try",
314 .keyword_undefined => "undefined",
315 .keyword_union => "union",
316 .keyword_unreachable => "unreachable",
317 .keyword_usingnamespace => "usingnamespace",
318 .keyword_var => "var",
319 .keyword_volatile => "volatile",
320 .keyword_while => "while",
321321 };
322322 }
323323
......@@ -421,7 +421,7 @@ pub const Tokenizer = struct {
421421 const start_index = self.index;
422422 var state: State = .start;
423423 var result = Token{
424 .tag = .Eof,
424 .tag = .eof,
425425 .loc = .{
426426 .start = self.index,
427427 .end = undefined,
......@@ -438,14 +438,14 @@ pub const Tokenizer = struct {
438438 },
439439 '"' => {
440440 state = .string_literal;
441 result.tag = .StringLiteral;
441 result.tag = .string_literal;
442442 },
443443 '\'' => {
444444 state = .char_literal;
445445 },
446446 'a'...'z', 'A'...'Z', '_' => {
447447 state = .identifier;
448 result.tag = .Identifier;
448 result.tag = .identifier;
449449 },
450450 '@' => {
451451 state = .saw_at_sign;
......@@ -460,42 +460,42 @@ pub const Tokenizer = struct {
460460 state = .pipe;
461461 },
462462 '(' => {
463 result.tag = .LParen;
463 result.tag = .l_paren;
464464 self.index += 1;
465465 break;
466466 },
467467 ')' => {
468 result.tag = .RParen;
468 result.tag = .r_paren;
469469 self.index += 1;
470470 break;
471471 },
472472 '[' => {
473 result.tag = .LBracket;
473 result.tag = .l_bracket;
474474 self.index += 1;
475475 break;
476476 },
477477 ']' => {
478 result.tag = .RBracket;
478 result.tag = .r_bracket;
479479 self.index += 1;
480480 break;
481481 },
482482 ';' => {
483 result.tag = .Semicolon;
483 result.tag = .semicolon;
484484 self.index += 1;
485485 break;
486486 },
487487 ',' => {
488 result.tag = .Comma;
488 result.tag = .comma;
489489 self.index += 1;
490490 break;
491491 },
492492 '?' => {
493 result.tag = .QuestionMark;
493 result.tag = .question_mark;
494494 self.index += 1;
495495 break;
496496 },
497497 ':' => {
498 result.tag = .Colon;
498 result.tag = .colon;
499499 self.index += 1;
500500 break;
501501 },
......@@ -519,20 +519,20 @@ pub const Tokenizer = struct {
519519 },
520520 '\\' => {
521521 state = .backslash;
522 result.tag = .MultilineStringLiteralLine;
522 result.tag = .multiline_string_literal_line;
523523 },
524524 '{' => {
525 result.tag = .LBrace;
525 result.tag = .l_brace;
526526 self.index += 1;
527527 break;
528528 },
529529 '}' => {
530 result.tag = .RBrace;
530 result.tag = .r_brace;
531531 self.index += 1;
532532 break;
533533 },
534534 '~' => {
535 result.tag = .Tilde;
535 result.tag = .tilde;
536536 self.index += 1;
537537 break;
538538 },
......@@ -550,14 +550,14 @@ pub const Tokenizer = struct {
550550 },
551551 '0' => {
552552 state = .zero;
553 result.tag = .IntegerLiteral;
553 result.tag = .integer_literal;
554554 },
555555 '1'...'9' => {
556556 state = .int_literal_dec;
557 result.tag = .IntegerLiteral;
557 result.tag = .integer_literal;
558558 },
559559 else => {
560 result.tag = .Invalid;
560 result.tag = .invalid;
561561 self.index += 1;
562562 break;
563563 },
......@@ -565,42 +565,42 @@ pub const Tokenizer = struct {
565565
566566 .saw_at_sign => switch (c) {
567567 '"' => {
568 result.tag = .Identifier;
568 result.tag = .identifier;
569569 state = .string_literal;
570570 },
571571 else => {
572572 // reinterpret as a builtin
573573 self.index -= 1;
574574 state = .builtin;
575 result.tag = .Builtin;
575 result.tag = .builtin;
576576 },
577577 },
578578
579579 .ampersand => switch (c) {
580580 '&' => {
581 result.tag = .Invalid_ampersands;
581 result.tag = .invalid_ampersands;
582582 self.index += 1;
583583 break;
584584 },
585585 '=' => {
586 result.tag = .AmpersandEqual;
586 result.tag = .ampersand_equal;
587587 self.index += 1;
588588 break;
589589 },
590590 else => {
591 result.tag = .Ampersand;
591 result.tag = .ampersand;
592592 break;
593593 },
594594 },
595595
596596 .asterisk => switch (c) {
597597 '=' => {
598 result.tag = .AsteriskEqual;
598 result.tag = .asterisk_equal;
599599 self.index += 1;
600600 break;
601601 },
602602 '*' => {
603 result.tag = .AsteriskAsterisk;
603 result.tag = .asterisk_asterisk;
604604 self.index += 1;
605605 break;
606606 },
......@@ -608,43 +608,43 @@ pub const Tokenizer = struct {
608608 state = .asterisk_percent;
609609 },
610610 else => {
611 result.tag = .Asterisk;
611 result.tag = .asterisk;
612612 break;
613613 },
614614 },
615615
616616 .asterisk_percent => switch (c) {
617617 '=' => {
618 result.tag = .AsteriskPercentEqual;
618 result.tag = .asterisk_percent_equal;
619619 self.index += 1;
620620 break;
621621 },
622622 else => {
623 result.tag = .AsteriskPercent;
623 result.tag = .asterisk_percent;
624624 break;
625625 },
626626 },
627627
628628 .percent => switch (c) {
629629 '=' => {
630 result.tag = .PercentEqual;
630 result.tag = .percent_equal;
631631 self.index += 1;
632632 break;
633633 },
634634 else => {
635 result.tag = .Percent;
635 result.tag = .percent;
636636 break;
637637 },
638638 },
639639
640640 .plus => switch (c) {
641641 '=' => {
642 result.tag = .PlusEqual;
642 result.tag = .plus_equal;
643643 self.index += 1;
644644 break;
645645 },
646646 '+' => {
647 result.tag = .PlusPlus;
647 result.tag = .plus_plus;
648648 self.index += 1;
649649 break;
650650 },
......@@ -652,31 +652,31 @@ pub const Tokenizer = struct {
652652 state = .plus_percent;
653653 },
654654 else => {
655 result.tag = .Plus;
655 result.tag = .plus;
656656 break;
657657 },
658658 },
659659
660660 .plus_percent => switch (c) {
661661 '=' => {
662 result.tag = .PlusPercentEqual;
662 result.tag = .plus_percent_equal;
663663 self.index += 1;
664664 break;
665665 },
666666 else => {
667 result.tag = .PlusPercent;
667 result.tag = .plus_percent;
668668 break;
669669 },
670670 },
671671
672672 .caret => switch (c) {
673673 '=' => {
674 result.tag = .CaretEqual;
674 result.tag = .caret_equal;
675675 self.index += 1;
676676 break;
677677 },
678678 else => {
679 result.tag = .Caret;
679 result.tag = .caret;
680680 break;
681681 },
682682 },
......@@ -724,7 +724,7 @@ pub const Tokenizer = struct {
724724 state = .char_literal_backslash;
725725 },
726726 '\'', 0x80...0xbf, 0xf8...0xff => {
727 result.tag = .Invalid;
727 result.tag = .invalid;
728728 break;
729729 },
730730 0xc0...0xdf => { // 110xxxxx
......@@ -746,7 +746,7 @@ pub const Tokenizer = struct {
746746
747747 .char_literal_backslash => switch (c) {
748748 '\n' => {
749 result.tag = .Invalid;
749 result.tag = .invalid;
750750 break;
751751 },
752752 'x' => {
......@@ -769,7 +769,7 @@ pub const Tokenizer = struct {
769769 }
770770 },
771771 else => {
772 result.tag = .Invalid;
772 result.tag = .invalid;
773773 break;
774774 },
775775 },
......@@ -780,7 +780,7 @@ pub const Tokenizer = struct {
780780 seen_escape_digits = 0;
781781 },
782782 else => {
783 result.tag = .Invalid;
783 result.tag = .invalid;
784784 state = .char_literal_unicode_invalid;
785785 },
786786 },
......@@ -791,14 +791,14 @@ pub const Tokenizer = struct {
791791 },
792792 '}' => {
793793 if (seen_escape_digits == 0) {
794 result.tag = .Invalid;
794 result.tag = .invalid;
795795 state = .char_literal_unicode_invalid;
796796 } else {
797797 state = .char_literal_end;
798798 }
799799 },
800800 else => {
801 result.tag = .Invalid;
801 result.tag = .invalid;
802802 state = .char_literal_unicode_invalid;
803803 },
804804 },
......@@ -813,12 +813,12 @@ pub const Tokenizer = struct {
813813
814814 .char_literal_end => switch (c) {
815815 '\'' => {
816 result.tag = .CharLiteral;
816 result.tag = .char_literal;
817817 self.index += 1;
818818 break;
819819 },
820820 else => {
821 result.tag = .Invalid;
821 result.tag = .invalid;
822822 break;
823823 },
824824 },
......@@ -831,7 +831,7 @@ pub const Tokenizer = struct {
831831 }
832832 },
833833 else => {
834 result.tag = .Invalid;
834 result.tag = .invalid;
835835 break;
836836 },
837837 },
......@@ -847,58 +847,58 @@ pub const Tokenizer = struct {
847847
848848 .bang => switch (c) {
849849 '=' => {
850 result.tag = .BangEqual;
850 result.tag = .bang_equal;
851851 self.index += 1;
852852 break;
853853 },
854854 else => {
855 result.tag = .Bang;
855 result.tag = .bang;
856856 break;
857857 },
858858 },
859859
860860 .pipe => switch (c) {
861861 '=' => {
862 result.tag = .PipeEqual;
862 result.tag = .pipe_equal;
863863 self.index += 1;
864864 break;
865865 },
866866 '|' => {
867 result.tag = .PipePipe;
867 result.tag = .pipe_pipe;
868868 self.index += 1;
869869 break;
870870 },
871871 else => {
872 result.tag = .Pipe;
872 result.tag = .pipe;
873873 break;
874874 },
875875 },
876876
877877 .equal => switch (c) {
878878 '=' => {
879 result.tag = .EqualEqual;
879 result.tag = .equal_equal;
880880 self.index += 1;
881881 break;
882882 },
883883 '>' => {
884 result.tag = .EqualAngleBracketRight;
884 result.tag = .equal_angle_bracket_right;
885885 self.index += 1;
886886 break;
887887 },
888888 else => {
889 result.tag = .Equal;
889 result.tag = .equal;
890890 break;
891891 },
892892 },
893893
894894 .minus => switch (c) {
895895 '>' => {
896 result.tag = .Arrow;
896 result.tag = .arrow;
897897 self.index += 1;
898898 break;
899899 },
900900 '=' => {
901 result.tag = .MinusEqual;
901 result.tag = .minus_equal;
902902 self.index += 1;
903903 break;
904904 },
......@@ -906,19 +906,19 @@ pub const Tokenizer = struct {
906906 state = .minus_percent;
907907 },
908908 else => {
909 result.tag = .Minus;
909 result.tag = .minus;
910910 break;
911911 },
912912 },
913913
914914 .minus_percent => switch (c) {
915915 '=' => {
916 result.tag = .MinusPercentEqual;
916 result.tag = .minus_percent_equal;
917917 self.index += 1;
918918 break;
919919 },
920920 else => {
921 result.tag = .MinusPercent;
921 result.tag = .minus_percent;
922922 break;
923923 },
924924 },
......@@ -928,24 +928,24 @@ pub const Tokenizer = struct {
928928 state = .angle_bracket_angle_bracket_left;
929929 },
930930 '=' => {
931 result.tag = .AngleBracketLeftEqual;
931 result.tag = .angle_bracket_left_equal;
932932 self.index += 1;
933933 break;
934934 },
935935 else => {
936 result.tag = .AngleBracketLeft;
936 result.tag = .angle_bracket_left;
937937 break;
938938 },
939939 },
940940
941941 .angle_bracket_angle_bracket_left => switch (c) {
942942 '=' => {
943 result.tag = .AngleBracketAngleBracketLeftEqual;
943 result.tag = .angle_bracket_angle_bracket_left_equal;
944944 self.index += 1;
945945 break;
946946 },
947947 else => {
948 result.tag = .AngleBracketAngleBracketLeft;
948 result.tag = .angle_bracket_angle_bracket_left;
949949 break;
950950 },
951951 },
......@@ -955,24 +955,24 @@ pub const Tokenizer = struct {
955955 state = .angle_bracket_angle_bracket_right;
956956 },
957957 '=' => {
958 result.tag = .AngleBracketRightEqual;
958 result.tag = .angle_bracket_right_equal;
959959 self.index += 1;
960960 break;
961961 },
962962 else => {
963 result.tag = .AngleBracketRight;
963 result.tag = .angle_bracket_right;
964964 break;
965965 },
966966 },
967967
968968 .angle_bracket_angle_bracket_right => switch (c) {
969969 '=' => {
970 result.tag = .AngleBracketAngleBracketRightEqual;
970 result.tag = .angle_bracket_angle_bracket_right_equal;
971971 self.index += 1;
972972 break;
973973 },
974974 else => {
975 result.tag = .AngleBracketAngleBracketRight;
975 result.tag = .angle_bracket_angle_bracket_right;
976976 break;
977977 },
978978 },
......@@ -985,30 +985,30 @@ pub const Tokenizer = struct {
985985 state = .period_asterisk;
986986 },
987987 else => {
988 result.tag = .Period;
988 result.tag = .period;
989989 break;
990990 },
991991 },
992992
993993 .period_2 => switch (c) {
994994 '.' => {
995 result.tag = .Ellipsis3;
995 result.tag = .ellipsis3;
996996 self.index += 1;
997997 break;
998998 },
999999 else => {
1000 result.tag = .Ellipsis2;
1000 result.tag = .ellipsis2;
10011001 break;
10021002 },
10031003 },
10041004
10051005 .period_asterisk => switch (c) {
10061006 '*' => {
1007 result.tag = .Invalid_periodasterisks;
1007 result.tag = .invalid_periodasterisks;
10081008 break;
10091009 },
10101010 else => {
1011 result.tag = .PeriodAsterisk;
1011 result.tag = .period_asterisk;
10121012 break;
10131013 },
10141014 },
......@@ -1018,12 +1018,12 @@ pub const Tokenizer = struct {
10181018 state = .line_comment_start;
10191019 },
10201020 '=' => {
1021 result.tag = .SlashEqual;
1021 result.tag = .slash_equal;
10221022 self.index += 1;
10231023 break;
10241024 },
10251025 else => {
1026 result.tag = .Slash;
1026 result.tag = .slash;
10271027 break;
10281028 },
10291029 },
......@@ -1032,7 +1032,7 @@ pub const Tokenizer = struct {
10321032 state = .doc_comment_start;
10331033 },
10341034 '!' => {
1035 result.tag = .ContainerDocComment;
1035 result.tag = .container_doc_comment;
10361036 state = .container_doc_comment;
10371037 },
10381038 '\n' => {
......@@ -1050,16 +1050,16 @@ pub const Tokenizer = struct {
10501050 state = .line_comment;
10511051 },
10521052 '\n' => {
1053 result.tag = .DocComment;
1053 result.tag = .doc_comment;
10541054 break;
10551055 },
10561056 '\t', '\r' => {
10571057 state = .doc_comment;
1058 result.tag = .DocComment;
1058 result.tag = .doc_comment;
10591059 },
10601060 else => {
10611061 state = .doc_comment;
1062 result.tag = .DocComment;
1062 result.tag = .doc_comment;
10631063 self.checkLiteralCharacter();
10641064 },
10651065 },
......@@ -1093,7 +1093,7 @@ pub const Tokenizer = struct {
10931093 },
10941094 else => {
10951095 if (isIdentifierChar(c)) {
1096 result.tag = .Invalid;
1096 result.tag = .invalid;
10971097 }
10981098 break;
10991099 },
......@@ -1103,7 +1103,7 @@ pub const Tokenizer = struct {
11031103 state = .int_literal_bin;
11041104 },
11051105 else => {
1106 result.tag = .Invalid;
1106 result.tag = .invalid;
11071107 break;
11081108 },
11091109 },
......@@ -1114,7 +1114,7 @@ pub const Tokenizer = struct {
11141114 '0'...'1' => {},
11151115 else => {
11161116 if (isIdentifierChar(c)) {
1117 result.tag = .Invalid;
1117 result.tag = .invalid;
11181118 }
11191119 break;
11201120 },
......@@ -1124,7 +1124,7 @@ pub const Tokenizer = struct {
11241124 state = .int_literal_oct;
11251125 },
11261126 else => {
1127 result.tag = .Invalid;
1127 result.tag = .invalid;
11281128 break;
11291129 },
11301130 },
......@@ -1135,7 +1135,7 @@ pub const Tokenizer = struct {
11351135 '0'...'7' => {},
11361136 else => {
11371137 if (isIdentifierChar(c)) {
1138 result.tag = .Invalid;
1138 result.tag = .invalid;
11391139 }
11401140 break;
11411141 },
......@@ -1145,7 +1145,7 @@ pub const Tokenizer = struct {
11451145 state = .int_literal_dec;
11461146 },
11471147 else => {
1148 result.tag = .Invalid;
1148 result.tag = .invalid;
11491149 break;
11501150 },
11511151 },
......@@ -1155,16 +1155,16 @@ pub const Tokenizer = struct {
11551155 },
11561156 '.' => {
11571157 state = .num_dot_dec;
1158 result.tag = .FloatLiteral;
1158 result.tag = .float_literal;
11591159 },
11601160 'e', 'E' => {
11611161 state = .float_exponent_unsigned;
1162 result.tag = .FloatLiteral;
1162 result.tag = .float_literal;
11631163 },
11641164 '0'...'9' => {},
11651165 else => {
11661166 if (isIdentifierChar(c)) {
1167 result.tag = .Invalid;
1167 result.tag = .invalid;
11681168 }
11691169 break;
11701170 },
......@@ -1174,7 +1174,7 @@ pub const Tokenizer = struct {
11741174 state = .int_literal_hex;
11751175 },
11761176 else => {
1177 result.tag = .Invalid;
1177 result.tag = .invalid;
11781178 break;
11791179 },
11801180 },
......@@ -1184,23 +1184,23 @@ pub const Tokenizer = struct {
11841184 },
11851185 '.' => {
11861186 state = .num_dot_hex;
1187 result.tag = .FloatLiteral;
1187 result.tag = .float_literal;
11881188 },
11891189 'p', 'P' => {
11901190 state = .float_exponent_unsigned;
1191 result.tag = .FloatLiteral;
1191 result.tag = .float_literal;
11921192 },
11931193 '0'...'9', 'a'...'f', 'A'...'F' => {},
11941194 else => {
11951195 if (isIdentifierChar(c)) {
1196 result.tag = .Invalid;
1196 result.tag = .invalid;
11971197 }
11981198 break;
11991199 },
12001200 },
12011201 .num_dot_dec => switch (c) {
12021202 '.' => {
1203 result.tag = .IntegerLiteral;
1203 result.tag = .integer_literal;
12041204 self.index -= 1;
12051205 state = .start;
12061206 break;
......@@ -1213,14 +1213,14 @@ pub const Tokenizer = struct {
12131213 },
12141214 else => {
12151215 if (isIdentifierChar(c)) {
1216 result.tag = .Invalid;
1216 result.tag = .invalid;
12171217 }
12181218 break;
12191219 },
12201220 },
12211221 .num_dot_hex => switch (c) {
12221222 '.' => {
1223 result.tag = .IntegerLiteral;
1223 result.tag = .integer_literal;
12241224 self.index -= 1;
12251225 state = .start;
12261226 break;
......@@ -1229,12 +1229,12 @@ pub const Tokenizer = struct {
12291229 state = .float_exponent_unsigned;
12301230 },
12311231 '0'...'9', 'a'...'f', 'A'...'F' => {
1232 result.tag = .FloatLiteral;
1232 result.tag = .float_literal;
12331233 state = .float_fraction_hex;
12341234 },
12351235 else => {
12361236 if (isIdentifierChar(c)) {
1237 result.tag = .Invalid;
1237 result.tag = .invalid;
12381238 }
12391239 break;
12401240 },
......@@ -1244,7 +1244,7 @@ pub const Tokenizer = struct {
12441244 state = .float_fraction_dec;
12451245 },
12461246 else => {
1247 result.tag = .Invalid;
1247 result.tag = .invalid;
12481248 break;
12491249 },
12501250 },
......@@ -1258,7 +1258,7 @@ pub const Tokenizer = struct {
12581258 '0'...'9' => {},
12591259 else => {
12601260 if (isIdentifierChar(c)) {
1261 result.tag = .Invalid;
1261 result.tag = .invalid;
12621262 }
12631263 break;
12641264 },
......@@ -1268,7 +1268,7 @@ pub const Tokenizer = struct {
12681268 state = .float_fraction_hex;
12691269 },
12701270 else => {
1271 result.tag = .Invalid;
1271 result.tag = .invalid;
12721272 break;
12731273 },
12741274 },
......@@ -1282,7 +1282,7 @@ pub const Tokenizer = struct {
12821282 '0'...'9', 'a'...'f', 'A'...'F' => {},
12831283 else => {
12841284 if (isIdentifierChar(c)) {
1285 result.tag = .Invalid;
1285 result.tag = .invalid;
12861286 }
12871287 break;
12881288 },
......@@ -1302,7 +1302,7 @@ pub const Tokenizer = struct {
13021302 state = .float_exponent_num;
13031303 },
13041304 else => {
1305 result.tag = .Invalid;
1305 result.tag = .invalid;
13061306 break;
13071307 },
13081308 },
......@@ -1313,7 +1313,7 @@ pub const Tokenizer = struct {
13131313 '0'...'9' => {},
13141314 else => {
13151315 if (isIdentifierChar(c)) {
1316 result.tag = .Invalid;
1316 result.tag = .invalid;
13171317 }
13181318 break;
13191319 },
......@@ -1344,10 +1344,10 @@ pub const Tokenizer = struct {
13441344 }
13451345 },
13461346 .doc_comment, .doc_comment_start => {
1347 result.tag = .DocComment;
1347 result.tag = .doc_comment;
13481348 },
13491349 .container_doc_comment => {
1350 result.tag = .ContainerDocComment;
1350 result.tag = .container_doc_comment;
13511351 },
13521352
13531353 .int_literal_dec_no_underscore,
......@@ -1370,76 +1370,76 @@ pub const Tokenizer = struct {
13701370 .char_literal_unicode,
13711371 .string_literal_backslash,
13721372 => {
1373 result.tag = .Invalid;
1373 result.tag = .invalid;
13741374 },
13751375
13761376 .equal => {
1377 result.tag = .Equal;
1377 result.tag = .equal;
13781378 },
13791379 .bang => {
1380 result.tag = .Bang;
1380 result.tag = .bang;
13811381 },
13821382 .minus => {
1383 result.tag = .Minus;
1383 result.tag = .minus;
13841384 },
13851385 .slash => {
1386 result.tag = .Slash;
1386 result.tag = .slash;
13871387 },
13881388 .zero => {
1389 result.tag = .IntegerLiteral;
1389 result.tag = .integer_literal;
13901390 },
13911391 .ampersand => {
1392 result.tag = .Ampersand;
1392 result.tag = .ampersand;
13931393 },
13941394 .period => {
1395 result.tag = .Period;
1395 result.tag = .period;
13961396 },
13971397 .period_2 => {
1398 result.tag = .Ellipsis2;
1398 result.tag = .ellipsis2;
13991399 },
14001400 .period_asterisk => {
1401 result.tag = .PeriodAsterisk;
1401 result.tag = .period_asterisk;
14021402 },
14031403 .pipe => {
1404 result.tag = .Pipe;
1404 result.tag = .pipe;
14051405 },
14061406 .angle_bracket_angle_bracket_right => {
1407 result.tag = .AngleBracketAngleBracketRight;
1407 result.tag = .angle_bracket_angle_bracket_right;
14081408 },
14091409 .angle_bracket_right => {
1410 result.tag = .AngleBracketRight;
1410 result.tag = .angle_bracket_right;
14111411 },
14121412 .angle_bracket_angle_bracket_left => {
1413 result.tag = .AngleBracketAngleBracketLeft;
1413 result.tag = .angle_bracket_angle_bracket_left;
14141414 },
14151415 .angle_bracket_left => {
1416 result.tag = .AngleBracketLeft;
1416 result.tag = .angle_bracket_left;
14171417 },
14181418 .plus_percent => {
1419 result.tag = .PlusPercent;
1419 result.tag = .plus_percent;
14201420 },
14211421 .plus => {
1422 result.tag = .Plus;
1422 result.tag = .plus;
14231423 },
14241424 .percent => {
1425 result.tag = .Percent;
1425 result.tag = .percent;
14261426 },
14271427 .caret => {
1428 result.tag = .Caret;
1428 result.tag = .caret;
14291429 },
14301430 .asterisk_percent => {
1431 result.tag = .AsteriskPercent;
1431 result.tag = .asterisk_percent;
14321432 },
14331433 .asterisk => {
1434 result.tag = .Asterisk;
1434 result.tag = .asterisk;
14351435 },
14361436 .minus_percent => {
1437 result.tag = .MinusPercent;
1437 result.tag = .minus_percent;
14381438 },
14391439 }
14401440 }
14411441
1442 if (result.tag == .Eof) {
1442 if (result.tag == .eof) {
14431443 if (self.pending_invalid_token) |token| {
14441444 self.pending_invalid_token = null;
14451445 return token;
......@@ -1455,7 +1455,7 @@ pub const Tokenizer = struct {
14551455 const invalid_length = self.getInvalidCharacterLength();
14561456 if (invalid_length == 0) return;
14571457 self.pending_invalid_token = .{
1458 .tag = .Invalid,
1458 .tag = .invalid,
14591459 .loc = .{
14601460 .start = self.index,
14611461 .end = self.index + invalid_length,
......@@ -1502,7 +1502,7 @@ pub const Tokenizer = struct {
15021502};
15031503
15041504test "tokenizer" {
1505 testTokenize("test", &[_]Token.Tag{.Keyword_test});
1505 testTokenize("test", &.{.keyword_test});
15061506}
15071507
15081508test "line comment followed by top-level comptime" {
......@@ -1510,10 +1510,10 @@ test "line comment followed by top-level comptime" {
15101510 \\// line comment
15111511 \\comptime {}
15121512 \\
1513 , &[_]Token.Tag{
1514 .Keyword_comptime,
1515 .LBrace,
1516 .RBrace,
1513 , &.{
1514 .keyword_comptime,
1515 .l_brace,
1516 .r_brace,
15171517 });
15181518}
15191519
......@@ -1521,199 +1521,199 @@ test "tokenizer - unknown length pointer and then c pointer" {
15211521 testTokenize(
15221522 \\[*]u8
15231523 \\[*c]u8
1524 , &[_]Token.Tag{
1525 .LBracket,
1526 .Asterisk,
1527 .RBracket,
1528 .Identifier,
1529 .LBracket,
1530 .Asterisk,
1531 .Identifier,
1532 .RBracket,
1533 .Identifier,
1524 , &.{
1525 .l_bracket,
1526 .asterisk,
1527 .r_bracket,
1528 .identifier,
1529 .l_bracket,
1530 .asterisk,
1531 .identifier,
1532 .r_bracket,
1533 .identifier,
15341534 });
15351535}
15361536
15371537test "tokenizer - char literal with hex escape" {
15381538 testTokenize(
15391539 \\'\x1b'
1540 , &[_]Token.Tag{.CharLiteral});
1540 , &.{.char_literal});
15411541 testTokenize(
15421542 \\'\x1'
1543 , &[_]Token.Tag{ .Invalid, .Invalid });
1543 , &.{ .invalid, .invalid });
15441544}
15451545
15461546test "tokenizer - char literal with unicode escapes" {
15471547 // Valid unicode escapes
15481548 testTokenize(
15491549 \\'\u{3}'
1550 , &[_]Token.Tag{.CharLiteral});
1550 , &.{.char_literal});
15511551 testTokenize(
15521552 \\'\u{01}'
1553 , &[_]Token.Tag{.CharLiteral});
1553 , &.{.char_literal});
15541554 testTokenize(
15551555 \\'\u{2a}'
1556 , &[_]Token.Tag{.CharLiteral});
1556 , &.{.char_literal});
15571557 testTokenize(
15581558 \\'\u{3f9}'
1559 , &[_]Token.Tag{.CharLiteral});
1559 , &.{.char_literal});
15601560 testTokenize(
15611561 \\'\u{6E09aBc1523}'
1562 , &[_]Token.Tag{.CharLiteral});
1562 , &.{.char_literal});
15631563 testTokenize(
15641564 \\"\u{440}"
1565 , &[_]Token.Tag{.StringLiteral});
1565 , &.{.string_literal});
15661566
15671567 // Invalid unicode escapes
15681568 testTokenize(
15691569 \\'\u'
1570 , &[_]Token.Tag{.Invalid});
1570 , &.{.invalid});
15711571 testTokenize(
15721572 \\'\u{{'
1573 , &[_]Token.Tag{ .Invalid, .Invalid });
1573 , &.{ .invalid, .invalid });
15741574 testTokenize(
15751575 \\'\u{}'
1576 , &[_]Token.Tag{ .Invalid, .Invalid });
1576 , &.{ .invalid, .invalid });
15771577 testTokenize(
15781578 \\'\u{s}'
1579 , &[_]Token.Tag{ .Invalid, .Invalid });
1579 , &.{ .invalid, .invalid });
15801580 testTokenize(
15811581 \\'\u{2z}'
1582 , &[_]Token.Tag{ .Invalid, .Invalid });
1582 , &.{ .invalid, .invalid });
15831583 testTokenize(
15841584 \\'\u{4a'
1585 , &[_]Token.Tag{.Invalid});
1585 , &.{.invalid});
15861586
15871587 // Test old-style unicode literals
15881588 testTokenize(
15891589 \\'\u0333'
1590 , &[_]Token.Tag{ .Invalid, .Invalid });
1590 , &.{ .invalid, .invalid });
15911591 testTokenize(
15921592 \\'\U0333'
1593 , &[_]Token.Tag{ .Invalid, .IntegerLiteral, .Invalid });
1593 , &.{ .invalid, .integer_literal, .invalid });
15941594}
15951595
15961596test "tokenizer - char literal with unicode code point" {
15971597 testTokenize(
15981598 \\'💩'
1599 , &[_]Token.Tag{.CharLiteral});
1599 , &.{.char_literal});
16001600}
16011601
16021602test "tokenizer - float literal e exponent" {
1603 testTokenize("a = 4.94065645841246544177e-324;\n", &[_]Token.Tag{
1604 .Identifier,
1605 .Equal,
1606 .FloatLiteral,
1607 .Semicolon,
1603 testTokenize("a = 4.94065645841246544177e-324;\n", &.{
1604 .identifier,
1605 .equal,
1606 .float_literal,
1607 .semicolon,
16081608 });
16091609}
16101610
16111611test "tokenizer - float literal p exponent" {
1612 testTokenize("a = 0x1.a827999fcef32p+1022;\n", &[_]Token.Tag{
1613 .Identifier,
1614 .Equal,
1615 .FloatLiteral,
1616 .Semicolon,
1612 testTokenize("a = 0x1.a827999fcef32p+1022;\n", &.{
1613 .identifier,
1614 .equal,
1615 .float_literal,
1616 .semicolon,
16171617 });
16181618}
16191619
16201620test "tokenizer - chars" {
1621 testTokenize("'c'", &[_]Token.Tag{.CharLiteral});
1621 testTokenize("'c'", &.{.char_literal});
16221622}
16231623
16241624test "tokenizer - invalid token characters" {
1625 testTokenize("#", &[_]Token.Tag{.Invalid});
1626 testTokenize("`", &[_]Token.Tag{.Invalid});
1627 testTokenize("'c", &[_]Token.Tag{.Invalid});
1628 testTokenize("'", &[_]Token.Tag{.Invalid});
1629 testTokenize("''", &[_]Token.Tag{ .Invalid, .Invalid });
1625 testTokenize("#", &.{.invalid});
1626 testTokenize("`", &.{.invalid});
1627 testTokenize("'c", &.{.invalid});
1628 testTokenize("'", &.{.invalid});
1629 testTokenize("''", &.{ .invalid, .invalid });
16301630}
16311631
16321632test "tokenizer - invalid literal/comment characters" {
1633 testTokenize("\"\x00\"", &[_]Token.Tag{
1634 .StringLiteral,
1635 .Invalid,
1633 testTokenize("\"\x00\"", &.{
1634 .string_literal,
1635 .invalid,
16361636 });
1637 testTokenize("//\x00", &[_]Token.Tag{
1638 .Invalid,
1637 testTokenize("//\x00", &.{
1638 .invalid,
16391639 });
1640 testTokenize("//\x1f", &[_]Token.Tag{
1641 .Invalid,
1640 testTokenize("//\x1f", &.{
1641 .invalid,
16421642 });
1643 testTokenize("//\x7f", &[_]Token.Tag{
1644 .Invalid,
1643 testTokenize("//\x7f", &.{
1644 .invalid,
16451645 });
16461646}
16471647
16481648test "tokenizer - utf8" {
1649 testTokenize("//\xc2\x80", &[_]Token.Tag{});
1650 testTokenize("//\xf4\x8f\xbf\xbf", &[_]Token.Tag{});
1649 testTokenize("//\xc2\x80", &.{});
1650 testTokenize("//\xf4\x8f\xbf\xbf", &.{});
16511651}
16521652
16531653test "tokenizer - invalid utf8" {
1654 testTokenize("//\x80", &[_]Token.Tag{
1655 .Invalid,
1654 testTokenize("//\x80", &.{
1655 .invalid,
16561656 });
1657 testTokenize("//\xbf", &[_]Token.Tag{
1658 .Invalid,
1657 testTokenize("//\xbf", &.{
1658 .invalid,
16591659 });
1660 testTokenize("//\xf8", &[_]Token.Tag{
1661 .Invalid,
1660 testTokenize("//\xf8", &.{
1661 .invalid,
16621662 });
1663 testTokenize("//\xff", &[_]Token.Tag{
1664 .Invalid,
1663 testTokenize("//\xff", &.{
1664 .invalid,
16651665 });
1666 testTokenize("//\xc2\xc0", &[_]Token.Tag{
1667 .Invalid,
1666 testTokenize("//\xc2\xc0", &.{
1667 .invalid,
16681668 });
1669 testTokenize("//\xe0", &[_]Token.Tag{
1670 .Invalid,
1669 testTokenize("//\xe0", &.{
1670 .invalid,
16711671 });
1672 testTokenize("//\xf0", &[_]Token.Tag{
1673 .Invalid,
1672 testTokenize("//\xf0", &.{
1673 .invalid,
16741674 });
1675 testTokenize("//\xf0\x90\x80\xc0", &[_]Token.Tag{
1676 .Invalid,
1675 testTokenize("//\xf0\x90\x80\xc0", &.{
1676 .invalid,
16771677 });
16781678}
16791679
16801680test "tokenizer - illegal unicode codepoints" {
16811681 // unicode newline characters.U+0085, U+2028, U+2029
1682 testTokenize("//\xc2\x84", &[_]Token.Tag{});
1683 testTokenize("//\xc2\x85", &[_]Token.Tag{
1684 .Invalid,
1682 testTokenize("//\xc2\x84", &.{});
1683 testTokenize("//\xc2\x85", &.{
1684 .invalid,
16851685 });
1686 testTokenize("//\xc2\x86", &[_]Token.Tag{});
1687 testTokenize("//\xe2\x80\xa7", &[_]Token.Tag{});
1688 testTokenize("//\xe2\x80\xa8", &[_]Token.Tag{
1689 .Invalid,
1686 testTokenize("//\xc2\x86", &.{});
1687 testTokenize("//\xe2\x80\xa7", &.{});
1688 testTokenize("//\xe2\x80\xa8", &.{
1689 .invalid,
16901690 });
1691 testTokenize("//\xe2\x80\xa9", &[_]Token.Tag{
1692 .Invalid,
1691 testTokenize("//\xe2\x80\xa9", &.{
1692 .invalid,
16931693 });
1694 testTokenize("//\xe2\x80\xaa", &[_]Token.Tag{});
1694 testTokenize("//\xe2\x80\xaa", &.{});
16951695}
16961696
16971697test "tokenizer - string identifier and builtin fns" {
16981698 testTokenize(
16991699 \\const @"if" = @import("std");
1700 , &[_]Token.Tag{
1701 .Keyword_const,
1702 .Identifier,
1703 .Equal,
1704 .Builtin,
1705 .LParen,
1706 .StringLiteral,
1707 .RParen,
1708 .Semicolon,
1700 , &.{
1701 .keyword_const,
1702 .identifier,
1703 .equal,
1704 .builtin,
1705 .l_paren,
1706 .string_literal,
1707 .r_paren,
1708 .semicolon,
17091709 });
17101710}
17111711
17121712test "tokenizer - multiline string literal with literal tab" {
17131713 testTokenize(
17141714 \\\\foo bar
1715 , &[_]Token.Tag{
1716 .MultilineStringLiteralLine,
1715 , &.{
1716 .multiline_string_literal_line,
17171717 });
17181718}
17191719
......@@ -1725,30 +1725,30 @@ test "tokenizer - comments with literal tab" {
17251725 \\// foo
17261726 \\/// foo
17271727 \\/// /foo
1728 , &[_]Token.Tag{
1729 .ContainerDocComment,
1730 .DocComment,
1731 .DocComment,
1732 .DocComment,
1728 , &.{
1729 .container_doc_comment,
1730 .doc_comment,
1731 .doc_comment,
1732 .doc_comment,
17331733 });
17341734}
17351735
17361736test "tokenizer - pipe and then invalid" {
1737 testTokenize("||=", &[_]Token.Tag{
1738 .PipePipe,
1739 .Equal,
1737 testTokenize("||=", &.{
1738 .pipe_pipe,
1739 .equal,
17401740 });
17411741}
17421742
17431743test "tokenizer - line comment and doc comment" {
1744 testTokenize("//", &[_]Token.Tag{});
1745 testTokenize("// a / b", &[_]Token.Tag{});
1746 testTokenize("// /", &[_]Token.Tag{});
1747 testTokenize("/// a", &[_]Token.Tag{.DocComment});
1748 testTokenize("///", &[_]Token.Tag{.DocComment});
1749 testTokenize("////", &[_]Token.Tag{});
1750 testTokenize("//!", &[_]Token.Tag{.ContainerDocComment});
1751 testTokenize("//!!", &[_]Token.Tag{.ContainerDocComment});
1744 testTokenize("//", &.{});
1745 testTokenize("// a / b", &.{});
1746 testTokenize("// /", &.{});
1747 testTokenize("/// a", &.{.doc_comment});
1748 testTokenize("///", &.{.doc_comment});
1749 testTokenize("////", &.{});
1750 testTokenize("//!", &.{.container_doc_comment});
1751 testTokenize("//!!", &.{.container_doc_comment});
17521752}
17531753
17541754test "tokenizer - line comment followed by identifier" {
......@@ -1756,293 +1756,293 @@ test "tokenizer - line comment followed by identifier" {
17561756 \\ Unexpected,
17571757 \\ // another
17581758 \\ Another,
1759 , &[_]Token.Tag{
1760 .Identifier,
1761 .Comma,
1762 .Identifier,
1763 .Comma,
1759 , &.{
1760 .identifier,
1761 .comma,
1762 .identifier,
1763 .comma,
17641764 });
17651765}
17661766
17671767test "tokenizer - UTF-8 BOM is recognized and skipped" {
1768 testTokenize("\xEF\xBB\xBFa;\n", &[_]Token.Tag{
1769 .Identifier,
1770 .Semicolon,
1768 testTokenize("\xEF\xBB\xBFa;\n", &.{
1769 .identifier,
1770 .semicolon,
17711771 });
17721772}
17731773
17741774test "correctly parse pointer assignment" {
1775 testTokenize("b.*=3;\n", &[_]Token.Tag{
1776 .Identifier,
1777 .PeriodAsterisk,
1778 .Equal,
1779 .IntegerLiteral,
1780 .Semicolon,
1775 testTokenize("b.*=3;\n", &.{
1776 .identifier,
1777 .period_asterisk,
1778 .equal,
1779 .integer_literal,
1780 .semicolon,
17811781 });
17821782}
17831783
17841784test "correctly parse pointer dereference followed by asterisk" {
1785 testTokenize("\"b\".* ** 10", &[_]Token.Tag{
1786 .StringLiteral,
1787 .PeriodAsterisk,
1788 .AsteriskAsterisk,
1789 .IntegerLiteral,
1785 testTokenize("\"b\".* ** 10", &.{
1786 .string_literal,
1787 .period_asterisk,
1788 .asterisk_asterisk,
1789 .integer_literal,
17901790 });
17911791
1792 testTokenize("(\"b\".*)** 10", &[_]Token.Tag{
1793 .LParen,
1794 .StringLiteral,
1795 .PeriodAsterisk,
1796 .RParen,
1797 .AsteriskAsterisk,
1798 .IntegerLiteral,
1792 testTokenize("(\"b\".*)** 10", &.{
1793 .l_paren,
1794 .string_literal,
1795 .period_asterisk,
1796 .r_paren,
1797 .asterisk_asterisk,
1798 .integer_literal,
17991799 });
18001800
1801 testTokenize("\"b\".*** 10", &[_]Token.Tag{
1802 .StringLiteral,
1803 .Invalid_periodasterisks,
1804 .AsteriskAsterisk,
1805 .IntegerLiteral,
1801 testTokenize("\"b\".*** 10", &.{
1802 .string_literal,
1803 .invalid_periodasterisks,
1804 .asterisk_asterisk,
1805 .integer_literal,
18061806 });
18071807}
18081808
18091809test "tokenizer - range literals" {
1810 testTokenize("0...9", &[_]Token.Tag{ .IntegerLiteral, .Ellipsis3, .IntegerLiteral });
1811 testTokenize("'0'...'9'", &[_]Token.Tag{ .CharLiteral, .Ellipsis3, .CharLiteral });
1812 testTokenize("0x00...0x09", &[_]Token.Tag{ .IntegerLiteral, .Ellipsis3, .IntegerLiteral });
1813 testTokenize("0b00...0b11", &[_]Token.Tag{ .IntegerLiteral, .Ellipsis3, .IntegerLiteral });
1814 testTokenize("0o00...0o11", &[_]Token.Tag{ .IntegerLiteral, .Ellipsis3, .IntegerLiteral });
1810 testTokenize("0...9", &.{ .integer_literal, .ellipsis3, .integer_literal });
1811 testTokenize("'0'...'9'", &.{ .char_literal, .ellipsis3, .char_literal });
1812 testTokenize("0x00...0x09", &.{ .integer_literal, .ellipsis3, .integer_literal });
1813 testTokenize("0b00...0b11", &.{ .integer_literal, .ellipsis3, .integer_literal });
1814 testTokenize("0o00...0o11", &.{ .integer_literal, .ellipsis3, .integer_literal });
18151815}
18161816
18171817test "tokenizer - number literals decimal" {
1818 testTokenize("0", &[_]Token.Tag{.IntegerLiteral});
1819 testTokenize("1", &[_]Token.Tag{.IntegerLiteral});
1820 testTokenize("2", &[_]Token.Tag{.IntegerLiteral});
1821 testTokenize("3", &[_]Token.Tag{.IntegerLiteral});
1822 testTokenize("4", &[_]Token.Tag{.IntegerLiteral});
1823 testTokenize("5", &[_]Token.Tag{.IntegerLiteral});
1824 testTokenize("6", &[_]Token.Tag{.IntegerLiteral});
1825 testTokenize("7", &[_]Token.Tag{.IntegerLiteral});
1826 testTokenize("8", &[_]Token.Tag{.IntegerLiteral});
1827 testTokenize("9", &[_]Token.Tag{.IntegerLiteral});
1828 testTokenize("1..", &[_]Token.Tag{ .IntegerLiteral, .Ellipsis2 });
1829 testTokenize("0a", &[_]Token.Tag{ .Invalid, .Identifier });
1830 testTokenize("9b", &[_]Token.Tag{ .Invalid, .Identifier });
1831 testTokenize("1z", &[_]Token.Tag{ .Invalid, .Identifier });
1832 testTokenize("1z_1", &[_]Token.Tag{ .Invalid, .Identifier });
1833 testTokenize("9z3", &[_]Token.Tag{ .Invalid, .Identifier });
1834
1835 testTokenize("0_0", &[_]Token.Tag{.IntegerLiteral});
1836 testTokenize("0001", &[_]Token.Tag{.IntegerLiteral});
1837 testTokenize("01234567890", &[_]Token.Tag{.IntegerLiteral});
1838 testTokenize("012_345_6789_0", &[_]Token.Tag{.IntegerLiteral});
1839 testTokenize("0_1_2_3_4_5_6_7_8_9_0", &[_]Token.Tag{.IntegerLiteral});
1840
1841 testTokenize("00_", &[_]Token.Tag{.Invalid});
1842 testTokenize("0_0_", &[_]Token.Tag{.Invalid});
1843 testTokenize("0__0", &[_]Token.Tag{ .Invalid, .Identifier });
1844 testTokenize("0_0f", &[_]Token.Tag{ .Invalid, .Identifier });
1845 testTokenize("0_0_f", &[_]Token.Tag{ .Invalid, .Identifier });
1846 testTokenize("0_0_f_00", &[_]Token.Tag{ .Invalid, .Identifier });
1847 testTokenize("1_,", &[_]Token.Tag{ .Invalid, .Comma });
1848
1849 testTokenize("1.", &[_]Token.Tag{.FloatLiteral});
1850 testTokenize("0.0", &[_]Token.Tag{.FloatLiteral});
1851 testTokenize("1.0", &[_]Token.Tag{.FloatLiteral});
1852 testTokenize("10.0", &[_]Token.Tag{.FloatLiteral});
1853 testTokenize("0e0", &[_]Token.Tag{.FloatLiteral});
1854 testTokenize("1e0", &[_]Token.Tag{.FloatLiteral});
1855 testTokenize("1e100", &[_]Token.Tag{.FloatLiteral});
1856 testTokenize("1.e100", &[_]Token.Tag{.FloatLiteral});
1857 testTokenize("1.0e100", &[_]Token.Tag{.FloatLiteral});
1858 testTokenize("1.0e+100", &[_]Token.Tag{.FloatLiteral});
1859 testTokenize("1.0e-100", &[_]Token.Tag{.FloatLiteral});
1860 testTokenize("1_0_0_0.0_0_0_0_0_1e1_0_0_0", &[_]Token.Tag{.FloatLiteral});
1861 testTokenize("1.+", &[_]Token.Tag{ .FloatLiteral, .Plus });
1862
1863 testTokenize("1e", &[_]Token.Tag{.Invalid});
1864 testTokenize("1.0e1f0", &[_]Token.Tag{ .Invalid, .Identifier });
1865 testTokenize("1.0p100", &[_]Token.Tag{ .Invalid, .Identifier });
1866 testTokenize("1.0p-100", &[_]Token.Tag{ .Invalid, .Identifier, .Minus, .IntegerLiteral });
1867 testTokenize("1.0p1f0", &[_]Token.Tag{ .Invalid, .Identifier });
1868 testTokenize("1.0_,", &[_]Token.Tag{ .Invalid, .Comma });
1869 testTokenize("1_.0", &[_]Token.Tag{ .Invalid, .Period, .IntegerLiteral });
1870 testTokenize("1._", &[_]Token.Tag{ .Invalid, .Identifier });
1871 testTokenize("1.a", &[_]Token.Tag{ .Invalid, .Identifier });
1872 testTokenize("1.z", &[_]Token.Tag{ .Invalid, .Identifier });
1873 testTokenize("1._0", &[_]Token.Tag{ .Invalid, .Identifier });
1874 testTokenize("1._+", &[_]Token.Tag{ .Invalid, .Identifier, .Plus });
1875 testTokenize("1._e", &[_]Token.Tag{ .Invalid, .Identifier });
1876 testTokenize("1.0e", &[_]Token.Tag{.Invalid});
1877 testTokenize("1.0e,", &[_]Token.Tag{ .Invalid, .Comma });
1878 testTokenize("1.0e_", &[_]Token.Tag{ .Invalid, .Identifier });
1879 testTokenize("1.0e+_", &[_]Token.Tag{ .Invalid, .Identifier });
1880 testTokenize("1.0e-_", &[_]Token.Tag{ .Invalid, .Identifier });
1881 testTokenize("1.0e0_+", &[_]Token.Tag{ .Invalid, .Plus });
1818 testTokenize("0", &.{.integer_literal});
1819 testTokenize("1", &.{.integer_literal});
1820 testTokenize("2", &.{.integer_literal});
1821 testTokenize("3", &.{.integer_literal});
1822 testTokenize("4", &.{.integer_literal});
1823 testTokenize("5", &.{.integer_literal});
1824 testTokenize("6", &.{.integer_literal});
1825 testTokenize("7", &.{.integer_literal});
1826 testTokenize("8", &.{.integer_literal});
1827 testTokenize("9", &.{.integer_literal});
1828 testTokenize("1..", &.{ .integer_literal, .ellipsis2 });
1829 testTokenize("0a", &.{ .invalid, .identifier });
1830 testTokenize("9b", &.{ .invalid, .identifier });
1831 testTokenize("1z", &.{ .invalid, .identifier });
1832 testTokenize("1z_1", &.{ .invalid, .identifier });
1833 testTokenize("9z3", &.{ .invalid, .identifier });
1834
1835 testTokenize("0_0", &.{.integer_literal});
1836 testTokenize("0001", &.{.integer_literal});
1837 testTokenize("01234567890", &.{.integer_literal});
1838 testTokenize("012_345_6789_0", &.{.integer_literal});
1839 testTokenize("0_1_2_3_4_5_6_7_8_9_0", &.{.integer_literal});
1840
1841 testTokenize("00_", &.{.invalid});
1842 testTokenize("0_0_", &.{.invalid});
1843 testTokenize("0__0", &.{ .invalid, .identifier });
1844 testTokenize("0_0f", &.{ .invalid, .identifier });
1845 testTokenize("0_0_f", &.{ .invalid, .identifier });
1846 testTokenize("0_0_f_00", &.{ .invalid, .identifier });
1847 testTokenize("1_,", &.{ .invalid, .comma });
1848
1849 testTokenize("1.", &.{.float_literal});
1850 testTokenize("0.0", &.{.float_literal});
1851 testTokenize("1.0", &.{.float_literal});
1852 testTokenize("10.0", &.{.float_literal});
1853 testTokenize("0e0", &.{.float_literal});
1854 testTokenize("1e0", &.{.float_literal});
1855 testTokenize("1e100", &.{.float_literal});
1856 testTokenize("1.e100", &.{.float_literal});
1857 testTokenize("1.0e100", &.{.float_literal});
1858 testTokenize("1.0e+100", &.{.float_literal});
1859 testTokenize("1.0e-100", &.{.float_literal});
1860 testTokenize("1_0_0_0.0_0_0_0_0_1e1_0_0_0", &.{.float_literal});
1861 testTokenize("1.+", &.{ .float_literal, .plus });
1862
1863 testTokenize("1e", &.{.invalid});
1864 testTokenize("1.0e1f0", &.{ .invalid, .identifier });
1865 testTokenize("1.0p100", &.{ .invalid, .identifier });
1866 testTokenize("1.0p-100", &.{ .invalid, .identifier, .minus, .integer_literal });
1867 testTokenize("1.0p1f0", &.{ .invalid, .identifier });
1868 testTokenize("1.0_,", &.{ .invalid, .comma });
1869 testTokenize("1_.0", &.{ .invalid, .period, .integer_literal });
1870 testTokenize("1._", &.{ .invalid, .identifier });
1871 testTokenize("1.a", &.{ .invalid, .identifier });
1872 testTokenize("1.z", &.{ .invalid, .identifier });
1873 testTokenize("1._0", &.{ .invalid, .identifier });
1874 testTokenize("1._+", &.{ .invalid, .identifier, .plus });
1875 testTokenize("1._e", &.{ .invalid, .identifier });
1876 testTokenize("1.0e", &.{.invalid});
1877 testTokenize("1.0e,", &.{ .invalid, .comma });
1878 testTokenize("1.0e_", &.{ .invalid, .identifier });
1879 testTokenize("1.0e+_", &.{ .invalid, .identifier });
1880 testTokenize("1.0e-_", &.{ .invalid, .identifier });
1881 testTokenize("1.0e0_+", &.{ .invalid, .plus });
18821882}
18831883
18841884test "tokenizer - number literals binary" {
1885 testTokenize("0b0", &[_]Token.Tag{.IntegerLiteral});
1886 testTokenize("0b1", &[_]Token.Tag{.IntegerLiteral});
1887 testTokenize("0b2", &[_]Token.Tag{ .Invalid, .IntegerLiteral });
1888 testTokenize("0b3", &[_]Token.Tag{ .Invalid, .IntegerLiteral });
1889 testTokenize("0b4", &[_]Token.Tag{ .Invalid, .IntegerLiteral });
1890 testTokenize("0b5", &[_]Token.Tag{ .Invalid, .IntegerLiteral });
1891 testTokenize("0b6", &[_]Token.Tag{ .Invalid, .IntegerLiteral });
1892 testTokenize("0b7", &[_]Token.Tag{ .Invalid, .IntegerLiteral });
1893 testTokenize("0b8", &[_]Token.Tag{ .Invalid, .IntegerLiteral });
1894 testTokenize("0b9", &[_]Token.Tag{ .Invalid, .IntegerLiteral });
1895 testTokenize("0ba", &[_]Token.Tag{ .Invalid, .Identifier });
1896 testTokenize("0bb", &[_]Token.Tag{ .Invalid, .Identifier });
1897 testTokenize("0bc", &[_]Token.Tag{ .Invalid, .Identifier });
1898 testTokenize("0bd", &[_]Token.Tag{ .Invalid, .Identifier });
1899 testTokenize("0be", &[_]Token.Tag{ .Invalid, .Identifier });
1900 testTokenize("0bf", &[_]Token.Tag{ .Invalid, .Identifier });
1901 testTokenize("0bz", &[_]Token.Tag{ .Invalid, .Identifier });
1902
1903 testTokenize("0b0000_0000", &[_]Token.Tag{.IntegerLiteral});
1904 testTokenize("0b1111_1111", &[_]Token.Tag{.IntegerLiteral});
1905 testTokenize("0b10_10_10_10", &[_]Token.Tag{.IntegerLiteral});
1906 testTokenize("0b0_1_0_1_0_1_0_1", &[_]Token.Tag{.IntegerLiteral});
1907 testTokenize("0b1.", &[_]Token.Tag{ .IntegerLiteral, .Period });
1908 testTokenize("0b1.0", &[_]Token.Tag{ .IntegerLiteral, .Period, .IntegerLiteral });
1909
1910 testTokenize("0B0", &[_]Token.Tag{ .Invalid, .Identifier });
1911 testTokenize("0b_", &[_]Token.Tag{ .Invalid, .Identifier });
1912 testTokenize("0b_0", &[_]Token.Tag{ .Invalid, .Identifier });
1913 testTokenize("0b1_", &[_]Token.Tag{.Invalid});
1914 testTokenize("0b0__1", &[_]Token.Tag{ .Invalid, .Identifier });
1915 testTokenize("0b0_1_", &[_]Token.Tag{.Invalid});
1916 testTokenize("0b1e", &[_]Token.Tag{ .Invalid, .Identifier });
1917 testTokenize("0b1p", &[_]Token.Tag{ .Invalid, .Identifier });
1918 testTokenize("0b1e0", &[_]Token.Tag{ .Invalid, .Identifier });
1919 testTokenize("0b1p0", &[_]Token.Tag{ .Invalid, .Identifier });
1920 testTokenize("0b1_,", &[_]Token.Tag{ .Invalid, .Comma });
1885 testTokenize("0b0", &.{.integer_literal});
1886 testTokenize("0b1", &.{.integer_literal});
1887 testTokenize("0b2", &.{ .invalid, .integer_literal });
1888 testTokenize("0b3", &.{ .invalid, .integer_literal });
1889 testTokenize("0b4", &.{ .invalid, .integer_literal });
1890 testTokenize("0b5", &.{ .invalid, .integer_literal });
1891 testTokenize("0b6", &.{ .invalid, .integer_literal });
1892 testTokenize("0b7", &.{ .invalid, .integer_literal });
1893 testTokenize("0b8", &.{ .invalid, .integer_literal });
1894 testTokenize("0b9", &.{ .invalid, .integer_literal });
1895 testTokenize("0ba", &.{ .invalid, .identifier });
1896 testTokenize("0bb", &.{ .invalid, .identifier });
1897 testTokenize("0bc", &.{ .invalid, .identifier });
1898 testTokenize("0bd", &.{ .invalid, .identifier });
1899 testTokenize("0be", &.{ .invalid, .identifier });
1900 testTokenize("0bf", &.{ .invalid, .identifier });
1901 testTokenize("0bz", &.{ .invalid, .identifier });
1902
1903 testTokenize("0b0000_0000", &.{.integer_literal});
1904 testTokenize("0b1111_1111", &.{.integer_literal});
1905 testTokenize("0b10_10_10_10", &.{.integer_literal});
1906 testTokenize("0b0_1_0_1_0_1_0_1", &.{.integer_literal});
1907 testTokenize("0b1.", &.{ .integer_literal, .period });
1908 testTokenize("0b1.0", &.{ .integer_literal, .period, .integer_literal });
1909
1910 testTokenize("0B0", &.{ .invalid, .identifier });
1911 testTokenize("0b_", &.{ .invalid, .identifier });
1912 testTokenize("0b_0", &.{ .invalid, .identifier });
1913 testTokenize("0b1_", &.{.invalid});
1914 testTokenize("0b0__1", &.{ .invalid, .identifier });
1915 testTokenize("0b0_1_", &.{.invalid});
1916 testTokenize("0b1e", &.{ .invalid, .identifier });
1917 testTokenize("0b1p", &.{ .invalid, .identifier });
1918 testTokenize("0b1e0", &.{ .invalid, .identifier });
1919 testTokenize("0b1p0", &.{ .invalid, .identifier });
1920 testTokenize("0b1_,", &.{ .invalid, .comma });
19211921}
19221922
19231923test "tokenizer - number literals octal" {
1924 testTokenize("0o0", &[_]Token.Tag{.IntegerLiteral});
1925 testTokenize("0o1", &[_]Token.Tag{.IntegerLiteral});
1926 testTokenize("0o2", &[_]Token.Tag{.IntegerLiteral});
1927 testTokenize("0o3", &[_]Token.Tag{.IntegerLiteral});
1928 testTokenize("0o4", &[_]Token.Tag{.IntegerLiteral});
1929 testTokenize("0o5", &[_]Token.Tag{.IntegerLiteral});
1930 testTokenize("0o6", &[_]Token.Tag{.IntegerLiteral});
1931 testTokenize("0o7", &[_]Token.Tag{.IntegerLiteral});
1932 testTokenize("0o8", &[_]Token.Tag{ .Invalid, .IntegerLiteral });
1933 testTokenize("0o9", &[_]Token.Tag{ .Invalid, .IntegerLiteral });
1934 testTokenize("0oa", &[_]Token.Tag{ .Invalid, .Identifier });
1935 testTokenize("0ob", &[_]Token.Tag{ .Invalid, .Identifier });
1936 testTokenize("0oc", &[_]Token.Tag{ .Invalid, .Identifier });
1937 testTokenize("0od", &[_]Token.Tag{ .Invalid, .Identifier });
1938 testTokenize("0oe", &[_]Token.Tag{ .Invalid, .Identifier });
1939 testTokenize("0of", &[_]Token.Tag{ .Invalid, .Identifier });
1940 testTokenize("0oz", &[_]Token.Tag{ .Invalid, .Identifier });
1941
1942 testTokenize("0o01234567", &[_]Token.Tag{.IntegerLiteral});
1943 testTokenize("0o0123_4567", &[_]Token.Tag{.IntegerLiteral});
1944 testTokenize("0o01_23_45_67", &[_]Token.Tag{.IntegerLiteral});
1945 testTokenize("0o0_1_2_3_4_5_6_7", &[_]Token.Tag{.IntegerLiteral});
1946 testTokenize("0o7.", &[_]Token.Tag{ .IntegerLiteral, .Period });
1947 testTokenize("0o7.0", &[_]Token.Tag{ .IntegerLiteral, .Period, .IntegerLiteral });
1948
1949 testTokenize("0O0", &[_]Token.Tag{ .Invalid, .Identifier });
1950 testTokenize("0o_", &[_]Token.Tag{ .Invalid, .Identifier });
1951 testTokenize("0o_0", &[_]Token.Tag{ .Invalid, .Identifier });
1952 testTokenize("0o1_", &[_]Token.Tag{.Invalid});
1953 testTokenize("0o0__1", &[_]Token.Tag{ .Invalid, .Identifier });
1954 testTokenize("0o0_1_", &[_]Token.Tag{.Invalid});
1955 testTokenize("0o1e", &[_]Token.Tag{ .Invalid, .Identifier });
1956 testTokenize("0o1p", &[_]Token.Tag{ .Invalid, .Identifier });
1957 testTokenize("0o1e0", &[_]Token.Tag{ .Invalid, .Identifier });
1958 testTokenize("0o1p0", &[_]Token.Tag{ .Invalid, .Identifier });
1959 testTokenize("0o_,", &[_]Token.Tag{ .Invalid, .Identifier, .Comma });
1924 testTokenize("0o0", &.{.integer_literal});
1925 testTokenize("0o1", &.{.integer_literal});
1926 testTokenize("0o2", &.{.integer_literal});
1927 testTokenize("0o3", &.{.integer_literal});
1928 testTokenize("0o4", &.{.integer_literal});
1929 testTokenize("0o5", &.{.integer_literal});
1930 testTokenize("0o6", &.{.integer_literal});
1931 testTokenize("0o7", &.{.integer_literal});
1932 testTokenize("0o8", &.{ .invalid, .integer_literal });
1933 testTokenize("0o9", &.{ .invalid, .integer_literal });
1934 testTokenize("0oa", &.{ .invalid, .identifier });
1935 testTokenize("0ob", &.{ .invalid, .identifier });
1936 testTokenize("0oc", &.{ .invalid, .identifier });
1937 testTokenize("0od", &.{ .invalid, .identifier });
1938 testTokenize("0oe", &.{ .invalid, .identifier });
1939 testTokenize("0of", &.{ .invalid, .identifier });
1940 testTokenize("0oz", &.{ .invalid, .identifier });
1941
1942 testTokenize("0o01234567", &.{.integer_literal});
1943 testTokenize("0o0123_4567", &.{.integer_literal});
1944 testTokenize("0o01_23_45_67", &.{.integer_literal});
1945 testTokenize("0o0_1_2_3_4_5_6_7", &.{.integer_literal});
1946 testTokenize("0o7.", &.{ .integer_literal, .period });
1947 testTokenize("0o7.0", &.{ .integer_literal, .period, .integer_literal });
1948
1949 testTokenize("0O0", &.{ .invalid, .identifier });
1950 testTokenize("0o_", &.{ .invalid, .identifier });
1951 testTokenize("0o_0", &.{ .invalid, .identifier });
1952 testTokenize("0o1_", &.{.invalid});
1953 testTokenize("0o0__1", &.{ .invalid, .identifier });
1954 testTokenize("0o0_1_", &.{.invalid});
1955 testTokenize("0o1e", &.{ .invalid, .identifier });
1956 testTokenize("0o1p", &.{ .invalid, .identifier });
1957 testTokenize("0o1e0", &.{ .invalid, .identifier });
1958 testTokenize("0o1p0", &.{ .invalid, .identifier });
1959 testTokenize("0o_,", &.{ .invalid, .identifier, .comma });
19601960}
19611961
19621962test "tokenizer - number literals hexadeciaml" {
1963 testTokenize("0x0", &[_]Token.Tag{.IntegerLiteral});
1964 testTokenize("0x1", &[_]Token.Tag{.IntegerLiteral});
1965 testTokenize("0x2", &[_]Token.Tag{.IntegerLiteral});
1966 testTokenize("0x3", &[_]Token.Tag{.IntegerLiteral});
1967 testTokenize("0x4", &[_]Token.Tag{.IntegerLiteral});
1968 testTokenize("0x5", &[_]Token.Tag{.IntegerLiteral});
1969 testTokenize("0x6", &[_]Token.Tag{.IntegerLiteral});
1970 testTokenize("0x7", &[_]Token.Tag{.IntegerLiteral});
1971 testTokenize("0x8", &[_]Token.Tag{.IntegerLiteral});
1972 testTokenize("0x9", &[_]Token.Tag{.IntegerLiteral});
1973 testTokenize("0xa", &[_]Token.Tag{.IntegerLiteral});
1974 testTokenize("0xb", &[_]Token.Tag{.IntegerLiteral});
1975 testTokenize("0xc", &[_]Token.Tag{.IntegerLiteral});
1976 testTokenize("0xd", &[_]Token.Tag{.IntegerLiteral});
1977 testTokenize("0xe", &[_]Token.Tag{.IntegerLiteral});
1978 testTokenize("0xf", &[_]Token.Tag{.IntegerLiteral});
1979 testTokenize("0xA", &[_]Token.Tag{.IntegerLiteral});
1980 testTokenize("0xB", &[_]Token.Tag{.IntegerLiteral});
1981 testTokenize("0xC", &[_]Token.Tag{.IntegerLiteral});
1982 testTokenize("0xD", &[_]Token.Tag{.IntegerLiteral});
1983 testTokenize("0xE", &[_]Token.Tag{.IntegerLiteral});
1984 testTokenize("0xF", &[_]Token.Tag{.IntegerLiteral});
1985 testTokenize("0x0z", &[_]Token.Tag{ .Invalid, .Identifier });
1986 testTokenize("0xz", &[_]Token.Tag{ .Invalid, .Identifier });
1987
1988 testTokenize("0x0123456789ABCDEF", &[_]Token.Tag{.IntegerLiteral});
1989 testTokenize("0x0123_4567_89AB_CDEF", &[_]Token.Tag{.IntegerLiteral});
1990 testTokenize("0x01_23_45_67_89AB_CDE_F", &[_]Token.Tag{.IntegerLiteral});
1991 testTokenize("0x0_1_2_3_4_5_6_7_8_9_A_B_C_D_E_F", &[_]Token.Tag{.IntegerLiteral});
1992
1993 testTokenize("0X0", &[_]Token.Tag{ .Invalid, .Identifier });
1994 testTokenize("0x_", &[_]Token.Tag{ .Invalid, .Identifier });
1995 testTokenize("0x_1", &[_]Token.Tag{ .Invalid, .Identifier });
1996 testTokenize("0x1_", &[_]Token.Tag{.Invalid});
1997 testTokenize("0x0__1", &[_]Token.Tag{ .Invalid, .Identifier });
1998 testTokenize("0x0_1_", &[_]Token.Tag{.Invalid});
1999 testTokenize("0x_,", &[_]Token.Tag{ .Invalid, .Identifier, .Comma });
2000
2001 testTokenize("0x1.", &[_]Token.Tag{.FloatLiteral});
2002 testTokenize("0x1.0", &[_]Token.Tag{.FloatLiteral});
2003 testTokenize("0xF.", &[_]Token.Tag{.FloatLiteral});
2004 testTokenize("0xF.0", &[_]Token.Tag{.FloatLiteral});
2005 testTokenize("0xF.F", &[_]Token.Tag{.FloatLiteral});
2006 testTokenize("0xF.Fp0", &[_]Token.Tag{.FloatLiteral});
2007 testTokenize("0xF.FP0", &[_]Token.Tag{.FloatLiteral});
2008 testTokenize("0x1p0", &[_]Token.Tag{.FloatLiteral});
2009 testTokenize("0xfp0", &[_]Token.Tag{.FloatLiteral});
2010 testTokenize("0x1.+0xF.", &[_]Token.Tag{ .FloatLiteral, .Plus, .FloatLiteral });
2011
2012 testTokenize("0x0123456.789ABCDEF", &[_]Token.Tag{.FloatLiteral});
2013 testTokenize("0x0_123_456.789_ABC_DEF", &[_]Token.Tag{.FloatLiteral});
2014 testTokenize("0x0_1_2_3_4_5_6.7_8_9_A_B_C_D_E_F", &[_]Token.Tag{.FloatLiteral});
2015 testTokenize("0x0p0", &[_]Token.Tag{.FloatLiteral});
2016 testTokenize("0x0.0p0", &[_]Token.Tag{.FloatLiteral});
2017 testTokenize("0xff.ffp10", &[_]Token.Tag{.FloatLiteral});
2018 testTokenize("0xff.ffP10", &[_]Token.Tag{.FloatLiteral});
2019 testTokenize("0xff.p10", &[_]Token.Tag{.FloatLiteral});
2020 testTokenize("0xffp10", &[_]Token.Tag{.FloatLiteral});
2021 testTokenize("0xff_ff.ff_ffp1_0_0_0", &[_]Token.Tag{.FloatLiteral});
2022 testTokenize("0xf_f_f_f.f_f_f_fp+1_000", &[_]Token.Tag{.FloatLiteral});
2023 testTokenize("0xf_f_f_f.f_f_f_fp-1_00_0", &[_]Token.Tag{.FloatLiteral});
2024
2025 testTokenize("0x1e", &[_]Token.Tag{.IntegerLiteral});
2026 testTokenize("0x1e0", &[_]Token.Tag{.IntegerLiteral});
2027 testTokenize("0x1p", &[_]Token.Tag{.Invalid});
2028 testTokenize("0xfp0z1", &[_]Token.Tag{ .Invalid, .Identifier });
2029 testTokenize("0xff.ffpff", &[_]Token.Tag{ .Invalid, .Identifier });
2030 testTokenize("0x0.p", &[_]Token.Tag{.Invalid});
2031 testTokenize("0x0.z", &[_]Token.Tag{ .Invalid, .Identifier });
2032 testTokenize("0x0._", &[_]Token.Tag{ .Invalid, .Identifier });
2033 testTokenize("0x0_.0", &[_]Token.Tag{ .Invalid, .Period, .IntegerLiteral });
2034 testTokenize("0x0_.0.0", &[_]Token.Tag{ .Invalid, .Period, .FloatLiteral });
2035 testTokenize("0x0._0", &[_]Token.Tag{ .Invalid, .Identifier });
2036 testTokenize("0x0.0_", &[_]Token.Tag{.Invalid});
2037 testTokenize("0x0_p0", &[_]Token.Tag{ .Invalid, .Identifier });
2038 testTokenize("0x0_.p0", &[_]Token.Tag{ .Invalid, .Period, .Identifier });
2039 testTokenize("0x0._p0", &[_]Token.Tag{ .Invalid, .Identifier });
2040 testTokenize("0x0.0_p0", &[_]Token.Tag{ .Invalid, .Identifier });
2041 testTokenize("0x0._0p0", &[_]Token.Tag{ .Invalid, .Identifier });
2042 testTokenize("0x0.0p_0", &[_]Token.Tag{ .Invalid, .Identifier });
2043 testTokenize("0x0.0p+_0", &[_]Token.Tag{ .Invalid, .Identifier });
2044 testTokenize("0x0.0p-_0", &[_]Token.Tag{ .Invalid, .Identifier });
2045 testTokenize("0x0.0p0_", &[_]Token.Tag{ .Invalid, .Eof });
1963 testTokenize("0x0", &.{.integer_literal});
1964 testTokenize("0x1", &.{.integer_literal});
1965 testTokenize("0x2", &.{.integer_literal});
1966 testTokenize("0x3", &.{.integer_literal});
1967 testTokenize("0x4", &.{.integer_literal});
1968 testTokenize("0x5", &.{.integer_literal});
1969 testTokenize("0x6", &.{.integer_literal});
1970 testTokenize("0x7", &.{.integer_literal});
1971 testTokenize("0x8", &.{.integer_literal});
1972 testTokenize("0x9", &.{.integer_literal});
1973 testTokenize("0xa", &.{.integer_literal});
1974 testTokenize("0xb", &.{.integer_literal});
1975 testTokenize("0xc", &.{.integer_literal});
1976 testTokenize("0xd", &.{.integer_literal});
1977 testTokenize("0xe", &.{.integer_literal});
1978 testTokenize("0xf", &.{.integer_literal});
1979 testTokenize("0xA", &.{.integer_literal});
1980 testTokenize("0xB", &.{.integer_literal});
1981 testTokenize("0xC", &.{.integer_literal});
1982 testTokenize("0xD", &.{.integer_literal});
1983 testTokenize("0xE", &.{.integer_literal});
1984 testTokenize("0xF", &.{.integer_literal});
1985 testTokenize("0x0z", &.{ .invalid, .identifier });
1986 testTokenize("0xz", &.{ .invalid, .identifier });
1987
1988 testTokenize("0x0123456789ABCDEF", &.{.integer_literal});
1989 testTokenize("0x0123_4567_89AB_CDEF", &.{.integer_literal});
1990 testTokenize("0x01_23_45_67_89AB_CDE_F", &.{.integer_literal});
1991 testTokenize("0x0_1_2_3_4_5_6_7_8_9_A_B_C_D_E_F", &.{.integer_literal});
1992
1993 testTokenize("0X0", &.{ .invalid, .identifier });
1994 testTokenize("0x_", &.{ .invalid, .identifier });
1995 testTokenize("0x_1", &.{ .invalid, .identifier });
1996 testTokenize("0x1_", &.{.invalid});
1997 testTokenize("0x0__1", &.{ .invalid, .identifier });
1998 testTokenize("0x0_1_", &.{.invalid});
1999 testTokenize("0x_,", &.{ .invalid, .identifier, .comma });
2000
2001 testTokenize("0x1.", &.{.float_literal});
2002 testTokenize("0x1.0", &.{.float_literal});
2003 testTokenize("0xF.", &.{.float_literal});
2004 testTokenize("0xF.0", &.{.float_literal});
2005 testTokenize("0xF.F", &.{.float_literal});
2006 testTokenize("0xF.Fp0", &.{.float_literal});
2007 testTokenize("0xF.FP0", &.{.float_literal});
2008 testTokenize("0x1p0", &.{.float_literal});
2009 testTokenize("0xfp0", &.{.float_literal});
2010 testTokenize("0x1.+0xF.", &.{ .float_literal, .plus, .float_literal });
2011
2012 testTokenize("0x0123456.789ABCDEF", &.{.float_literal});
2013 testTokenize("0x0_123_456.789_ABC_DEF", &.{.float_literal});
2014 testTokenize("0x0_1_2_3_4_5_6.7_8_9_A_B_C_D_E_F", &.{.float_literal});
2015 testTokenize("0x0p0", &.{.float_literal});
2016 testTokenize("0x0.0p0", &.{.float_literal});
2017 testTokenize("0xff.ffp10", &.{.float_literal});
2018 testTokenize("0xff.ffP10", &.{.float_literal});
2019 testTokenize("0xff.p10", &.{.float_literal});
2020 testTokenize("0xffp10", &.{.float_literal});
2021 testTokenize("0xff_ff.ff_ffp1_0_0_0", &.{.float_literal});
2022 testTokenize("0xf_f_f_f.f_f_f_fp+1_000", &.{.float_literal});
2023 testTokenize("0xf_f_f_f.f_f_f_fp-1_00_0", &.{.float_literal});
2024
2025 testTokenize("0x1e", &.{.integer_literal});
2026 testTokenize("0x1e0", &.{.integer_literal});
2027 testTokenize("0x1p", &.{.invalid});
2028 testTokenize("0xfp0z1", &.{ .invalid, .identifier });
2029 testTokenize("0xff.ffpff", &.{ .invalid, .identifier });
2030 testTokenize("0x0.p", &.{.invalid});
2031 testTokenize("0x0.z", &.{ .invalid, .identifier });
2032 testTokenize("0x0._", &.{ .invalid, .identifier });
2033 testTokenize("0x0_.0", &.{ .invalid, .period, .integer_literal });
2034 testTokenize("0x0_.0.0", &.{ .invalid, .period, .float_literal });
2035 testTokenize("0x0._0", &.{ .invalid, .identifier });
2036 testTokenize("0x0.0_", &.{.invalid});
2037 testTokenize("0x0_p0", &.{ .invalid, .identifier });
2038 testTokenize("0x0_.p0", &.{ .invalid, .period, .identifier });
2039 testTokenize("0x0._p0", &.{ .invalid, .identifier });
2040 testTokenize("0x0.0_p0", &.{ .invalid, .identifier });
2041 testTokenize("0x0._0p0", &.{ .invalid, .identifier });
2042 testTokenize("0x0.0p_0", &.{ .invalid, .identifier });
2043 testTokenize("0x0.0p+_0", &.{ .invalid, .identifier });
2044 testTokenize("0x0.0p-_0", &.{ .invalid, .identifier });
2045 testTokenize("0x0.0p0_", &.{ .invalid, .eof });
20462046}
20472047
20482048fn testTokenize(source: []const u8, expected_tokens: []const Token.Tag) void {
......@@ -2054,5 +2054,5 @@ fn testTokenize(source: []const u8, expected_tokens: []const Token.Tag) void {
20542054 }
20552055 }
20562056 const last_token = tokenizer.next();
2057 std.testing.expect(last_token.tag == .Eof);
2057 std.testing.expect(last_token.tag == .eof);
20582058}