| ... | ... | @@ -16,7 +16,7 @@ const Parser = struct { |
| 16 | 16 | pub fn parseRoot(p: *Parser) bool { |
| 17 | 17 | return blk_0: { |
| 18 | 18 | const pos_0 = p.i; |
| 19 | | if (p.parseContainerMembers() and p.parseskip() and p.parseeof()) break :blk_0 true; |
| 19 | if ((p.parseinitial_doc_comment() or true) and p.parseContainerMembers() and p.parseskip() and p.parseeof()) break :blk_0 true; |
| 20 | 20 | p.i = pos_0; |
| 21 | 21 | break :blk_0 false; |
| 22 | 22 | }; |
| ... | ... | @@ -2330,6 +2330,60 @@ const Parser = struct { |
| 2330 | 2330 | break :blk_0 false; |
| 2331 | 2331 | }; |
| 2332 | 2332 | } |
| 2333 | pub fn parseinitial_doc_comment(p: *Parser) bool { |
| 2334 | return blk_0: { |
| 2335 | const pos_0 = p.i; |
| 2336 | if (blk_1: { |
| 2337 | var match_1 = false; |
| 2338 | while (blk_3: { |
| 2339 | const pos_3 = p.i; |
| 2340 | if (p.parseskip() and blk_4: { |
| 2341 | if (std.mem.startsWith(u8, p.source[p.i..], "///")) { |
| 2342 | p.i += 3; |
| 2343 | break :blk_4 true; |
| 2344 | } |
| 2345 | break :blk_4 false; |
| 2346 | } and blk_4: { |
| 2347 | while (p.parsenon_control_utf8()) {} |
| 2348 | break :blk_4 true; |
| 2349 | } and p.parsenewline()) break :blk_3 true; |
| 2350 | p.i = pos_3; |
| 2351 | break :blk_3 false; |
| 2352 | }) { |
| 2353 | match_1 = true; |
| 2354 | } |
| 2355 | break :blk_1 match_1; |
| 2356 | } and p.parseskip() and blk_1: { |
| 2357 | const pos_1 = p.i; |
| 2358 | const match_1 = blk_2: { |
| 2359 | if (std.mem.startsWith(u8, p.source[p.i..], "//!")) { |
| 2360 | p.i += 3; |
| 2361 | break :blk_2 true; |
| 2362 | } |
| 2363 | break :blk_2 false; |
| 2364 | }; |
| 2365 | p.i = pos_1; |
| 2366 | break :blk_1 !match_1; |
| 2367 | } and blk_1: { |
| 2368 | const pos_1 = p.i; |
| 2369 | const match_1 = p.parseKEYWORD_test(); |
| 2370 | p.i = pos_1; |
| 2371 | break :blk_1 !match_1; |
| 2372 | } and blk_1: { |
| 2373 | const pos_1 = p.i; |
| 2374 | const match_1 = p.parseKEYWORD_comptime(); |
| 2375 | p.i = pos_1; |
| 2376 | break :blk_1 !match_1; |
| 2377 | } and blk_1: { |
| 2378 | const pos_1 = p.i; |
| 2379 | const match_1 = p.parseeof(); |
| 2380 | p.i = pos_1; |
| 2381 | break :blk_1 !match_1; |
| 2382 | }) break :blk_0 true; |
| 2383 | p.i = pos_0; |
| 2384 | break :blk_0 false; |
| 2385 | }; |
| 2386 | } |
| 2333 | 2387 | pub fn parsecontainer_doc_comment(p: *Parser) bool { |
| 2334 | 2388 | return blk_0: { |
| 2335 | 2389 | const pos_0 = p.i; |
| ... | ... | @@ -2361,7 +2415,7 @@ const Parser = struct { |
| 2361 | 2415 | pub fn parsedoc_comment(p: *Parser) bool { |
| 2362 | 2416 | return blk_0: { |
| 2363 | 2417 | const pos_0 = p.i; |
| 2364 | | if (blk_1: { |
| 2418 | if (p.parseskip_require_newline() and blk_1: { |
| 2365 | 2419 | var match_1 = false; |
| 2366 | 2420 | while (blk_3: { |
| 2367 | 2421 | const pos_3 = p.i; |
| ... | ... | @@ -2496,6 +2550,40 @@ const Parser = struct { |
| 2496 | 2550 | break :blk_0 false; |
| 2497 | 2551 | }; |
| 2498 | 2552 | } |
| 2553 | pub fn parseskip_require_newline(p: *Parser) bool { |
| 2554 | return blk_0: { |
| 2555 | const pos_0 = p.i; |
| 2556 | if (blk_1: { |
| 2557 | while ((p.i < p.source.len and switch (p.source[p.i]) { |
| 2558 | ' '...' ', |
| 2559 | '\t'...'\t', |
| 2560 | '\r'...'\r', |
| 2561 | => blk_2: { |
| 2562 | p.i += 1; |
| 2563 | break :blk_2 true; |
| 2564 | }, |
| 2565 | else => false, |
| 2566 | })) {} |
| 2567 | break :blk_1 true; |
| 2568 | } and blk_2: { |
| 2569 | const pos_2 = p.i; |
| 2570 | if ((p.i < p.source.len and switch (p.source[p.i]) { |
| 2571 | '\n'...'\n', |
| 2572 | => blk_3: { |
| 2573 | p.i += 1; |
| 2574 | break :blk_3 true; |
| 2575 | }, |
| 2576 | else => false, |
| 2577 | })) break :blk_2 true; |
| 2578 | p.i = pos_2; |
| 2579 | if (p.parseline_comment()) break :blk_2 true; |
| 2580 | p.i = pos_2; |
| 2581 | break :blk_2 false; |
| 2582 | } and p.parseskip()) break :blk_0 true; |
| 2583 | p.i = pos_0; |
| 2584 | break :blk_0 false; |
| 2585 | }; |
| 2586 | } |
| 2499 | 2587 | pub fn parsepre_op_white(p: *Parser) bool { |
| 2500 | 2588 | return blk_0: { |
| 2501 | 2589 | const pos_0 = p.i; |