authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-05-21 10:09:47-07:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2023-05-21 10:09:47-07:00
log9d4d96ca9b186af2705f88c17b2704096c08e829
treed68831f17aaa2b71704759209d2dc5badfee7a3e
parentdf909da5d87fda01245c564858522c6c57dd8a75
parent2088e8dc6f14b4004905aaea5a518ef87ca5c0dc
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

Merge pull request #15796 from linusg/docgen-snek-case-enums


1 files changed, 133 insertions(+), 134 deletions(-)

doc/docgen.zig+133-134
...@@ -111,13 +111,13 @@ const Token = struct {...@@ -111,13 +111,13 @@ const Token = struct {
111 end: usize,111 end: usize,
112112
113 const Id = enum {113 const Id = enum {
114 Invalid,114 invalid,
115 Content,115 content,
116 BracketOpen,116 bracket_open,
117 TagContent,117 tag_content,
118 Separator,118 separator,
119 BracketClose,119 bracket_close,
120 Eof,120 eof,
121 };121 };
122};122};
123123
...@@ -129,18 +129,18 @@ const Tokenizer = struct {...@@ -129,18 +129,18 @@ const Tokenizer = struct {
129 code_node_count: usize,129 code_node_count: usize,
130130
131 const State = enum {131 const State = enum {
132 Start,132 start,
133 LBracket,133 l_bracket,
134 Hash,134 hash,
135 TagName,135 tag_name,
136 Eof,136 eof,
137 };137 };
138138
139 fn init(source_file_name: []const u8, buffer: []const u8) Tokenizer {139 fn init(source_file_name: []const u8, buffer: []const u8) Tokenizer {
140 return Tokenizer{140 return Tokenizer{
141 .buffer = buffer,141 .buffer = buffer,
142 .index = 0,142 .index = 0,
143 .state = State.Start,143 .state = .start,
144 .source_file_name = source_file_name,144 .source_file_name = source_file_name,
145 .code_node_count = 0,145 .code_node_count = 0,
146 };146 };
...@@ -148,84 +148,84 @@ const Tokenizer = struct {...@@ -148,84 +148,84 @@ const Tokenizer = struct {
148148
149 fn next(self: *Tokenizer) Token {149 fn next(self: *Tokenizer) Token {
150 var result = Token{150 var result = Token{
151 .id = Token.Id.Eof,151 .id = .eof,
152 .start = self.index,152 .start = self.index,
153 .end = undefined,153 .end = undefined,
154 };154 };
155 while (self.index < self.buffer.len) : (self.index += 1) {155 while (self.index < self.buffer.len) : (self.index += 1) {
156 const c = self.buffer[self.index];156 const c = self.buffer[self.index];
157 switch (self.state) {157 switch (self.state) {
158 State.Start => switch (c) {158 .start => switch (c) {
159 '{' => {159 '{' => {
160 self.state = State.LBracket;160 self.state = .l_bracket;
161 },161 },
162 else => {162 else => {
163 result.id = Token.Id.Content;163 result.id = .content;
164 },164 },
165 },165 },
166 State.LBracket => switch (c) {166 .l_bracket => switch (c) {
167 '#' => {167 '#' => {
168 if (result.id != Token.Id.Eof) {168 if (result.id != .eof) {
169 self.index -= 1;169 self.index -= 1;
170 self.state = State.Start;170 self.state = .start;
171 break;171 break;
172 } else {172 } else {
173 result.id = Token.Id.BracketOpen;173 result.id = .bracket_open;
174 self.index += 1;174 self.index += 1;
175 self.state = State.TagName;175 self.state = .tag_name;
176 break;176 break;
177 }177 }
178 },178 },
179 else => {179 else => {
180 result.id = Token.Id.Content;180 result.id = .content;
181 self.state = State.Start;181 self.state = .start;
182 },182 },
183 },183 },
184 State.TagName => switch (c) {184 .tag_name => switch (c) {
185 '|' => {185 '|' => {
186 if (result.id != Token.Id.Eof) {186 if (result.id != .eof) {
187 break;187 break;
188 } else {188 } else {
189 result.id = Token.Id.Separator;189 result.id = .separator;
190 self.index += 1;190 self.index += 1;
191 break;191 break;
192 }192 }
193 },193 },
194 '#' => {194 '#' => {
195 self.state = State.Hash;195 self.state = .hash;
196 },196 },
197 else => {197 else => {
198 result.id = Token.Id.TagContent;198 result.id = .tag_content;
199 },199 },
200 },200 },
201 State.Hash => switch (c) {201 .hash => switch (c) {
202 '}' => {202 '}' => {
203 if (result.id != Token.Id.Eof) {203 if (result.id != .eof) {
204 self.index -= 1;204 self.index -= 1;
205 self.state = State.TagName;205 self.state = .tag_name;
206 break;206 break;
207 } else {207 } else {
208 result.id = Token.Id.BracketClose;208 result.id = .bracket_close;
209 self.index += 1;209 self.index += 1;
210 self.state = State.Start;210 self.state = .start;
211 break;211 break;
212 }212 }
213 },213 },
214 else => {214 else => {
215 result.id = Token.Id.TagContent;215 result.id = .tag_content;
216 self.state = State.TagName;216 self.state = .tag_name;
217 },217 },
218 },218 },
219 State.Eof => unreachable,219 .eof => unreachable,
220 }220 }
221 } else {221 } else {
222 switch (self.state) {222 switch (self.state) {
223 State.Start, State.LBracket, State.Eof => {},223 .start, .l_bracket, .eof => {},
224 else => {224 else => {
225 result.id = Token.Id.Invalid;225 result.id = .invalid;
226 },226 },
227 }227 }
228 self.state = State.Eof;228 self.state = .eof;
229 }229 }
230 result.end = self.index;230 result.end = self.index;
231 return result;231 return result;
...@@ -311,9 +311,9 @@ const SeeAlsoItem = struct {...@@ -311,9 +311,9 @@ const SeeAlsoItem = struct {
311};311};
312312
313const ExpectedOutcome = enum {313const ExpectedOutcome = enum {
314 Succeed,314 succeed,
315 Fail,315 fail,
316 BuildFail,316 build_fail,
317};317};
318318
319const Code = struct {319const Code = struct {
...@@ -331,12 +331,12 @@ const Code = struct {...@@ -331,12 +331,12 @@ const Code = struct {
331 additional_options: []const []const u8,331 additional_options: []const []const u8,
332332
333 const Id = union(enum) {333 const Id = union(enum) {
334 Test,334 @"test",
335 TestError: []const u8,335 test_error: []const u8,
336 TestSafety: []const u8,336 test_safety: []const u8,
337 Exe: ExpectedOutcome,337 exe: ExpectedOutcome,
338 Obj: ?[]const u8,338 obj: ?[]const u8,
339 Lib,339 lib,
340 };340 };
341};341};
342342
...@@ -379,8 +379,8 @@ const Toc = struct {...@@ -379,8 +379,8 @@ const Toc = struct {
379};379};
380380
381const Action = enum {381const Action = enum {
382 Open,382 open,
383 Close,383 close,
384};384};
385385
386fn genToc(allocator: Allocator, tokenizer: *Tokenizer) !Toc {386fn genToc(allocator: Allocator, tokenizer: *Tokenizer) !Toc {
...@@ -388,7 +388,7 @@ fn genToc(allocator: Allocator, tokenizer: *Tokenizer) !Toc {...@@ -388,7 +388,7 @@ fn genToc(allocator: Allocator, tokenizer: *Tokenizer) !Toc {
388 errdefer urls.deinit();388 errdefer urls.deinit();
389389
390 var header_stack_size: usize = 0;390 var header_stack_size: usize = 0;
391 var last_action = Action.Open;391 var last_action: Action = .open;
392 var last_columns: ?u8 = null;392 var last_columns: ?u8 = null;
393393
394 var toc_buf = std.ArrayList(u8).init(allocator);394 var toc_buf = std.ArrayList(u8).init(allocator);
...@@ -404,38 +404,38 @@ fn genToc(allocator: Allocator, tokenizer: *Tokenizer) !Toc {...@@ -404,38 +404,38 @@ fn genToc(allocator: Allocator, tokenizer: *Tokenizer) !Toc {
404 while (true) {404 while (true) {
405 const token = tokenizer.next();405 const token = tokenizer.next();
406 switch (token.id) {406 switch (token.id) {
407 Token.Id.Eof => {407 .eof => {
408 if (header_stack_size != 0) {408 if (header_stack_size != 0) {
409 return parseError(tokenizer, token, "unbalanced headers", .{});409 return parseError(tokenizer, token, "unbalanced headers", .{});
410 }410 }
411 try toc.writeAll(" </ul>\n");411 try toc.writeAll(" </ul>\n");
412 break;412 break;
413 },413 },
414 Token.Id.Content => {414 .content => {
415 try nodes.append(Node{ .Content = tokenizer.buffer[token.start..token.end] });415 try nodes.append(Node{ .Content = tokenizer.buffer[token.start..token.end] });
416 },416 },
417 Token.Id.BracketOpen => {417 .bracket_open => {
418 const tag_token = try eatToken(tokenizer, Token.Id.TagContent);418 const tag_token = try eatToken(tokenizer, .tag_content);
419 const tag_name = tokenizer.buffer[tag_token.start..tag_token.end];419 const tag_name = tokenizer.buffer[tag_token.start..tag_token.end];
420420
421 if (mem.eql(u8, tag_name, "nav")) {421 if (mem.eql(u8, tag_name, "nav")) {
422 _ = try eatToken(tokenizer, Token.Id.BracketClose);422 _ = try eatToken(tokenizer, .bracket_close);
423423
424 try nodes.append(Node.Nav);424 try nodes.append(Node.Nav);
425 } else if (mem.eql(u8, tag_name, "builtin")) {425 } else if (mem.eql(u8, tag_name, "builtin")) {
426 _ = try eatToken(tokenizer, Token.Id.BracketClose);426 _ = try eatToken(tokenizer, .bracket_close);
427 try nodes.append(Node{ .Builtin = tag_token });427 try nodes.append(Node{ .Builtin = tag_token });
428 } else if (mem.eql(u8, tag_name, "header_open")) {428 } else if (mem.eql(u8, tag_name, "header_open")) {
429 _ = try eatToken(tokenizer, Token.Id.Separator);429 _ = try eatToken(tokenizer, .separator);
430 const content_token = try eatToken(tokenizer, Token.Id.TagContent);430 const content_token = try eatToken(tokenizer, .tag_content);
431 const content = tokenizer.buffer[content_token.start..content_token.end];431 const content = tokenizer.buffer[content_token.start..content_token.end];
432 var columns: ?u8 = null;432 var columns: ?u8 = null;
433 while (true) {433 while (true) {
434 const bracket_tok = tokenizer.next();434 const bracket_tok = tokenizer.next();
435 switch (bracket_tok.id) {435 switch (bracket_tok.id) {
436 .BracketClose => break,436 .bracket_close => break,
437 .Separator => continue,437 .separator => continue,
438 .TagContent => {438 .tag_content => {
439 const param = tokenizer.buffer[bracket_tok.start..bracket_tok.end];439 const param = tokenizer.buffer[bracket_tok.start..bracket_tok.end];
440 if (mem.eql(u8, param, "2col")) {440 if (mem.eql(u8, param, "2col")) {
441 columns = 2;441 columns = 2;
...@@ -467,7 +467,7 @@ fn genToc(allocator: Allocator, tokenizer: *Tokenizer) !Toc {...@@ -467,7 +467,7 @@ fn genToc(allocator: Allocator, tokenizer: *Tokenizer) !Toc {
467 parseError(tokenizer, kv.value, "other tag here", .{}) catch {};467 parseError(tokenizer, kv.value, "other tag here", .{}) catch {};
468 return error.ParseError;468 return error.ParseError;
469 }469 }
470 if (last_action == Action.Open) {470 if (last_action == .open) {
471 try toc.writeByte('\n');471 try toc.writeByte('\n');
472 try toc.writeByteNTimes(' ', header_stack_size * 4);472 try toc.writeByteNTimes(' ', header_stack_size * 4);
473 if (last_columns) |n| {473 if (last_columns) |n| {
...@@ -476,7 +476,7 @@ fn genToc(allocator: Allocator, tokenizer: *Tokenizer) !Toc {...@@ -476,7 +476,7 @@ fn genToc(allocator: Allocator, tokenizer: *Tokenizer) !Toc {
476 try toc.writeAll("<ul>\n");476 try toc.writeAll("<ul>\n");
477 }477 }
478 } else {478 } else {
479 last_action = Action.Open;479 last_action = .open;
480 }480 }
481 last_columns = columns;481 last_columns = columns;
482 try toc.writeByteNTimes(' ', 4 + header_stack_size * 4);482 try toc.writeByteNTimes(' ', 4 + header_stack_size * 4);
...@@ -486,14 +486,14 @@ fn genToc(allocator: Allocator, tokenizer: *Tokenizer) !Toc {...@@ -486,14 +486,14 @@ fn genToc(allocator: Allocator, tokenizer: *Tokenizer) !Toc {
486 return parseError(tokenizer, tag_token, "unbalanced close header", .{});486 return parseError(tokenizer, tag_token, "unbalanced close header", .{});
487 }487 }
488 header_stack_size -= 1;488 header_stack_size -= 1;
489 _ = try eatToken(tokenizer, Token.Id.BracketClose);489 _ = try eatToken(tokenizer, .bracket_close);
490490
491 if (last_action == Action.Close) {491 if (last_action == .close) {
492 try toc.writeByteNTimes(' ', 8 + header_stack_size * 4);492 try toc.writeByteNTimes(' ', 8 + header_stack_size * 4);
493 try toc.writeAll("</ul></li>\n");493 try toc.writeAll("</ul></li>\n");
494 } else {494 } else {
495 try toc.writeAll("</li>\n");495 try toc.writeAll("</li>\n");
496 last_action = Action.Close;496 last_action = .close;
497 }497 }
498 } else if (mem.eql(u8, tag_name, "see_also")) {498 } else if (mem.eql(u8, tag_name, "see_also")) {
499 var list = std.ArrayList(SeeAlsoItem).init(allocator);499 var list = std.ArrayList(SeeAlsoItem).init(allocator);
...@@ -502,15 +502,15 @@ fn genToc(allocator: Allocator, tokenizer: *Tokenizer) !Toc {...@@ -502,15 +502,15 @@ fn genToc(allocator: Allocator, tokenizer: *Tokenizer) !Toc {
502 while (true) {502 while (true) {
503 const see_also_tok = tokenizer.next();503 const see_also_tok = tokenizer.next();
504 switch (see_also_tok.id) {504 switch (see_also_tok.id) {
505 Token.Id.TagContent => {505 .tag_content => {
506 const content = tokenizer.buffer[see_also_tok.start..see_also_tok.end];506 const content = tokenizer.buffer[see_also_tok.start..see_also_tok.end];
507 try list.append(SeeAlsoItem{507 try list.append(SeeAlsoItem{
508 .name = content,508 .name = content,
509 .token = see_also_tok,509 .token = see_also_tok,
510 });510 });
511 },511 },
512 Token.Id.Separator => {},512 .separator => {},
513 Token.Id.BracketClose => {513 .bracket_close => {
514 try nodes.append(Node{ .SeeAlso = try list.toOwnedSlice() });514 try nodes.append(Node{ .SeeAlso = try list.toOwnedSlice() });
515 break;515 break;
516 },516 },
...@@ -518,17 +518,17 @@ fn genToc(allocator: Allocator, tokenizer: *Tokenizer) !Toc {...@@ -518,17 +518,17 @@ fn genToc(allocator: Allocator, tokenizer: *Tokenizer) !Toc {
518 }518 }
519 }519 }
520 } else if (mem.eql(u8, tag_name, "link")) {520 } else if (mem.eql(u8, tag_name, "link")) {
521 _ = try eatToken(tokenizer, Token.Id.Separator);521 _ = try eatToken(tokenizer, .separator);
522 const name_tok = try eatToken(tokenizer, Token.Id.TagContent);522 const name_tok = try eatToken(tokenizer, .tag_content);
523 const name = tokenizer.buffer[name_tok.start..name_tok.end];523 const name = tokenizer.buffer[name_tok.start..name_tok.end];
524524
525 const url_name = blk: {525 const url_name = blk: {
526 const tok = tokenizer.next();526 const tok = tokenizer.next();
527 switch (tok.id) {527 switch (tok.id) {
528 Token.Id.BracketClose => break :blk name,528 .bracket_close => break :blk name,
529 Token.Id.Separator => {529 .separator => {
530 const explicit_text = try eatToken(tokenizer, Token.Id.TagContent);530 const explicit_text = try eatToken(tokenizer, .tag_content);
531 _ = try eatToken(tokenizer, Token.Id.BracketClose);531 _ = try eatToken(tokenizer, .bracket_close);
532 break :blk tokenizer.buffer[explicit_text.start..explicit_text.end];532 break :blk tokenizer.buffer[explicit_text.start..explicit_text.end];
533 },533 },
534 else => return parseError(tokenizer, tok, "invalid link token", .{}),534 else => return parseError(tokenizer, tok, "invalid link token", .{}),
...@@ -543,45 +543,45 @@ fn genToc(allocator: Allocator, tokenizer: *Tokenizer) !Toc {...@@ -543,45 +543,45 @@ fn genToc(allocator: Allocator, tokenizer: *Tokenizer) !Toc {
543 },543 },
544 });544 });
545 } else if (mem.eql(u8, tag_name, "code_begin")) {545 } else if (mem.eql(u8, tag_name, "code_begin")) {
546 _ = try eatToken(tokenizer, Token.Id.Separator);546 _ = try eatToken(tokenizer, .separator);
547 const code_kind_tok = try eatToken(tokenizer, Token.Id.TagContent);547 const code_kind_tok = try eatToken(tokenizer, .tag_content);
548 _ = try eatToken(tokenizer, Token.Id.Separator);548 _ = try eatToken(tokenizer, .separator);
549 const name_tok = try eatToken(tokenizer, Token.Id.TagContent);549 const name_tok = try eatToken(tokenizer, .tag_content);
550 const name = tokenizer.buffer[name_tok.start..name_tok.end];550 const name = tokenizer.buffer[name_tok.start..name_tok.end];
551 var error_str: []const u8 = "";551 var error_str: []const u8 = "";
552 const maybe_sep = tokenizer.next();552 const maybe_sep = tokenizer.next();
553 switch (maybe_sep.id) {553 switch (maybe_sep.id) {
554 Token.Id.Separator => {554 .separator => {
555 const error_tok = try eatToken(tokenizer, Token.Id.TagContent);555 const error_tok = try eatToken(tokenizer, .tag_content);
556 error_str = tokenizer.buffer[error_tok.start..error_tok.end];556 error_str = tokenizer.buffer[error_tok.start..error_tok.end];
557 _ = try eatToken(tokenizer, Token.Id.BracketClose);557 _ = try eatToken(tokenizer, .bracket_close);
558 },558 },
559 Token.Id.BracketClose => {},559 .bracket_close => {},
560 else => return parseError(tokenizer, token, "invalid token", .{}),560 else => return parseError(tokenizer, token, "invalid token", .{}),
561 }561 }
562 const code_kind_str = tokenizer.buffer[code_kind_tok.start..code_kind_tok.end];562 const code_kind_str = tokenizer.buffer[code_kind_tok.start..code_kind_tok.end];
563 var code_kind_id: Code.Id = undefined;563 var code_kind_id: Code.Id = undefined;
564 var just_check_syntax = false;564 var just_check_syntax = false;
565 if (mem.eql(u8, code_kind_str, "exe")) {565 if (mem.eql(u8, code_kind_str, "exe")) {
566 code_kind_id = Code.Id{ .Exe = ExpectedOutcome.Succeed };566 code_kind_id = Code.Id{ .exe = .succeed };
567 } else if (mem.eql(u8, code_kind_str, "exe_err")) {567 } else if (mem.eql(u8, code_kind_str, "exe_err")) {
568 code_kind_id = Code.Id{ .Exe = ExpectedOutcome.Fail };568 code_kind_id = Code.Id{ .exe = .fail };
569 } else if (mem.eql(u8, code_kind_str, "exe_build_err")) {569 } else if (mem.eql(u8, code_kind_str, "exe_build_err")) {
570 code_kind_id = Code.Id{ .Exe = ExpectedOutcome.BuildFail };570 code_kind_id = Code.Id{ .exe = .build_fail };
571 } else if (mem.eql(u8, code_kind_str, "test")) {571 } else if (mem.eql(u8, code_kind_str, "test")) {
572 code_kind_id = Code.Id.Test;572 code_kind_id = .@"test";
573 } else if (mem.eql(u8, code_kind_str, "test_err")) {573 } else if (mem.eql(u8, code_kind_str, "test_err")) {
574 code_kind_id = Code.Id{ .TestError = error_str };574 code_kind_id = Code.Id{ .test_error = error_str };
575 } else if (mem.eql(u8, code_kind_str, "test_safety")) {575 } else if (mem.eql(u8, code_kind_str, "test_safety")) {
576 code_kind_id = Code.Id{ .TestSafety = error_str };576 code_kind_id = Code.Id{ .test_safety = error_str };
577 } else if (mem.eql(u8, code_kind_str, "obj")) {577 } else if (mem.eql(u8, code_kind_str, "obj")) {
578 code_kind_id = Code.Id{ .Obj = null };578 code_kind_id = Code.Id{ .obj = null };
579 } else if (mem.eql(u8, code_kind_str, "obj_err")) {579 } else if (mem.eql(u8, code_kind_str, "obj_err")) {
580 code_kind_id = Code.Id{ .Obj = error_str };580 code_kind_id = Code.Id{ .obj = error_str };
581 } else if (mem.eql(u8, code_kind_str, "lib")) {581 } else if (mem.eql(u8, code_kind_str, "lib")) {
582 code_kind_id = Code.Id.Lib;582 code_kind_id = Code.Id.lib;
583 } else if (mem.eql(u8, code_kind_str, "syntax")) {583 } else if (mem.eql(u8, code_kind_str, "syntax")) {
584 code_kind_id = Code.Id{ .Obj = null };584 code_kind_id = Code.Id{ .obj = null };
585 just_check_syntax = true;585 just_check_syntax = true;
586 } else {586 } else {
587 return parseError(tokenizer, code_kind_tok, "unrecognized code kind: {s}", .{code_kind_str});587 return parseError(tokenizer, code_kind_tok, "unrecognized code kind: {s}", .{code_kind_str});
...@@ -599,9 +599,9 @@ fn genToc(allocator: Allocator, tokenizer: *Tokenizer) !Toc {...@@ -599,9 +599,9 @@ fn genToc(allocator: Allocator, tokenizer: *Tokenizer) !Toc {
599 defer additional_options.deinit();599 defer additional_options.deinit();
600600
601 const source_token = while (true) {601 const source_token = while (true) {
602 const content_tok = try eatToken(tokenizer, Token.Id.Content);602 const content_tok = try eatToken(tokenizer, .content);
603 _ = try eatToken(tokenizer, Token.Id.BracketOpen);603 _ = try eatToken(tokenizer, .bracket_open);
604 const end_code_tag = try eatToken(tokenizer, Token.Id.TagContent);604 const end_code_tag = try eatToken(tokenizer, .tag_content);
605 const end_tag_name = tokenizer.buffer[end_code_tag.start..end_code_tag.end];605 const end_tag_name = tokenizer.buffer[end_code_tag.start..end_code_tag.end];
606 if (mem.eql(u8, end_tag_name, "code_release_fast")) {606 if (mem.eql(u8, end_tag_name, "code_release_fast")) {
607 mode = .ReleaseFast;607 mode = .ReleaseFast;
...@@ -612,8 +612,8 @@ fn genToc(allocator: Allocator, tokenizer: *Tokenizer) !Toc {...@@ -612,8 +612,8 @@ fn genToc(allocator: Allocator, tokenizer: *Tokenizer) !Toc {
612 } else if (mem.eql(u8, end_tag_name, "code_verbose_cimport")) {612 } else if (mem.eql(u8, end_tag_name, "code_verbose_cimport")) {
613 verbose_cimport = true;613 verbose_cimport = true;
614 } else if (mem.eql(u8, end_tag_name, "code_link_object")) {614 } else if (mem.eql(u8, end_tag_name, "code_link_object")) {
615 _ = try eatToken(tokenizer, Token.Id.Separator);615 _ = try eatToken(tokenizer, .separator);
616 const obj_tok = try eatToken(tokenizer, Token.Id.TagContent);616 const obj_tok = try eatToken(tokenizer, .tag_content);
617 try link_objects.append(tokenizer.buffer[obj_tok.start..obj_tok.end]);617 try link_objects.append(tokenizer.buffer[obj_tok.start..obj_tok.end]);
618 } else if (mem.eql(u8, end_tag_name, "target_windows")) {618 } else if (mem.eql(u8, end_tag_name, "target_windows")) {
619 target_str = "x86_64-windows";619 target_str = "x86_64-windows";
...@@ -630,11 +630,11 @@ fn genToc(allocator: Allocator, tokenizer: *Tokenizer) !Toc {...@@ -630,11 +630,11 @@ fn genToc(allocator: Allocator, tokenizer: *Tokenizer) !Toc {
630 } else if (mem.eql(u8, end_tag_name, "link_mode_dynamic")) {630 } else if (mem.eql(u8, end_tag_name, "link_mode_dynamic")) {
631 link_mode = .Dynamic;631 link_mode = .Dynamic;
632 } else if (mem.eql(u8, end_tag_name, "additonal_option")) {632 } else if (mem.eql(u8, end_tag_name, "additonal_option")) {
633 _ = try eatToken(tokenizer, Token.Id.Separator);633 _ = try eatToken(tokenizer, .separator);
634 const option = try eatToken(tokenizer, Token.Id.TagContent);634 const option = try eatToken(tokenizer, .tag_content);
635 try additional_options.append(tokenizer.buffer[option.start..option.end]);635 try additional_options.append(tokenizer.buffer[option.start..option.end]);
636 } else if (mem.eql(u8, end_tag_name, "code_end")) {636 } else if (mem.eql(u8, end_tag_name, "code_end")) {
637 _ = try eatToken(tokenizer, Token.Id.BracketClose);637 _ = try eatToken(tokenizer, .bracket_close);
638 break content_tok;638 break content_tok;
639 } else {639 } else {
640 return parseError(640 return parseError(
...@@ -644,7 +644,7 @@ fn genToc(allocator: Allocator, tokenizer: *Tokenizer) !Toc {...@@ -644,7 +644,7 @@ fn genToc(allocator: Allocator, tokenizer: *Tokenizer) !Toc {
644 .{end_tag_name},644 .{end_tag_name},
645 );645 );
646 }646 }
647 _ = try eatToken(tokenizer, Token.Id.BracketClose);647 _ = try eatToken(tokenizer, .bracket_close);
648 } else unreachable; // TODO issue #707648 } else unreachable; // TODO issue #707
649 try nodes.append(Node{649 try nodes.append(Node{
650 .Code = Code{650 .Code = Code{
...@@ -664,10 +664,10 @@ fn genToc(allocator: Allocator, tokenizer: *Tokenizer) !Toc {...@@ -664,10 +664,10 @@ fn genToc(allocator: Allocator, tokenizer: *Tokenizer) !Toc {
664 });664 });
665 tokenizer.code_node_count += 1;665 tokenizer.code_node_count += 1;
666 } else if (mem.eql(u8, tag_name, "syntax")) {666 } else if (mem.eql(u8, tag_name, "syntax")) {
667 _ = try eatToken(tokenizer, Token.Id.BracketClose);667 _ = try eatToken(tokenizer, .bracket_close);
668 const content_tok = try eatToken(tokenizer, Token.Id.Content);668 const content_tok = try eatToken(tokenizer, .content);
669 _ = try eatToken(tokenizer, Token.Id.BracketOpen);669 _ = try eatToken(tokenizer, .bracket_open);
670 const end_syntax_tag = try eatToken(tokenizer, Token.Id.TagContent);670 const end_syntax_tag = try eatToken(tokenizer, .tag_content);
671 const end_tag_name = tokenizer.buffer[end_syntax_tag.start..end_syntax_tag.end];671 const end_tag_name = tokenizer.buffer[end_syntax_tag.start..end_syntax_tag.end];
672 if (!mem.eql(u8, end_tag_name, "endsyntax")) {672 if (!mem.eql(u8, end_tag_name, "endsyntax")) {
673 return parseError(673 return parseError(
...@@ -677,13 +677,13 @@ fn genToc(allocator: Allocator, tokenizer: *Tokenizer) !Toc {...@@ -677,13 +677,13 @@ fn genToc(allocator: Allocator, tokenizer: *Tokenizer) !Toc {
677 .{end_tag_name},677 .{end_tag_name},
678 );678 );
679 }679 }
680 _ = try eatToken(tokenizer, Token.Id.BracketClose);680 _ = try eatToken(tokenizer, .bracket_close);
681 try nodes.append(Node{ .InlineSyntax = content_tok });681 try nodes.append(Node{ .InlineSyntax = content_tok });
682 } else if (mem.eql(u8, tag_name, "shell_samp")) {682 } else if (mem.eql(u8, tag_name, "shell_samp")) {
683 _ = try eatToken(tokenizer, Token.Id.BracketClose);683 _ = try eatToken(tokenizer, .bracket_close);
684 const content_tok = try eatToken(tokenizer, Token.Id.Content);684 const content_tok = try eatToken(tokenizer, .content);
685 _ = try eatToken(tokenizer, Token.Id.BracketOpen);685 _ = try eatToken(tokenizer, .bracket_open);
686 const end_syntax_tag = try eatToken(tokenizer, Token.Id.TagContent);686 const end_syntax_tag = try eatToken(tokenizer, .tag_content);
687 const end_tag_name = tokenizer.buffer[end_syntax_tag.start..end_syntax_tag.end];687 const end_tag_name = tokenizer.buffer[end_syntax_tag.start..end_syntax_tag.end];
688 if (!mem.eql(u8, end_tag_name, "end_shell_samp")) {688 if (!mem.eql(u8, end_tag_name, "end_shell_samp")) {
689 return parseError(689 return parseError(
...@@ -693,20 +693,20 @@ fn genToc(allocator: Allocator, tokenizer: *Tokenizer) !Toc {...@@ -693,20 +693,20 @@ fn genToc(allocator: Allocator, tokenizer: *Tokenizer) !Toc {
693 .{end_tag_name},693 .{end_tag_name},
694 );694 );
695 }695 }
696 _ = try eatToken(tokenizer, Token.Id.BracketClose);696 _ = try eatToken(tokenizer, .bracket_close);
697 try nodes.append(Node{ .Shell = content_tok });697 try nodes.append(Node{ .Shell = content_tok });
698 } else if (mem.eql(u8, tag_name, "syntax_block")) {698 } else if (mem.eql(u8, tag_name, "syntax_block")) {
699 _ = try eatToken(tokenizer, Token.Id.Separator);699 _ = try eatToken(tokenizer, .separator);
700 const source_type_tok = try eatToken(tokenizer, Token.Id.TagContent);700 const source_type_tok = try eatToken(tokenizer, .tag_content);
701 var name: []const u8 = "sample_code";701 var name: []const u8 = "sample_code";
702 const maybe_sep = tokenizer.next();702 const maybe_sep = tokenizer.next();
703 switch (maybe_sep.id) {703 switch (maybe_sep.id) {
704 Token.Id.Separator => {704 .separator => {
705 const name_tok = try eatToken(tokenizer, Token.Id.TagContent);705 const name_tok = try eatToken(tokenizer, .tag_content);
706 name = tokenizer.buffer[name_tok.start..name_tok.end];706 name = tokenizer.buffer[name_tok.start..name_tok.end];
707 _ = try eatToken(tokenizer, Token.Id.BracketClose);707 _ = try eatToken(tokenizer, .bracket_close);
708 },708 },
709 Token.Id.BracketClose => {},709 .bracket_close => {},
710 else => return parseError(tokenizer, token, "invalid token", .{}),710 else => return parseError(tokenizer, token, "invalid token", .{}),
711 }711 }
712 const source_type_str = tokenizer.buffer[source_type_tok.start..source_type_tok.end];712 const source_type_str = tokenizer.buffer[source_type_tok.start..source_type_tok.end];
...@@ -723,12 +723,12 @@ fn genToc(allocator: Allocator, tokenizer: *Tokenizer) !Toc {...@@ -723,12 +723,12 @@ fn genToc(allocator: Allocator, tokenizer: *Tokenizer) !Toc {
723 return parseError(tokenizer, source_type_tok, "unrecognized code kind: {s}", .{source_type_str});723 return parseError(tokenizer, source_type_tok, "unrecognized code kind: {s}", .{source_type_str});
724 }724 }
725 const source_token = while (true) {725 const source_token = while (true) {
726 const content_tok = try eatToken(tokenizer, Token.Id.Content);726 const content_tok = try eatToken(tokenizer, .content);
727 _ = try eatToken(tokenizer, Token.Id.BracketOpen);727 _ = try eatToken(tokenizer, .bracket_open);
728 const end_code_tag = try eatToken(tokenizer, Token.Id.TagContent);728 const end_code_tag = try eatToken(tokenizer, .tag_content);
729 const end_tag_name = tokenizer.buffer[end_code_tag.start..end_code_tag.end];729 const end_tag_name = tokenizer.buffer[end_code_tag.start..end_code_tag.end];
730 if (mem.eql(u8, end_tag_name, "end_syntax_block")) {730 if (mem.eql(u8, end_tag_name, "end_syntax_block")) {
731 _ = try eatToken(tokenizer, Token.Id.BracketClose);731 _ = try eatToken(tokenizer, .bracket_close);
732 break content_tok;732 break content_tok;
733 } else {733 } else {
734 return parseError(734 return parseError(
...@@ -738,7 +738,7 @@ fn genToc(allocator: Allocator, tokenizer: *Tokenizer) !Toc {...@@ -738,7 +738,7 @@ fn genToc(allocator: Allocator, tokenizer: *Tokenizer) !Toc {
738 .{end_tag_name},738 .{end_tag_name},
739 );739 );
740 }740 }
741 _ = try eatToken(tokenizer, Token.Id.BracketClose);741 _ = try eatToken(tokenizer, .bracket_close);
742 };742 };
743 try nodes.append(Node{ .SyntaxBlock = SyntaxBlock{ .source_type = source_type, .name = name, .source_token = source_token } });743 try nodes.append(Node{ .SyntaxBlock = SyntaxBlock{ .source_type = source_type, .name = name, .source_token = source_token } });
744 } else {744 } else {
...@@ -1371,7 +1371,7 @@ fn genHtml(...@@ -1371,7 +1371,7 @@ fn genHtml(
1371 var shell_out = shell_buffer.writer();1371 var shell_out = shell_buffer.writer();
13721372
1373 switch (code.id) {1373 switch (code.id) {
1374 Code.Id.Exe => |expected_outcome| code_block: {1374 .exe => |expected_outcome| code_block: {
1375 var build_args = std.ArrayList([]const u8).init(allocator);1375 var build_args = std.ArrayList([]const u8).init(allocator);
1376 defer build_args.deinit();1376 defer build_args.deinit();
1377 try build_args.appendSlice(&[_][]const u8{1377 try build_args.appendSlice(&[_][]const u8{
...@@ -1420,7 +1420,7 @@ fn genHtml(...@@ -1420,7 +1420,7 @@ fn genHtml(
14201420
1421 try shell_out.print("\n", .{});1421 try shell_out.print("\n", .{});
14221422
1423 if (expected_outcome == .BuildFail) {1423 if (expected_outcome == .build_fail) {
1424 const result = try ChildProcess.exec(.{1424 const result = try ChildProcess.exec(.{
1425 .allocator = allocator,1425 .allocator = allocator,
1426 .argv = build_args.items,1426 .argv = build_args.items,
...@@ -1476,7 +1476,7 @@ fn genHtml(...@@ -1476,7 +1476,7 @@ fn genHtml(
14761476
1477 var exited_with_signal = false;1477 var exited_with_signal = false;
14781478
1479 const result = if (expected_outcome == ExpectedOutcome.Fail) blk: {1479 const result = if (expected_outcome == .fail) blk: {
1480 const result = try ChildProcess.exec(.{1480 const result = try ChildProcess.exec(.{
1481 .allocator = allocator,1481 .allocator = allocator,
1482 .argv = run_args,1482 .argv = run_args,
...@@ -1513,7 +1513,7 @@ fn genHtml(...@@ -1513,7 +1513,7 @@ fn genHtml(
1513 }1513 }
1514 try shell_out.writeAll("\n");1514 try shell_out.writeAll("\n");
1515 },1515 },
1516 Code.Id.Test => {1516 .@"test" => {
1517 var test_args = std.ArrayList([]const u8).init(allocator);1517 var test_args = std.ArrayList([]const u8).init(allocator);
1518 defer test_args.deinit();1518 defer test_args.deinit();
15191519
...@@ -1565,7 +1565,7 @@ fn genHtml(...@@ -1565,7 +1565,7 @@ fn genHtml(
1565 const escaped_stdout = try escapeHtml(allocator, result.stdout);1565 const escaped_stdout = try escapeHtml(allocator, result.stdout);
1566 try shell_out.print("\n{s}{s}\n", .{ escaped_stderr, escaped_stdout });1566 try shell_out.print("\n{s}{s}\n", .{ escaped_stderr, escaped_stdout });
1567 },1567 },
1568 Code.Id.TestError => |error_match| {1568 .test_error => |error_match| {
1569 var test_args = std.ArrayList([]const u8).init(allocator);1569 var test_args = std.ArrayList([]const u8).init(allocator);
1570 defer test_args.deinit();1570 defer test_args.deinit();
15711571
...@@ -1621,8 +1621,7 @@ fn genHtml(...@@ -1621,8 +1621,7 @@ fn genHtml(
1621 const colored_stderr = try termColor(allocator, escaped_stderr);1621 const colored_stderr = try termColor(allocator, escaped_stderr);
1622 try shell_out.print("\n{s}\n", .{colored_stderr});1622 try shell_out.print("\n{s}\n", .{colored_stderr});
1623 },1623 },
16241624 .test_safety => |error_match| {
1625 Code.Id.TestSafety => |error_match| {
1626 var test_args = std.ArrayList([]const u8).init(allocator);1625 var test_args = std.ArrayList([]const u8).init(allocator);
1627 defer test_args.deinit();1626 defer test_args.deinit();
16281627
...@@ -1685,7 +1684,7 @@ fn genHtml(...@@ -1685,7 +1684,7 @@ fn genHtml(
1685 colored_stderr,1684 colored_stderr,
1686 });1685 });
1687 },1686 },
1688 Code.Id.Obj => |maybe_error_match| {1687 .obj => |maybe_error_match| {
1689 const name_plus_obj_ext = try std.fmt.allocPrint(allocator, "{s}{s}", .{ code.name, obj_ext });1688 const name_plus_obj_ext = try std.fmt.allocPrint(allocator, "{s}{s}", .{ code.name, obj_ext });
1690 var build_args = std.ArrayList([]const u8).init(allocator);1689 var build_args = std.ArrayList([]const u8).init(allocator);
1691 defer build_args.deinit();1690 defer build_args.deinit();
...@@ -1758,7 +1757,7 @@ fn genHtml(...@@ -1758,7 +1757,7 @@ fn genHtml(
1758 }1757 }
1759 try shell_out.writeAll("\n");1758 try shell_out.writeAll("\n");
1760 },1759 },
1761 Code.Id.Lib => {1760 .lib => {
1762 const bin_basename = try std.zig.binNameAlloc(allocator, .{1761 const bin_basename = try std.zig.binNameAlloc(allocator, .{
1763 .root_name = code.name,1762 .root_name = code.name,
1764 .target = builtin.target,1763 .target = builtin.target,