| author | |
| committer | |
| log | e2289961c6b53451e5bdcdfb6eec27e27f6553ca |
| tree | 4752b2cf7df22896fb7289649f5b44b0a22b454e |
| parent | faa3fa65ac89b774b26bdd0ea4ac70861b29d0b4 |
| signature |
4 files changed, 1415 insertions(+), 1415 deletions(-)
lib/std/zig/ast.zig+56-56| ... | @@ -343,7 +343,7 @@ pub const Tree = struct { | ... | @@ -343,7 +343,7 @@ pub const Tree = struct { |
| 343 | .ContainerField, | 343 | .ContainerField, |
| 344 | => { | 344 | => { |
| 345 | const name_token = main_tokens[n]; | 345 | 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) { |
| 347 | end_offset += 1; | 347 | end_offset += 1; |
| 348 | } | 348 | } |
| 349 | return name_token - end_offset; | 349 | return name_token - end_offset; |
| ... | @@ -358,12 +358,12 @@ pub const Tree = struct { | ... | @@ -358,12 +358,12 @@ pub const Tree = struct { |
| 358 | while (i > 0) { | 358 | while (i > 0) { |
| 359 | i -= 1; | 359 | i -= 1; |
| 360 | switch (token_tags[i]) { | 360 | switch (token_tags[i]) { |
| 361 | .Keyword_extern, | 361 | .keyword_extern, |
| 362 | .Keyword_export, | 362 | .keyword_export, |
| 363 | .Keyword_comptime, | 363 | .keyword_comptime, |
| 364 | .Keyword_pub, | 364 | .keyword_pub, |
| 365 | .Keyword_threadlocal, | 365 | .keyword_threadlocal, |
| 366 | .StringLiteral, | 366 | .string_literal, |
| 367 | => continue, | 367 | => continue, |
| 368 | 368 | ||
| 369 | else => return i + 1 - end_offset, | 369 | else => return i + 1 - end_offset, |
| ... | @@ -379,7 +379,7 @@ pub const Tree = struct { | ... | @@ -379,7 +379,7 @@ pub const Tree = struct { |
| 379 | => { | 379 | => { |
| 380 | // Look for a label. | 380 | // Look for a label. |
| 381 | const lbrace = main_tokens[n]; | 381 | const lbrace = main_tokens[n]; |
| 382 | if (token_tags[lbrace - 1] == .Colon) { | 382 | if (token_tags[lbrace - 1] == .colon) { |
| 383 | end_offset += 2; | 383 | end_offset += 2; |
| 384 | } | 384 | } |
| 385 | return lbrace - end_offset; | 385 | return lbrace - end_offset; |
| ... | @@ -400,7 +400,7 @@ pub const Tree = struct { | ... | @@ -400,7 +400,7 @@ pub const Tree = struct { |
| 400 | => { | 400 | => { |
| 401 | const main_token = main_tokens[n]; | 401 | const main_token = main_tokens[n]; |
| 402 | switch (token_tags[main_token - 1]) { | 402 | switch (token_tags[main_token - 1]) { |
| 403 | .Keyword_packed, .Keyword_extern => end_offset += 1, | 403 | .keyword_packed, .keyword_extern => end_offset += 1, |
| 404 | else => {}, | 404 | else => {}, |
| 405 | } | 405 | } |
| 406 | return main_token - end_offset; | 406 | return main_token - end_offset; |
| ... | @@ -413,13 +413,13 @@ pub const Tree = struct { | ... | @@ -413,13 +413,13 @@ pub const Tree = struct { |
| 413 | => { | 413 | => { |
| 414 | const main_token = main_tokens[n]; | 414 | const main_token = main_tokens[n]; |
| 415 | return switch (token_tags[main_token]) { | 415 | return switch (token_tags[main_token]) { |
| 416 | .Asterisk, | 416 | .asterisk, |
| 417 | .AsteriskAsterisk, | 417 | .asterisk_asterisk, |
| 418 | => switch (token_tags[main_token - 1]) { | 418 | => switch (token_tags[main_token - 1]) { |
| 419 | .LBracket => main_token - 1, | 419 | .l_bracket => main_token - 1, |
| 420 | else => main_token, | 420 | else => main_token, |
| 421 | }, | 421 | }, |
| 422 | .LBracket => main_token, | 422 | .l_bracket => main_token, |
| 423 | else => unreachable, | 423 | else => unreachable, |
| 424 | } - end_offset; | 424 | } - end_offset; |
| 425 | }, | 425 | }, |
| ... | @@ -438,7 +438,7 @@ pub const Tree = struct { | ... | @@ -438,7 +438,7 @@ pub const Tree = struct { |
| 438 | }, | 438 | }, |
| 439 | 439 | ||
| 440 | .AsmOutput, .AsmInput => { | 440 | .AsmOutput, .AsmInput => { |
| 441 | assert(token_tags[main_tokens[n] - 1] == .LBracket); | 441 | assert(token_tags[main_tokens[n] - 1] == .l_bracket); |
| 442 | return main_tokens[n] - 1 - end_offset; | 442 | return main_tokens[n] - 1 - end_offset; |
| 443 | }, | 443 | }, |
| 444 | 444 | ||
| ... | @@ -450,7 +450,7 @@ pub const Tree = struct { | ... | @@ -450,7 +450,7 @@ pub const Tree = struct { |
| 450 | => { | 450 | => { |
| 451 | const main_token = main_tokens[n]; | 451 | const main_token = main_tokens[n]; |
| 452 | return switch (token_tags[main_token - 1]) { | 452 | return switch (token_tags[main_token - 1]) { |
| 453 | .Keyword_inline => main_token - 1, | 453 | .keyword_inline => main_token - 1, |
| 454 | else => main_token, | 454 | else => main_token, |
| 455 | } - end_offset; | 455 | } - end_offset; |
| 456 | }, | 456 | }, |
| ... | @@ -1599,11 +1599,11 @@ pub const Tree = struct { | ... | @@ -1599,11 +1599,11 @@ pub const Tree = struct { |
| 1599 | while (i > 0) { | 1599 | while (i > 0) { |
| 1600 | i -= 1; | 1600 | i -= 1; |
| 1601 | switch (token_tags[i]) { | 1601 | switch (token_tags[i]) { |
| 1602 | .Keyword_extern, .Keyword_export => result.extern_export_token = i, | 1602 | .keyword_extern, .keyword_export => result.extern_export_token = i, |
| 1603 | .Keyword_comptime => result.comptime_token = i, | 1603 | .keyword_comptime => result.comptime_token = i, |
| 1604 | .Keyword_pub => result.visib_token = i, | 1604 | .keyword_pub => result.visib_token = i, |
| 1605 | .Keyword_threadlocal => result.threadlocal_token = i, | 1605 | .keyword_threadlocal => result.threadlocal_token = i, |
| 1606 | .StringLiteral => result.lib_name = i, | 1606 | .string_literal => result.lib_name = i, |
| 1607 | else => break, | 1607 | else => break, |
| 1608 | } | 1608 | } |
| 1609 | } | 1609 | } |
| ... | @@ -1621,14 +1621,14 @@ pub const Tree = struct { | ... | @@ -1621,14 +1621,14 @@ pub const Tree = struct { |
| 1621 | // if (cond_expr) |x| | 1621 | // if (cond_expr) |x| |
| 1622 | // ^ ^ | 1622 | // ^ ^ |
| 1623 | const payload_pipe = tree.lastToken(info.cond_expr) + 2; | 1623 | const payload_pipe = tree.lastToken(info.cond_expr) + 2; |
| 1624 | if (token_tags[payload_pipe] == .Pipe) { | 1624 | if (token_tags[payload_pipe] == .pipe) { |
| 1625 | result.payload_token = payload_pipe + 1; | 1625 | result.payload_token = payload_pipe + 1; |
| 1626 | } | 1626 | } |
| 1627 | if (info.else_expr != 0) { | 1627 | if (info.else_expr != 0) { |
| 1628 | // then_expr else |x| | 1628 | // then_expr else |x| |
| 1629 | // ^ ^ | 1629 | // ^ ^ |
| 1630 | result.else_token = tree.lastToken(info.then_expr) + 1; | 1630 | 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) { |
| 1632 | result.error_token = result.else_token + 2; | 1632 | result.error_token = result.else_token + 2; |
| 1633 | } | 1633 | } |
| 1634 | } | 1634 | } |
| ... | @@ -1643,7 +1643,7 @@ pub const Tree = struct { | ... | @@ -1643,7 +1643,7 @@ pub const Tree = struct { |
| 1643 | }; | 1643 | }; |
| 1644 | // comptime name: type = init, | 1644 | // comptime name: type = init, |
| 1645 | // ^ | 1645 | // ^ |
| 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) { |
| 1647 | result.comptime_token = info.name_token - 1; | 1647 | result.comptime_token = info.name_token - 1; |
| 1648 | } | 1648 | } |
| 1649 | return result; | 1649 | return result; |
| ... | @@ -1671,17 +1671,17 @@ pub const Tree = struct { | ... | @@ -1671,17 +1671,17 @@ pub const Tree = struct { |
| 1671 | // literals in some places here | 1671 | // literals in some places here |
| 1672 | const Kind = full.PtrType.Kind; | 1672 | const Kind = full.PtrType.Kind; |
| 1673 | const kind: Kind = switch (token_tags[info.main_token]) { | 1673 | const kind: Kind = switch (token_tags[info.main_token]) { |
| 1674 | .Asterisk, | 1674 | .asterisk, |
| 1675 | .AsteriskAsterisk, | 1675 | .asterisk_asterisk, |
| 1676 | => switch (token_tags[info.main_token + 1]) { | 1676 | => switch (token_tags[info.main_token + 1]) { |
| 1677 | .RBracket => .many, | 1677 | .r_bracket => .many, |
| 1678 | .Colon => .sentinel, | 1678 | .colon => .sentinel, |
| 1679 | .Identifier => if (token_tags[info.main_token - 1] == .LBracket) Kind.c else .one, | 1679 | .identifier => if (token_tags[info.main_token - 1] == .l_bracket) Kind.c else .one, |
| 1680 | else => .one, | 1680 | else => .one, |
| 1681 | }, | 1681 | }, |
| 1682 | .LBracket => switch (token_tags[info.main_token + 1]) { | 1682 | .l_bracket => switch (token_tags[info.main_token + 1]) { |
| 1683 | .RBracket => Kind.slice, | 1683 | .r_bracket => Kind.slice, |
| 1684 | .Colon => .slice_sentinel, | 1684 | .colon => .slice_sentinel, |
| 1685 | else => unreachable, | 1685 | else => unreachable, |
| 1686 | }, | 1686 | }, |
| 1687 | else => unreachable, | 1687 | else => unreachable, |
| ... | @@ -1707,10 +1707,10 @@ pub const Tree = struct { | ... | @@ -1707,10 +1707,10 @@ pub const Tree = struct { |
| 1707 | const end = tree.firstToken(info.child_type); | 1707 | const end = tree.firstToken(info.child_type); |
| 1708 | while (i < end) : (i += 1) { | 1708 | while (i < end) : (i += 1) { |
| 1709 | switch (token_tags[i]) { | 1709 | switch (token_tags[i]) { |
| 1710 | .Keyword_allowzero => result.allowzero_token = i, | 1710 | .keyword_allowzero => result.allowzero_token = i, |
| 1711 | .Keyword_const => result.const_token = i, | 1711 | .keyword_const => result.const_token = i, |
| 1712 | .Keyword_volatile => result.volatile_token = i, | 1712 | .keyword_volatile => result.volatile_token = i, |
| 1713 | .Keyword_align => { | 1713 | .keyword_align => { |
| 1714 | assert(info.align_node != 0); | 1714 | assert(info.align_node != 0); |
| 1715 | if (info.bit_range_end != 0) { | 1715 | if (info.bit_range_end != 0) { |
| 1716 | assert(info.bit_range_start != 0); | 1716 | assert(info.bit_range_start != 0); |
| ... | @@ -1732,7 +1732,7 @@ pub const Tree = struct { | ... | @@ -1732,7 +1732,7 @@ pub const Tree = struct { |
| 1732 | .layout_token = null, | 1732 | .layout_token = null, |
| 1733 | }; | 1733 | }; |
| 1734 | switch (token_tags[info.main_token - 1]) { | 1734 | 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, |
| 1736 | else => {}, | 1736 | else => {}, |
| 1737 | } | 1737 | } |
| 1738 | return result; | 1738 | return result; |
| ... | @@ -1744,7 +1744,7 @@ pub const Tree = struct { | ... | @@ -1744,7 +1744,7 @@ pub const Tree = struct { |
| 1744 | .ast = info, | 1744 | .ast = info, |
| 1745 | .payload_token = null, | 1745 | .payload_token = null, |
| 1746 | }; | 1746 | }; |
| 1747 | if (token_tags[info.arrow_token + 1] == .Pipe) { | 1747 | if (token_tags[info.arrow_token + 1] == .pipe) { |
| 1748 | result.payload_token = info.arrow_token + 2; | 1748 | result.payload_token = info.arrow_token + 2; |
| 1749 | } | 1749 | } |
| 1750 | return result; | 1750 | return result; |
| ... | @@ -1760,7 +1760,7 @@ pub const Tree = struct { | ... | @@ -1760,7 +1760,7 @@ pub const Tree = struct { |
| 1760 | .outputs = &.{}, | 1760 | .outputs = &.{}, |
| 1761 | .first_clobber = null, | 1761 | .first_clobber = null, |
| 1762 | }; | 1762 | }; |
| 1763 | if (token_tags[info.asm_token + 1] == .Keyword_volatile) { | 1763 | if (token_tags[info.asm_token + 1] == .keyword_volatile) { |
| 1764 | result.volatile_token = info.asm_token + 1; | 1764 | result.volatile_token = info.asm_token + 1; |
| 1765 | } | 1765 | } |
| 1766 | const outputs_end: usize = for (info.items) |item, i| { | 1766 | const outputs_end: usize = for (info.items) |item, i| { |
| ... | @@ -1776,10 +1776,10 @@ pub const Tree = struct { | ... | @@ -1776,10 +1776,10 @@ pub const Tree = struct { |
| 1776 | if (info.items.len == 0) { | 1776 | if (info.items.len == 0) { |
| 1777 | // asm ("foo" ::: "a", "b"); | 1777 | // asm ("foo" ::: "a", "b"); |
| 1778 | const template_token = tree.lastToken(info.template); | 1778 | const template_token = tree.lastToken(info.template); |
| 1779 | if (token_tags[template_token + 1] == .Colon and | 1779 | if (token_tags[template_token + 1] == .colon and |
| 1780 | token_tags[template_token + 2] == .Colon and | 1780 | token_tags[template_token + 2] == .colon and |
| 1781 | token_tags[template_token + 3] == .Colon and | 1781 | token_tags[template_token + 3] == .colon and |
| 1782 | token_tags[template_token + 4] == .StringLiteral) | 1782 | token_tags[template_token + 4] == .string_literal) |
| 1783 | { | 1783 | { |
| 1784 | result.first_clobber = template_token + 4; | 1784 | result.first_clobber = template_token + 4; |
| 1785 | } | 1785 | } |
| ... | @@ -1787,8 +1787,8 @@ pub const Tree = struct { | ... | @@ -1787,8 +1787,8 @@ pub const Tree = struct { |
| 1787 | // asm ("foo" :: [_] "" (y) : "a", "b"); | 1787 | // asm ("foo" :: [_] "" (y) : "a", "b"); |
| 1788 | const last_input = result.inputs[result.inputs.len - 1]; | 1788 | const last_input = result.inputs[result.inputs.len - 1]; |
| 1789 | const rparen = tree.lastToken(last_input); | 1789 | const rparen = tree.lastToken(last_input); |
| 1790 | if (token_tags[rparen + 1] == .Colon and | 1790 | if (token_tags[rparen + 1] == .colon and |
| 1791 | token_tags[rparen + 2] == .StringLiteral) | 1791 | token_tags[rparen + 2] == .string_literal) |
| 1792 | { | 1792 | { |
| 1793 | result.first_clobber = rparen + 2; | 1793 | result.first_clobber = rparen + 2; |
| 1794 | } | 1794 | } |
| ... | @@ -1796,9 +1796,9 @@ pub const Tree = struct { | ... | @@ -1796,9 +1796,9 @@ pub const Tree = struct { |
| 1796 | // asm ("foo" : [_] "" (x) :: "a", "b"); | 1796 | // asm ("foo" : [_] "" (x) :: "a", "b"); |
| 1797 | const last_output = result.outputs[result.outputs.len - 1]; | 1797 | const last_output = result.outputs[result.outputs.len - 1]; |
| 1798 | const rparen = tree.lastToken(last_output); | 1798 | const rparen = tree.lastToken(last_output); |
| 1799 | if (token_tags[rparen + 1] == .Colon and | 1799 | if (token_tags[rparen + 1] == .colon and |
| 1800 | token_tags[rparen + 2] == .Colon and | 1800 | token_tags[rparen + 2] == .colon and |
| 1801 | token_tags[rparen + 3] == .StringLiteral) | 1801 | token_tags[rparen + 3] == .string_literal) |
| 1802 | { | 1802 | { |
| 1803 | result.first_clobber = rparen + 3; | 1803 | result.first_clobber = rparen + 3; |
| 1804 | } | 1804 | } |
| ... | @@ -1818,24 +1818,24 @@ pub const Tree = struct { | ... | @@ -1818,24 +1818,24 @@ pub const Tree = struct { |
| 1818 | .error_token = null, | 1818 | .error_token = null, |
| 1819 | }; | 1819 | }; |
| 1820 | var tok_i = info.while_token - 1; | 1820 | var tok_i = info.while_token - 1; |
| 1821 | if (token_tags[tok_i] == .Keyword_inline) { | 1821 | if (token_tags[tok_i] == .keyword_inline) { |
| 1822 | result.inline_token = tok_i; | 1822 | result.inline_token = tok_i; |
| 1823 | tok_i -= 1; | 1823 | tok_i -= 1; |
| 1824 | } | 1824 | } |
| 1825 | if (token_tags[tok_i] == .Colon and | 1825 | if (token_tags[tok_i] == .colon and |
| 1826 | token_tags[tok_i - 1] == .Identifier) | 1826 | token_tags[tok_i - 1] == .identifier) |
| 1827 | { | 1827 | { |
| 1828 | result.label_token = tok_i - 1; | 1828 | result.label_token = tok_i - 1; |
| 1829 | } | 1829 | } |
| 1830 | const last_cond_token = tree.lastToken(info.cond_expr); | 1830 | 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) { |
| 1832 | result.payload_token = last_cond_token + 3; | 1832 | result.payload_token = last_cond_token + 3; |
| 1833 | } | 1833 | } |
| 1834 | if (info.else_expr != 0) { | 1834 | if (info.else_expr != 0) { |
| 1835 | // then_expr else |x| | 1835 | // then_expr else |x| |
| 1836 | // ^ ^ | 1836 | // ^ ^ |
| 1837 | result.else_token = tree.lastToken(info.then_expr) + 1; | 1837 | 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) { |
| 1839 | result.error_token = result.else_token + 2; | 1839 | result.error_token = result.else_token + 2; |
| 1840 | } | 1840 | } |
| 1841 | } | 1841 | } |
| ... | @@ -1849,7 +1849,7 @@ pub const Tree = struct { | ... | @@ -1849,7 +1849,7 @@ pub const Tree = struct { |
| 1849 | .async_token = null, | 1849 | .async_token = null, |
| 1850 | }; | 1850 | }; |
| 1851 | const maybe_async_token = tree.firstToken(info.fn_expr) - 1; | 1851 | 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) { |
| 1853 | result.async_token = maybe_async_token; | 1853 | result.async_token = maybe_async_token; |
| 1854 | } | 1854 | } |
| 1855 | return result; | 1855 | return result; |
| ... | @@ -2120,7 +2120,7 @@ pub const Error = union(enum) { | ... | @@ -2120,7 +2120,7 @@ pub const Error = union(enum) { |
| 2120 | pub const ExpectedVarDecl = SingleTokenError("Expected variable declaration, found '{s}'"); | 2120 | pub const ExpectedVarDecl = SingleTokenError("Expected variable declaration, found '{s}'"); |
| 2121 | pub const ExpectedFn = SingleTokenError("Expected function, found '{s}'"); | 2121 | pub const ExpectedFn = SingleTokenError("Expected function, found '{s}'"); |
| 2122 | pub const ExpectedReturnType = SingleTokenError("Expected return type expression, found '{s}'"); | 2122 | 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}'"); |
| 2124 | pub const ExpectedEqOrSemi = SingleTokenError("Expected '=' or ';', found '{s}'"); | 2124 | pub const ExpectedEqOrSemi = SingleTokenError("Expected '=' or ';', found '{s}'"); |
| 2125 | pub const ExpectedSemiOrLBrace = SingleTokenError("Expected ';' or '{{', found '{s}'"); | 2125 | pub const ExpectedSemiOrLBrace = SingleTokenError("Expected ';' or '{{', found '{s}'"); |
| 2126 | pub const ExpectedSemiOrElse = SingleTokenError("Expected ';' or 'else', found '{s}'"); | 2126 | pub const ExpectedSemiOrElse = SingleTokenError("Expected ';' or 'else', found '{s}'"); |
| ... | @@ -2129,7 +2129,7 @@ pub const Error = union(enum) { | ... | @@ -2129,7 +2129,7 @@ pub const Error = union(enum) { |
| 2129 | pub const ExpectedColonOrRParen = SingleTokenError("Expected ':' or ')', found '{s}'"); | 2129 | pub const ExpectedColonOrRParen = SingleTokenError("Expected ':' or ')', found '{s}'"); |
| 2130 | pub const ExpectedLabelable = SingleTokenError("Expected 'while', 'for', 'inline', 'suspend', or '{{', found '{s}'"); | 2130 | pub const ExpectedLabelable = SingleTokenError("Expected 'while', 'for', 'inline', 'suspend', or '{{', found '{s}'"); |
| 2131 | pub const ExpectedInlinable = SingleTokenError("Expected 'while' or 'for', found '{s}'"); | 2131 | 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}'"); |
| 2133 | pub const ExpectedSliceOrRBracket = SingleTokenError("Expected ']' or '..', found '{s}'"); | 2133 | pub const ExpectedSliceOrRBracket = SingleTokenError("Expected ']' or '..', found '{s}'"); |
| 2134 | pub const ExpectedTypeExpr = SingleTokenError("Expected type expression, found '{s}'"); | 2134 | pub const ExpectedTypeExpr = SingleTokenError("Expected type expression, found '{s}'"); |
| 2135 | pub const ExpectedPrimaryTypeExpr = SingleTokenError("Expected primary type expression, found '{s}'"); | 2135 | pub const ExpectedPrimaryTypeExpr = SingleTokenError("Expected primary type expression, found '{s}'"); |
| ... | @@ -2185,7 +2185,7 @@ pub const Error = union(enum) { | ... | @@ -2185,7 +2185,7 @@ pub const Error = union(enum) { |
| 2185 | pub fn render(self: *const ExpectedToken, tokens: []const Token.Tag, stream: anytype) !void { | 2185 | pub fn render(self: *const ExpectedToken, tokens: []const Token.Tag, stream: anytype) !void { |
| 2186 | const found_token = tokens[self.token]; | 2186 | const found_token = tokens[self.token]; |
| 2187 | switch (found_token) { | 2187 | switch (found_token) { |
| 2188 | .Invalid => { | 2188 | .invalid => { |
| 2189 | return stream.print("expected '{s}', found invalid bytes", .{self.expected_id.symbol()}); | 2189 | return stream.print("expected '{s}', found invalid bytes", .{self.expected_id.symbol()}); |
| 2190 | }, | 2190 | }, |
| 2191 | else => { | 2191 | else => { |
lib/std/zig/parse.zig+496-496| ... | @@ -32,7 +32,7 @@ pub fn parse(gpa: *Allocator, source: []const u8) Allocator.Error!Tree { | ... | @@ -32,7 +32,7 @@ pub fn parse(gpa: *Allocator, source: []const u8) Allocator.Error!Tree { |
| 32 | .tag = token.tag, | 32 | .tag = token.tag, |
| 33 | .start = @intCast(u32, token.loc.start), | 33 | .start = @intCast(u32, token.loc.start), |
| 34 | }); | 34 | }); |
| 35 | if (token.tag == .Eof) break; | 35 | if (token.tag == .eof) break; |
| 36 | } | 36 | } |
| 37 | 37 | ||
| 38 | var parser: Parser = .{ | 38 | var parser: Parser = .{ |
| ... | @@ -68,7 +68,7 @@ pub fn parse(gpa: *Allocator, source: []const u8) Allocator.Error!Tree { | ... | @@ -68,7 +68,7 @@ pub fn parse(gpa: *Allocator, source: []const u8) Allocator.Error!Tree { |
| 68 | const root_decls = try root_members.toSpan(&parser); | 68 | const root_decls = try root_members.toSpan(&parser); |
| 69 | // parseContainerMembers will try to skip as much invalid tokens as | 69 | // parseContainerMembers will try to skip as much invalid tokens as |
| 70 | // it can, so we are now at EOF. | 70 | // 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); |
| 72 | parser.nodes.items(.data)[0] = .{ | 72 | parser.nodes.items(.data)[0] = .{ |
| 73 | .lhs = root_decls.start, | 73 | .lhs = root_decls.start, |
| 74 | .rhs = root_decls.end, | 74 | .rhs = root_decls.end, |
| ... | @@ -186,14 +186,14 @@ const Parser = struct { | ... | @@ -186,14 +186,14 @@ const Parser = struct { |
| 186 | } = .none; | 186 | } = .none; |
| 187 | 187 | ||
| 188 | // Skip container doc comments. | 188 | // Skip container doc comments. |
| 189 | while (p.eatToken(.ContainerDocComment)) |_| {} | 189 | while (p.eatToken(.container_doc_comment)) |_| {} |
| 190 | 190 | ||
| 191 | var trailing_comma = false; | 191 | var trailing_comma = false; |
| 192 | while (true) { | 192 | while (true) { |
| 193 | const doc_comment = p.eatDocComments(); | 193 | const doc_comment = p.eatDocComments(); |
| 194 | 194 | ||
| 195 | switch (p.token_tags[p.tok_i]) { | 195 | switch (p.token_tags[p.tok_i]) { |
| 196 | .Keyword_test => { | 196 | .keyword_test => { |
| 197 | const test_decl_node = try p.expectTestDeclRecoverable(); | 197 | const test_decl_node = try p.expectTestDeclRecoverable(); |
| 198 | if (test_decl_node != 0) { | 198 | if (test_decl_node != 0) { |
| 199 | if (field_state == .seen) { | 199 | if (field_state == .seen) { |
| ... | @@ -203,8 +203,8 @@ const Parser = struct { | ... | @@ -203,8 +203,8 @@ const Parser = struct { |
| 203 | } | 203 | } |
| 204 | trailing_comma = false; | 204 | trailing_comma = false; |
| 205 | }, | 205 | }, |
| 206 | .Keyword_comptime => switch (p.token_tags[p.tok_i + 1]) { | 206 | .keyword_comptime => switch (p.token_tags[p.tok_i + 1]) { |
| 207 | .Identifier => { | 207 | .identifier => { |
| 208 | p.tok_i += 1; | 208 | p.tok_i += 1; |
| 209 | const container_field = try p.expectContainerFieldRecoverable(); | 209 | const container_field = try p.expectContainerFieldRecoverable(); |
| 210 | if (container_field != 0) { | 210 | if (container_field != 0) { |
| ... | @@ -221,12 +221,12 @@ const Parser = struct { | ... | @@ -221,12 +221,12 @@ const Parser = struct { |
| 221 | } | 221 | } |
| 222 | try list.append(container_field); | 222 | try list.append(container_field); |
| 223 | switch (p.token_tags[p.tok_i]) { | 223 | switch (p.token_tags[p.tok_i]) { |
| 224 | .Comma => { | 224 | .comma => { |
| 225 | p.tok_i += 1; | 225 | p.tok_i += 1; |
| 226 | trailing_comma = true; | 226 | trailing_comma = true; |
| 227 | continue; | 227 | continue; |
| 228 | }, | 228 | }, |
| 229 | .RBrace, .Eof => { | 229 | .r_brace, .eof => { |
| 230 | trailing_comma = false; | 230 | trailing_comma = false; |
| 231 | break; | 231 | break; |
| 232 | }, | 232 | }, |
| ... | @@ -235,12 +235,12 @@ const Parser = struct { | ... | @@ -235,12 +235,12 @@ const Parser = struct { |
| 235 | // There is not allowed to be a decl after a field with no comma. | 235 | // There is not allowed to be a decl after a field with no comma. |
| 236 | // Report error but recover parser. | 236 | // Report error but recover parser. |
| 237 | try p.warn(.{ | 237 | try p.warn(.{ |
| 238 | .ExpectedToken = .{ .token = p.tok_i, .expected_id = .Comma }, | 238 | .ExpectedToken = .{ .token = p.tok_i, .expected_id = .comma }, |
| 239 | }); | 239 | }); |
| 240 | p.findNextContainerMember(); | 240 | p.findNextContainerMember(); |
| 241 | } | 241 | } |
| 242 | }, | 242 | }, |
| 243 | .LBrace => { | 243 | .l_brace => { |
| 244 | const comptime_token = p.nextToken(); | 244 | const comptime_token = p.nextToken(); |
| 245 | const block = p.parseBlock() catch |err| switch (err) { | 245 | const block = p.parseBlock() catch |err| switch (err) { |
| 246 | error.OutOfMemory => return error.OutOfMemory, | 246 | error.OutOfMemory => return error.OutOfMemory, |
| ... | @@ -270,7 +270,7 @@ const Parser = struct { | ... | @@ -270,7 +270,7 @@ const Parser = struct { |
| 270 | try p.warn(.{ .ExpectedBlockOrField = .{ .token = p.tok_i } }); | 270 | try p.warn(.{ .ExpectedBlockOrField = .{ .token = p.tok_i } }); |
| 271 | }, | 271 | }, |
| 272 | }, | 272 | }, |
| 273 | .Keyword_pub => { | 273 | .keyword_pub => { |
| 274 | p.tok_i += 1; | 274 | p.tok_i += 1; |
| 275 | const top_level_decl = try p.expectTopLevelDeclRecoverable(); | 275 | const top_level_decl = try p.expectTopLevelDeclRecoverable(); |
| 276 | if (top_level_decl != 0) { | 276 | if (top_level_decl != 0) { |
| ... | @@ -281,7 +281,7 @@ const Parser = struct { | ... | @@ -281,7 +281,7 @@ const Parser = struct { |
| 281 | } | 281 | } |
| 282 | trailing_comma = false; | 282 | trailing_comma = false; |
| 283 | }, | 283 | }, |
| 284 | .Keyword_usingnamespace => { | 284 | .keyword_usingnamespace => { |
| 285 | const node = try p.expectUsingNamespaceRecoverable(); | 285 | const node = try p.expectUsingNamespaceRecoverable(); |
| 286 | if (node != 0) { | 286 | if (node != 0) { |
| 287 | if (field_state == .seen) { | 287 | if (field_state == .seen) { |
| ... | @@ -291,14 +291,14 @@ const Parser = struct { | ... | @@ -291,14 +291,14 @@ const Parser = struct { |
| 291 | } | 291 | } |
| 292 | trailing_comma = false; | 292 | trailing_comma = false; |
| 293 | }, | 293 | }, |
| 294 | .Keyword_const, | 294 | .keyword_const, |
| 295 | .Keyword_var, | 295 | .keyword_var, |
| 296 | .Keyword_threadlocal, | 296 | .keyword_threadlocal, |
| 297 | .Keyword_export, | 297 | .keyword_export, |
| 298 | .Keyword_extern, | 298 | .keyword_extern, |
| 299 | .Keyword_inline, | 299 | .keyword_inline, |
| 300 | .Keyword_noinline, | 300 | .keyword_noinline, |
| 301 | .Keyword_fn, | 301 | .keyword_fn, |
| 302 | => { | 302 | => { |
| 303 | const top_level_decl = try p.expectTopLevelDeclRecoverable(); | 303 | const top_level_decl = try p.expectTopLevelDeclRecoverable(); |
| 304 | if (top_level_decl != 0) { | 304 | if (top_level_decl != 0) { |
| ... | @@ -309,7 +309,7 @@ const Parser = struct { | ... | @@ -309,7 +309,7 @@ const Parser = struct { |
| 309 | } | 309 | } |
| 310 | trailing_comma = false; | 310 | trailing_comma = false; |
| 311 | }, | 311 | }, |
| 312 | .Identifier => { | 312 | .identifier => { |
| 313 | const container_field = try p.expectContainerFieldRecoverable(); | 313 | const container_field = try p.expectContainerFieldRecoverable(); |
| 314 | if (container_field != 0) { | 314 | if (container_field != 0) { |
| 315 | switch (field_state) { | 315 | switch (field_state) { |
| ... | @@ -325,12 +325,12 @@ const Parser = struct { | ... | @@ -325,12 +325,12 @@ const Parser = struct { |
| 325 | } | 325 | } |
| 326 | try list.append(container_field); | 326 | try list.append(container_field); |
| 327 | switch (p.token_tags[p.tok_i]) { | 327 | switch (p.token_tags[p.tok_i]) { |
| 328 | .Comma => { | 328 | .comma => { |
| 329 | p.tok_i += 1; | 329 | p.tok_i += 1; |
| 330 | trailing_comma = true; | 330 | trailing_comma = true; |
| 331 | continue; | 331 | continue; |
| 332 | }, | 332 | }, |
| 333 | .RBrace, .Eof => { | 333 | .r_brace, .eof => { |
| 334 | trailing_comma = false; | 334 | trailing_comma = false; |
| 335 | break; | 335 | break; |
| 336 | }, | 336 | }, |
| ... | @@ -339,12 +339,12 @@ const Parser = struct { | ... | @@ -339,12 +339,12 @@ const Parser = struct { |
| 339 | // There is not allowed to be a decl after a field with no comma. | 339 | // There is not allowed to be a decl after a field with no comma. |
| 340 | // Report error but recover parser. | 340 | // Report error but recover parser. |
| 341 | try p.warn(.{ | 341 | try p.warn(.{ |
| 342 | .ExpectedToken = .{ .token = p.tok_i, .expected_id = .Comma }, | 342 | .ExpectedToken = .{ .token = p.tok_i, .expected_id = .comma }, |
| 343 | }); | 343 | }); |
| 344 | p.findNextContainerMember(); | 344 | p.findNextContainerMember(); |
| 345 | } | 345 | } |
| 346 | }, | 346 | }, |
| 347 | .Eof, .RBrace => { | 347 | .eof, .r_brace => { |
| 348 | if (doc_comment) |tok| { | 348 | if (doc_comment) |tok| { |
| 349 | try p.warn(.{ .UnattachedDocComment = .{ .token = tok } }); | 349 | try p.warn(.{ .UnattachedDocComment = .{ .token = tok } }); |
| 350 | } | 350 | } |
| ... | @@ -396,36 +396,36 @@ const Parser = struct { | ... | @@ -396,36 +396,36 @@ const Parser = struct { |
| 396 | const tok = p.nextToken(); | 396 | const tok = p.nextToken(); |
| 397 | switch (p.token_tags[tok]) { | 397 | switch (p.token_tags[tok]) { |
| 398 | // any of these can start a new top level declaration | 398 | // any of these can start a new top level declaration |
| 399 | .Keyword_test, | 399 | .keyword_test, |
| 400 | .Keyword_comptime, | 400 | .keyword_comptime, |
| 401 | .Keyword_pub, | 401 | .keyword_pub, |
| 402 | .Keyword_export, | 402 | .keyword_export, |
| 403 | .Keyword_extern, | 403 | .keyword_extern, |
| 404 | .Keyword_inline, | 404 | .keyword_inline, |
| 405 | .Keyword_noinline, | 405 | .keyword_noinline, |
| 406 | .Keyword_usingnamespace, | 406 | .keyword_usingnamespace, |
| 407 | .Keyword_threadlocal, | 407 | .keyword_threadlocal, |
| 408 | .Keyword_const, | 408 | .keyword_const, |
| 409 | .Keyword_var, | 409 | .keyword_var, |
| 410 | .Keyword_fn, | 410 | .keyword_fn, |
| 411 | .Identifier, | 411 | .identifier, |
| 412 | => { | 412 | => { |
| 413 | if (level == 0) { | 413 | if (level == 0) { |
| 414 | p.tok_i -= 1; | 414 | p.tok_i -= 1; |
| 415 | return; | 415 | return; |
| 416 | } | 416 | } |
| 417 | }, | 417 | }, |
| 418 | .Comma, .Semicolon => { | 418 | .comma, .semicolon => { |
| 419 | // this decl was likely meant to end here | 419 | // this decl was likely meant to end here |
| 420 | if (level == 0) { | 420 | if (level == 0) { |
| 421 | return; | 421 | return; |
| 422 | } | 422 | } |
| 423 | }, | 423 | }, |
| 424 | .LParen, .LBracket, .LBrace => level += 1, | 424 | .l_paren, .l_bracket, .l_brace => level += 1, |
| 425 | .RParen, .RBracket => { | 425 | .r_paren, .r_bracket => { |
| 426 | if (level != 0) level -= 1; | 426 | if (level != 0) level -= 1; |
| 427 | }, | 427 | }, |
| 428 | .RBrace => { | 428 | .r_brace => { |
| 429 | if (level == 0) { | 429 | if (level == 0) { |
| 430 | // end of container, exit | 430 | // end of container, exit |
| 431 | p.tok_i -= 1; | 431 | p.tok_i -= 1; |
| ... | @@ -433,7 +433,7 @@ const Parser = struct { | ... | @@ -433,7 +433,7 @@ const Parser = struct { |
| 433 | } | 433 | } |
| 434 | level -= 1; | 434 | level -= 1; |
| 435 | }, | 435 | }, |
| 436 | .Eof => { | 436 | .eof => { |
| 437 | p.tok_i -= 1; | 437 | p.tok_i -= 1; |
| 438 | return; | 438 | return; |
| 439 | }, | 439 | }, |
| ... | @@ -448,20 +448,20 @@ const Parser = struct { | ... | @@ -448,20 +448,20 @@ const Parser = struct { |
| 448 | while (true) { | 448 | while (true) { |
| 449 | const tok = p.nextToken(); | 449 | const tok = p.nextToken(); |
| 450 | switch (p.token_tags[tok]) { | 450 | switch (p.token_tags[tok]) { |
| 451 | .LBrace => level += 1, | 451 | .l_brace => level += 1, |
| 452 | .RBrace => { | 452 | .r_brace => { |
| 453 | if (level == 0) { | 453 | if (level == 0) { |
| 454 | p.tok_i -= 1; | 454 | p.tok_i -= 1; |
| 455 | return; | 455 | return; |
| 456 | } | 456 | } |
| 457 | level -= 1; | 457 | level -= 1; |
| 458 | }, | 458 | }, |
| 459 | .Semicolon => { | 459 | .semicolon => { |
| 460 | if (level == 0) { | 460 | if (level == 0) { |
| 461 | return; | 461 | return; |
| 462 | } | 462 | } |
| 463 | }, | 463 | }, |
| 464 | .Eof => { | 464 | .eof => { |
| 465 | p.tok_i -= 1; | 465 | p.tok_i -= 1; |
| 466 | return; | 466 | return; |
| 467 | }, | 467 | }, |
| ... | @@ -472,8 +472,8 @@ const Parser = struct { | ... | @@ -472,8 +472,8 @@ const Parser = struct { |
| 472 | 472 | ||
| 473 | /// TestDecl <- KEYWORD_test STRINGLITERALSINGLE? Block | 473 | /// TestDecl <- KEYWORD_test STRINGLITERALSINGLE? Block |
| 474 | fn expectTestDecl(p: *Parser) !Node.Index { | 474 | fn expectTestDecl(p: *Parser) !Node.Index { |
| 475 | const test_token = p.assertToken(.Keyword_test); | 475 | const test_token = p.assertToken(.keyword_test); |
| 476 | const name_token = p.eatToken(.StringLiteral); | 476 | const name_token = p.eatToken(.string_literal); |
| 477 | const block_node = try p.parseBlock(); | 477 | const block_node = try p.parseBlock(); |
| 478 | if (block_node == 0) return p.fail(.{ .ExpectedLBrace = .{ .token = p.tok_i } }); | 478 | if (block_node == 0) return p.fail(.{ .ExpectedLBrace = .{ .token = p.tok_i } }); |
| 479 | return p.addNode(.{ | 479 | return p.addNode(.{ |
| ... | @@ -505,15 +505,15 @@ const Parser = struct { | ... | @@ -505,15 +505,15 @@ const Parser = struct { |
| 505 | var expect_fn: bool = false; | 505 | var expect_fn: bool = false; |
| 506 | var exported: bool = false; | 506 | var exported: bool = false; |
| 507 | switch (p.token_tags[extern_export_inline_token]) { | 507 | switch (p.token_tags[extern_export_inline_token]) { |
| 508 | .Keyword_extern => _ = p.eatToken(.StringLiteral), | 508 | .keyword_extern => _ = p.eatToken(.string_literal), |
| 509 | .Keyword_export => exported = true, | 509 | .keyword_export => exported = true, |
| 510 | .Keyword_inline, .Keyword_noinline => expect_fn = true, | 510 | .keyword_inline, .keyword_noinline => expect_fn = true, |
| 511 | else => p.tok_i -= 1, | 511 | else => p.tok_i -= 1, |
| 512 | } | 512 | } |
| 513 | const fn_proto = try p.parseFnProto(); | 513 | const fn_proto = try p.parseFnProto(); |
| 514 | if (fn_proto != 0) { | 514 | if (fn_proto != 0) { |
| 515 | switch (p.token_tags[p.tok_i]) { | 515 | switch (p.token_tags[p.tok_i]) { |
| 516 | .Semicolon => { | 516 | .semicolon => { |
| 517 | const semicolon_token = p.nextToken(); | 517 | const semicolon_token = p.nextToken(); |
| 518 | try p.parseAppendedDocComment(semicolon_token); | 518 | try p.parseAppendedDocComment(semicolon_token); |
| 519 | return p.addNode(.{ | 519 | return p.addNode(.{ |
| ... | @@ -525,7 +525,7 @@ const Parser = struct { | ... | @@ -525,7 +525,7 @@ const Parser = struct { |
| 525 | }, | 525 | }, |
| 526 | }); | 526 | }); |
| 527 | }, | 527 | }, |
| 528 | .LBrace => { | 528 | .l_brace => { |
| 529 | const body_block = try p.parseBlock(); | 529 | const body_block = try p.parseBlock(); |
| 530 | assert(body_block != 0); | 530 | assert(body_block != 0); |
| 531 | return p.addNode(.{ | 531 | return p.addNode(.{ |
| ... | @@ -553,10 +553,10 @@ const Parser = struct { | ... | @@ -553,10 +553,10 @@ const Parser = struct { |
| 553 | return error.ParseError; | 553 | return error.ParseError; |
| 554 | } | 554 | } |
| 555 | 555 | ||
| 556 | const thread_local_token = p.eatToken(.Keyword_threadlocal); | 556 | const thread_local_token = p.eatToken(.keyword_threadlocal); |
| 557 | const var_decl = try p.parseVarDecl(); | 557 | const var_decl = try p.parseVarDecl(); |
| 558 | if (var_decl != 0) { | 558 | if (var_decl != 0) { |
| 559 | const semicolon_token = try p.expectToken(.Semicolon); | 559 | const semicolon_token = try p.expectToken(.semicolon); |
| 560 | try p.parseAppendedDocComment(semicolon_token); | 560 | try p.parseAppendedDocComment(semicolon_token); |
| 561 | return var_decl; | 561 | return var_decl; |
| 562 | } | 562 | } |
| ... | @@ -582,9 +582,9 @@ const Parser = struct { | ... | @@ -582,9 +582,9 @@ const Parser = struct { |
| 582 | } | 582 | } |
| 583 | 583 | ||
| 584 | fn expectUsingNamespace(p: *Parser) !Node.Index { | 584 | fn expectUsingNamespace(p: *Parser) !Node.Index { |
| 585 | const usingnamespace_token = try p.expectToken(.Keyword_usingnamespace); | 585 | const usingnamespace_token = try p.expectToken(.keyword_usingnamespace); |
| 586 | const expr = try p.expectExpr(); | 586 | const expr = try p.expectExpr(); |
| 587 | const semicolon_token = try p.expectToken(.Semicolon); | 587 | const semicolon_token = try p.expectToken(.semicolon); |
| 588 | try p.parseAppendedDocComment(semicolon_token); | 588 | try p.parseAppendedDocComment(semicolon_token); |
| 589 | return p.addNode(.{ | 589 | return p.addNode(.{ |
| 590 | .tag = .UsingNamespace, | 590 | .tag = .UsingNamespace, |
| ... | @@ -608,14 +608,14 @@ const Parser = struct { | ... | @@ -608,14 +608,14 @@ const Parser = struct { |
| 608 | 608 | ||
| 609 | /// FnProto <- KEYWORD_fn IDENTIFIER? LPAREN ParamDeclList RPAREN ByteAlign? LinkSection? CallConv? EXCLAMATIONMARK? (Keyword_anytype / TypeExpr) | 609 | /// FnProto <- KEYWORD_fn IDENTIFIER? LPAREN ParamDeclList RPAREN ByteAlign? LinkSection? CallConv? EXCLAMATIONMARK? (Keyword_anytype / TypeExpr) |
| 610 | fn parseFnProto(p: *Parser) !Node.Index { | 610 | fn parseFnProto(p: *Parser) !Node.Index { |
| 611 | const fn_token = p.eatToken(.Keyword_fn) orelse return null_node; | 611 | const fn_token = p.eatToken(.keyword_fn) orelse return null_node; |
| 612 | _ = p.eatToken(.Identifier); | 612 | _ = p.eatToken(.identifier); |
| 613 | const params = try p.parseParamDeclList(); | 613 | const params = try p.parseParamDeclList(); |
| 614 | defer params.deinit(p.gpa); | 614 | defer params.deinit(p.gpa); |
| 615 | const align_expr = try p.parseByteAlign(); | 615 | const align_expr = try p.parseByteAlign(); |
| 616 | const section_expr = try p.parseLinkSection(); | 616 | const section_expr = try p.parseLinkSection(); |
| 617 | const callconv_expr = try p.parseCallconv(); | 617 | const callconv_expr = try p.parseCallconv(); |
| 618 | const bang_token = p.eatToken(.Bang); | 618 | const bang_token = p.eatToken(.bang); |
| 619 | 619 | ||
| 620 | const return_type_expr = try p.parseTypeExpr(); | 620 | const return_type_expr = try p.parseTypeExpr(); |
| 621 | if (return_type_expr == 0) { | 621 | if (return_type_expr == 0) { |
| ... | @@ -686,15 +686,15 @@ const Parser = struct { | ... | @@ -686,15 +686,15 @@ const Parser = struct { |
| 686 | 686 | ||
| 687 | /// VarDecl <- (KEYWORD_const / KEYWORD_var) IDENTIFIER (COLON TypeExpr)? ByteAlign? LinkSection? (EQUAL Expr)? SEMICOLON | 687 | /// VarDecl <- (KEYWORD_const / KEYWORD_var) IDENTIFIER (COLON TypeExpr)? ByteAlign? LinkSection? (EQUAL Expr)? SEMICOLON |
| 688 | fn parseVarDecl(p: *Parser) !Node.Index { | 688 | fn parseVarDecl(p: *Parser) !Node.Index { |
| 689 | const mut_token = p.eatToken(.Keyword_const) orelse | 689 | const mut_token = p.eatToken(.keyword_const) orelse |
| 690 | p.eatToken(.Keyword_var) orelse | 690 | p.eatToken(.keyword_var) orelse |
| 691 | return null_node; | 691 | return null_node; |
| 692 | 692 | ||
| 693 | _ = try p.expectToken(.Identifier); | 693 | _ = try p.expectToken(.identifier); |
| 694 | const type_node: Node.Index = if (p.eatToken(.Colon) == null) 0 else try p.expectTypeExpr(); | 694 | const type_node: Node.Index = if (p.eatToken(.colon) == null) 0 else try p.expectTypeExpr(); |
| 695 | const align_node = try p.parseByteAlign(); | 695 | const align_node = try p.parseByteAlign(); |
| 696 | const section_node = try p.parseLinkSection(); | 696 | 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(); |
| 698 | if (section_node == 0) { | 698 | if (section_node == 0) { |
| 699 | if (align_node == 0) { | 699 | if (align_node == 0) { |
| 700 | return p.addNode(.{ | 700 | return p.addNode(.{ |
| ... | @@ -745,13 +745,13 @@ const Parser = struct { | ... | @@ -745,13 +745,13 @@ const Parser = struct { |
| 745 | 745 | ||
| 746 | /// ContainerField <- KEYWORD_comptime? IDENTIFIER (COLON TypeExpr ByteAlign?)? (EQUAL Expr)? | 746 | /// ContainerField <- KEYWORD_comptime? IDENTIFIER (COLON TypeExpr ByteAlign?)? (EQUAL Expr)? |
| 747 | fn expectContainerField(p: *Parser) !Node.Index { | 747 | fn expectContainerField(p: *Parser) !Node.Index { |
| 748 | const comptime_token = p.eatToken(.Keyword_comptime); | 748 | const comptime_token = p.eatToken(.keyword_comptime); |
| 749 | const name_token = p.assertToken(.Identifier); | 749 | const name_token = p.assertToken(.identifier); |
| 750 | 750 | ||
| 751 | var align_expr: Node.Index = 0; | 751 | var align_expr: Node.Index = 0; |
| 752 | var type_expr: Node.Index = 0; | 752 | var type_expr: Node.Index = 0; |
| 753 | if (p.eatToken(.Colon)) |_| { | 753 | if (p.eatToken(.colon)) |_| { |
| 754 | if (p.eatToken(.Keyword_anytype)) |anytype_tok| { | 754 | if (p.eatToken(.keyword_anytype)) |anytype_tok| { |
| 755 | type_expr = try p.addNode(.{ | 755 | type_expr = try p.addNode(.{ |
| 756 | .tag = .AnyType, | 756 | .tag = .AnyType, |
| 757 | .main_token = anytype_tok, | 757 | .main_token = anytype_tok, |
| ... | @@ -766,7 +766,7 @@ const Parser = struct { | ... | @@ -766,7 +766,7 @@ const Parser = struct { |
| 766 | } | 766 | } |
| 767 | } | 767 | } |
| 768 | 768 | ||
| 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(); |
| 770 | 770 | ||
| 771 | if (align_expr == 0) { | 771 | if (align_expr == 0) { |
| 772 | return p.addNode(.{ | 772 | return p.addNode(.{ |
| ... | @@ -823,11 +823,11 @@ const Parser = struct { | ... | @@ -823,11 +823,11 @@ const Parser = struct { |
| 823 | /// / SwitchExpr | 823 | /// / SwitchExpr |
| 824 | /// / AssignExpr SEMICOLON | 824 | /// / AssignExpr SEMICOLON |
| 825 | fn parseStatement(p: *Parser) Error!Node.Index { | 825 | fn parseStatement(p: *Parser) Error!Node.Index { |
| 826 | const comptime_token = p.eatToken(.Keyword_comptime); | 826 | const comptime_token = p.eatToken(.keyword_comptime); |
| 827 | 827 | ||
| 828 | const var_decl = try p.parseVarDecl(); | 828 | const var_decl = try p.parseVarDecl(); |
| 829 | if (var_decl != 0) { | 829 | if (var_decl != 0) { |
| 830 | _ = try p.expectTokenRecoverable(.Semicolon); | 830 | _ = try p.expectTokenRecoverable(.semicolon); |
| 831 | return var_decl; | 831 | return var_decl; |
| 832 | } | 832 | } |
| 833 | 833 | ||
| ... | @@ -843,7 +843,7 @@ const Parser = struct { | ... | @@ -843,7 +843,7 @@ const Parser = struct { |
| 843 | } | 843 | } |
| 844 | 844 | ||
| 845 | switch (p.token_tags[p.tok_i]) { | 845 | switch (p.token_tags[p.tok_i]) { |
| 846 | .Keyword_nosuspend => { | 846 | .keyword_nosuspend => { |
| 847 | return p.addNode(.{ | 847 | return p.addNode(.{ |
| 848 | .tag = .Nosuspend, | 848 | .tag = .Nosuspend, |
| 849 | .main_token = p.nextToken(), | 849 | .main_token = p.nextToken(), |
| ... | @@ -853,9 +853,9 @@ const Parser = struct { | ... | @@ -853,9 +853,9 @@ const Parser = struct { |
| 853 | }, | 853 | }, |
| 854 | }); | 854 | }); |
| 855 | }, | 855 | }, |
| 856 | .Keyword_suspend => { | 856 | .keyword_suspend => { |
| 857 | const token = p.nextToken(); | 857 | 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) |
| 859 | 0 | 859 | 0 |
| 860 | else | 860 | else |
| 861 | try p.expectBlockExprStatement(); | 861 | try p.expectBlockExprStatement(); |
| ... | @@ -868,7 +868,7 @@ const Parser = struct { | ... | @@ -868,7 +868,7 @@ const Parser = struct { |
| 868 | }, | 868 | }, |
| 869 | }); | 869 | }); |
| 870 | }, | 870 | }, |
| 871 | .Keyword_defer => return p.addNode(.{ | 871 | .keyword_defer => return p.addNode(.{ |
| 872 | .tag = .Defer, | 872 | .tag = .Defer, |
| 873 | .main_token = p.nextToken(), | 873 | .main_token = p.nextToken(), |
| 874 | .data = .{ | 874 | .data = .{ |
| ... | @@ -876,7 +876,7 @@ const Parser = struct { | ... | @@ -876,7 +876,7 @@ const Parser = struct { |
| 876 | .rhs = try p.expectBlockExprStatement(), | 876 | .rhs = try p.expectBlockExprStatement(), |
| 877 | }, | 877 | }, |
| 878 | }), | 878 | }), |
| 879 | .Keyword_errdefer => return p.addNode(.{ | 879 | .keyword_errdefer => return p.addNode(.{ |
| 880 | .tag = .ErrDefer, | 880 | .tag = .ErrDefer, |
| 881 | .main_token = p.nextToken(), | 881 | .main_token = p.nextToken(), |
| 882 | .data = .{ | 882 | .data = .{ |
| ... | @@ -884,8 +884,8 @@ const Parser = struct { | ... | @@ -884,8 +884,8 @@ const Parser = struct { |
| 884 | .rhs = try p.expectBlockExprStatement(), | 884 | .rhs = try p.expectBlockExprStatement(), |
| 885 | }, | 885 | }, |
| 886 | }), | 886 | }), |
| 887 | .Keyword_switch => return p.expectSwitchExpr(), | 887 | .keyword_switch => return p.expectSwitchExpr(), |
| 888 | .Keyword_if => return p.expectIfStatement(), | 888 | .keyword_if => return p.expectIfStatement(), |
| 889 | else => {}, | 889 | else => {}, |
| 890 | } | 890 | } |
| 891 | 891 | ||
| ... | @@ -894,7 +894,7 @@ const Parser = struct { | ... | @@ -894,7 +894,7 @@ const Parser = struct { |
| 894 | 894 | ||
| 895 | const assign_expr = try p.parseAssignExpr(); | 895 | const assign_expr = try p.parseAssignExpr(); |
| 896 | if (assign_expr != 0) { | 896 | if (assign_expr != 0) { |
| 897 | _ = try p.expectTokenRecoverable(.Semicolon); | 897 | _ = try p.expectTokenRecoverable(.semicolon); |
| 898 | return assign_expr; | 898 | return assign_expr; |
| 899 | } | 899 | } |
| 900 | 900 | ||
| ... | @@ -918,7 +918,7 @@ const Parser = struct { | ... | @@ -918,7 +918,7 @@ const Parser = struct { |
| 918 | error.OutOfMemory => return error.OutOfMemory, | 918 | error.OutOfMemory => return error.OutOfMemory, |
| 919 | error.ParseError => { | 919 | error.ParseError => { |
| 920 | p.findNextStmt(); // Try to skip to the next statement. | 920 | 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; |
| 922 | continue; | 922 | continue; |
| 923 | }, | 923 | }, |
| 924 | }; | 924 | }; |
| ... | @@ -929,10 +929,10 @@ const Parser = struct { | ... | @@ -929,10 +929,10 @@ const Parser = struct { |
| 929 | /// <- IfPrefix BlockExpr ( KEYWORD_else Payload? Statement )? | 929 | /// <- IfPrefix BlockExpr ( KEYWORD_else Payload? Statement )? |
| 930 | /// / IfPrefix AssignExpr ( SEMICOLON / KEYWORD_else Payload? Statement ) | 930 | /// / IfPrefix AssignExpr ( SEMICOLON / KEYWORD_else Payload? Statement ) |
| 931 | fn expectIfStatement(p: *Parser) !Node.Index { | 931 | fn expectIfStatement(p: *Parser) !Node.Index { |
| 932 | const if_token = p.assertToken(.Keyword_if); | 932 | const if_token = p.assertToken(.keyword_if); |
| 933 | _ = try p.expectToken(.LParen); | 933 | _ = try p.expectToken(.l_paren); |
| 934 | const condition = try p.expectExpr(); | 934 | const condition = try p.expectExpr(); |
| 935 | _ = try p.expectToken(.RParen); | 935 | _ = try p.expectToken(.r_paren); |
| 936 | const then_payload = try p.parsePtrPayload(); | 936 | const then_payload = try p.parsePtrPayload(); |
| 937 | 937 | ||
| 938 | // TODO propose to change the syntax so that semicolons are always required | 938 | // TODO propose to change the syntax so that semicolons are always required |
| ... | @@ -945,7 +945,7 @@ const Parser = struct { | ... | @@ -945,7 +945,7 @@ const Parser = struct { |
| 945 | if (assign_expr == 0) { | 945 | if (assign_expr == 0) { |
| 946 | return p.fail(.{ .ExpectedBlockOrAssignment = .{ .token = p.tok_i } }); | 946 | return p.fail(.{ .ExpectedBlockOrAssignment = .{ .token = p.tok_i } }); |
| 947 | } | 947 | } |
| 948 | if (p.eatToken(.Semicolon)) |_| { | 948 | if (p.eatToken(.semicolon)) |_| { |
| 949 | return p.addNode(.{ | 949 | return p.addNode(.{ |
| 950 | .tag = .IfSimple, | 950 | .tag = .IfSimple, |
| 951 | .main_token = if_token, | 951 | .main_token = if_token, |
| ... | @@ -958,7 +958,7 @@ const Parser = struct { | ... | @@ -958,7 +958,7 @@ const Parser = struct { |
| 958 | else_required = true; | 958 | else_required = true; |
| 959 | break :blk assign_expr; | 959 | break :blk assign_expr; |
| 960 | }; | 960 | }; |
| 961 | const else_token = p.eatToken(.Keyword_else) orelse { | 961 | const else_token = p.eatToken(.keyword_else) orelse { |
| 962 | if (else_required) { | 962 | if (else_required) { |
| 963 | return p.fail(.{ .ExpectedSemiOrElse = .{ .token = p.tok_i } }); | 963 | return p.fail(.{ .ExpectedSemiOrElse = .{ .token = p.tok_i } }); |
| 964 | } | 964 | } |
| ... | @@ -1004,7 +1004,7 @@ const Parser = struct { | ... | @@ -1004,7 +1004,7 @@ const Parser = struct { |
| 1004 | 1004 | ||
| 1005 | /// LoopStatement <- KEYWORD_inline? (ForStatement / WhileStatement) | 1005 | /// LoopStatement <- KEYWORD_inline? (ForStatement / WhileStatement) |
| 1006 | fn parseLoopStatement(p: *Parser) !Node.Index { | 1006 | fn parseLoopStatement(p: *Parser) !Node.Index { |
| 1007 | const inline_token = p.eatToken(.Keyword_inline); | 1007 | const inline_token = p.eatToken(.keyword_inline); |
| 1008 | 1008 | ||
| 1009 | const for_statement = try p.parseForStatement(); | 1009 | const for_statement = try p.parseForStatement(); |
| 1010 | if (for_statement != 0) return for_statement; | 1010 | if (for_statement != 0) return for_statement; |
| ... | @@ -1023,10 +1023,10 @@ const Parser = struct { | ... | @@ -1023,10 +1023,10 @@ const Parser = struct { |
| 1023 | /// <- ForPrefix BlockExpr ( KEYWORD_else Statement )? | 1023 | /// <- ForPrefix BlockExpr ( KEYWORD_else Statement )? |
| 1024 | /// / ForPrefix AssignExpr ( SEMICOLON / KEYWORD_else Statement ) | 1024 | /// / ForPrefix AssignExpr ( SEMICOLON / KEYWORD_else Statement ) |
| 1025 | fn parseForStatement(p: *Parser) !Node.Index { | 1025 | fn parseForStatement(p: *Parser) !Node.Index { |
| 1026 | const for_token = p.eatToken(.Keyword_for) orelse return null_node; | 1026 | const for_token = p.eatToken(.keyword_for) orelse return null_node; |
| 1027 | _ = try p.expectToken(.LParen); | 1027 | _ = try p.expectToken(.l_paren); |
| 1028 | const array_expr = try p.expectExpr(); | 1028 | const array_expr = try p.expectExpr(); |
| 1029 | _ = try p.expectToken(.RParen); | 1029 | _ = try p.expectToken(.r_paren); |
| 1030 | _ = try p.parsePtrIndexPayload(); | 1030 | _ = try p.parsePtrIndexPayload(); |
| 1031 | 1031 | ||
| 1032 | // TODO propose to change the syntax so that semicolons are always required | 1032 | // TODO propose to change the syntax so that semicolons are always required |
| ... | @@ -1039,7 +1039,7 @@ const Parser = struct { | ... | @@ -1039,7 +1039,7 @@ const Parser = struct { |
| 1039 | if (assign_expr == 0) { | 1039 | if (assign_expr == 0) { |
| 1040 | return p.fail(.{ .ExpectedBlockOrAssignment = .{ .token = p.tok_i } }); | 1040 | return p.fail(.{ .ExpectedBlockOrAssignment = .{ .token = p.tok_i } }); |
| 1041 | } | 1041 | } |
| 1042 | if (p.eatToken(.Semicolon)) |_| { | 1042 | if (p.eatToken(.semicolon)) |_| { |
| 1043 | return p.addNode(.{ | 1043 | return p.addNode(.{ |
| 1044 | .tag = .ForSimple, | 1044 | .tag = .ForSimple, |
| 1045 | .main_token = for_token, | 1045 | .main_token = for_token, |
| ... | @@ -1052,7 +1052,7 @@ const Parser = struct { | ... | @@ -1052,7 +1052,7 @@ const Parser = struct { |
| 1052 | else_required = true; | 1052 | else_required = true; |
| 1053 | break :blk assign_expr; | 1053 | break :blk assign_expr; |
| 1054 | }; | 1054 | }; |
| 1055 | const else_token = p.eatToken(.Keyword_else) orelse { | 1055 | const else_token = p.eatToken(.keyword_else) orelse { |
| 1056 | if (else_required) { | 1056 | if (else_required) { |
| 1057 | return p.fail(.{ .ExpectedSemiOrElse = .{ .token = p.tok_i } }); | 1057 | return p.fail(.{ .ExpectedSemiOrElse = .{ .token = p.tok_i } }); |
| 1058 | } | 1058 | } |
| ... | @@ -1083,10 +1083,10 @@ const Parser = struct { | ... | @@ -1083,10 +1083,10 @@ const Parser = struct { |
| 1083 | /// <- WhilePrefix BlockExpr ( KEYWORD_else Payload? Statement )? | 1083 | /// <- WhilePrefix BlockExpr ( KEYWORD_else Payload? Statement )? |
| 1084 | /// / WhilePrefix AssignExpr ( SEMICOLON / KEYWORD_else Payload? Statement ) | 1084 | /// / WhilePrefix AssignExpr ( SEMICOLON / KEYWORD_else Payload? Statement ) |
| 1085 | fn parseWhileStatement(p: *Parser) !Node.Index { | 1085 | fn parseWhileStatement(p: *Parser) !Node.Index { |
| 1086 | const while_token = p.eatToken(.Keyword_while) orelse return null_node; | 1086 | const while_token = p.eatToken(.keyword_while) orelse return null_node; |
| 1087 | _ = try p.expectToken(.LParen); | 1087 | _ = try p.expectToken(.l_paren); |
| 1088 | const condition = try p.expectExpr(); | 1088 | const condition = try p.expectExpr(); |
| 1089 | _ = try p.expectToken(.RParen); | 1089 | _ = try p.expectToken(.r_paren); |
| 1090 | const then_payload = try p.parsePtrPayload(); | 1090 | const then_payload = try p.parsePtrPayload(); |
| 1091 | const cont_expr = try p.parseWhileContinueExpr(); | 1091 | const cont_expr = try p.parseWhileContinueExpr(); |
| 1092 | 1092 | ||
| ... | @@ -1100,7 +1100,7 @@ const Parser = struct { | ... | @@ -1100,7 +1100,7 @@ const Parser = struct { |
| 1100 | if (assign_expr == 0) { | 1100 | if (assign_expr == 0) { |
| 1101 | return p.fail(.{ .ExpectedBlockOrAssignment = .{ .token = p.tok_i } }); | 1101 | return p.fail(.{ .ExpectedBlockOrAssignment = .{ .token = p.tok_i } }); |
| 1102 | } | 1102 | } |
| 1103 | if (p.eatToken(.Semicolon)) |_| { | 1103 | if (p.eatToken(.semicolon)) |_| { |
| 1104 | if (cont_expr == 0) { | 1104 | if (cont_expr == 0) { |
| 1105 | return p.addNode(.{ | 1105 | return p.addNode(.{ |
| 1106 | .tag = .WhileSimple, | 1106 | .tag = .WhileSimple, |
| ... | @@ -1127,7 +1127,7 @@ const Parser = struct { | ... | @@ -1127,7 +1127,7 @@ const Parser = struct { |
| 1127 | else_required = true; | 1127 | else_required = true; |
| 1128 | break :blk assign_expr; | 1128 | break :blk assign_expr; |
| 1129 | }; | 1129 | }; |
| 1130 | const else_token = p.eatToken(.Keyword_else) orelse { | 1130 | const else_token = p.eatToken(.keyword_else) orelse { |
| 1131 | if (else_required) { | 1131 | if (else_required) { |
| 1132 | return p.fail(.{ .ExpectedSemiOrElse = .{ .token = p.tok_i } }); | 1132 | return p.fail(.{ .ExpectedSemiOrElse = .{ .token = p.tok_i } }); |
| 1133 | } | 1133 | } |
| ... | @@ -1180,7 +1180,7 @@ const Parser = struct { | ... | @@ -1180,7 +1180,7 @@ const Parser = struct { |
| 1180 | } | 1180 | } |
| 1181 | const assign_expr = try p.parseAssignExpr(); | 1181 | const assign_expr = try p.parseAssignExpr(); |
| 1182 | if (assign_expr != 0) { | 1182 | if (assign_expr != 0) { |
| 1183 | _ = try p.expectTokenRecoverable(.Semicolon); | 1183 | _ = try p.expectTokenRecoverable(.semicolon); |
| 1184 | return assign_expr; | 1184 | return assign_expr; |
| 1185 | } | 1185 | } |
| 1186 | return null_node; | 1186 | return null_node; |
| ... | @@ -1197,9 +1197,9 @@ const Parser = struct { | ... | @@ -1197,9 +1197,9 @@ const Parser = struct { |
| 1197 | /// BlockExpr <- BlockLabel? Block | 1197 | /// BlockExpr <- BlockLabel? Block |
| 1198 | fn parseBlockExpr(p: *Parser) Error!Node.Index { | 1198 | fn parseBlockExpr(p: *Parser) Error!Node.Index { |
| 1199 | switch (p.token_tags[p.tok_i]) { | 1199 | switch (p.token_tags[p.tok_i]) { |
| 1200 | .Identifier => { | 1200 | .identifier => { |
| 1201 | if (p.token_tags[p.tok_i + 1] == .Colon and | 1201 | if (p.token_tags[p.tok_i + 1] == .colon and |
| 1202 | p.token_tags[p.tok_i + 2] == .LBrace) | 1202 | p.token_tags[p.tok_i + 2] == .l_brace) |
| 1203 | { | 1203 | { |
| 1204 | p.tok_i += 2; | 1204 | p.tok_i += 2; |
| 1205 | return p.parseBlock(); | 1205 | return p.parseBlock(); |
| ... | @@ -1207,7 +1207,7 @@ const Parser = struct { | ... | @@ -1207,7 +1207,7 @@ const Parser = struct { |
| 1207 | return null_node; | 1207 | return null_node; |
| 1208 | } | 1208 | } |
| 1209 | }, | 1209 | }, |
| 1210 | .LBrace => return p.parseBlock(), | 1210 | .l_brace => return p.parseBlock(), |
| 1211 | else => return null_node, | 1211 | else => return null_node, |
| 1212 | } | 1212 | } |
| 1213 | } | 1213 | } |
| ... | @@ -1233,20 +1233,20 @@ const Parser = struct { | ... | @@ -1233,20 +1233,20 @@ const Parser = struct { |
| 1233 | if (expr == 0) return null_node; | 1233 | if (expr == 0) return null_node; |
| 1234 | 1234 | ||
| 1235 | const tag: Node.Tag = switch (p.token_tags[p.tok_i]) { | 1235 | const tag: Node.Tag = switch (p.token_tags[p.tok_i]) { |
| 1236 | .AsteriskEqual => .AssignMul, | 1236 | .asterisk_equal => .AssignMul, |
| 1237 | .SlashEqual => .AssignDiv, | 1237 | .slash_equal => .AssignDiv, |
| 1238 | .PercentEqual => .AssignMod, | 1238 | .percent_equal => .AssignMod, |
| 1239 | .PlusEqual => .AssignAdd, | 1239 | .plus_equal => .AssignAdd, |
| 1240 | .MinusEqual => .AssignSub, | 1240 | .minus_equal => .AssignSub, |
| 1241 | .AngleBracketAngleBracketLeftEqual => .AssignBitShiftLeft, | 1241 | .angle_bracket_angle_bracket_left_equal => .AssignBitShiftLeft, |
| 1242 | .AngleBracketAngleBracketRightEqual => .AssignBitShiftRight, | 1242 | .angle_bracket_angle_bracket_right_equal => .AssignBitShiftRight, |
| 1243 | .AmpersandEqual => .AssignBitAnd, | 1243 | .ampersand_equal => .AssignBitAnd, |
| 1244 | .CaretEqual => .AssignBitXor, | 1244 | .caret_equal => .AssignBitXor, |
| 1245 | .PipeEqual => .AssignBitOr, | 1245 | .pipe_equal => .AssignBitOr, |
| 1246 | .AsteriskPercentEqual => .AssignMulWrap, | 1246 | .asterisk_percent_equal => .AssignMulWrap, |
| 1247 | .PlusPercentEqual => .AssignAddWrap, | 1247 | .plus_percent_equal => .AssignAddWrap, |
| 1248 | .MinusPercentEqual => .AssignSubWrap, | 1248 | .minus_percent_equal => .AssignSubWrap, |
| 1249 | .Equal => .Assign, | 1249 | .equal => .Assign, |
| 1250 | else => return expr, | 1250 | else => return expr, |
| 1251 | }; | 1251 | }; |
| 1252 | return p.addNode(.{ | 1252 | return p.addNode(.{ |
| ... | @@ -1288,7 +1288,7 @@ const Parser = struct { | ... | @@ -1288,7 +1288,7 @@ const Parser = struct { |
| 1288 | 1288 | ||
| 1289 | while (true) { | 1289 | while (true) { |
| 1290 | switch (p.token_tags[p.tok_i]) { | 1290 | switch (p.token_tags[p.tok_i]) { |
| 1291 | .Keyword_or => { | 1291 | .keyword_or => { |
| 1292 | const or_token = p.nextToken(); | 1292 | const or_token = p.nextToken(); |
| 1293 | const rhs = try p.parseBoolAndExpr(); | 1293 | const rhs = try p.parseBoolAndExpr(); |
| 1294 | if (rhs == 0) { | 1294 | if (rhs == 0) { |
| ... | @@ -1315,7 +1315,7 @@ const Parser = struct { | ... | @@ -1315,7 +1315,7 @@ const Parser = struct { |
| 1315 | 1315 | ||
| 1316 | while (true) { | 1316 | while (true) { |
| 1317 | switch (p.token_tags[p.tok_i]) { | 1317 | switch (p.token_tags[p.tok_i]) { |
| 1318 | .Keyword_and => { | 1318 | .keyword_and => { |
| 1319 | const and_token = p.nextToken(); | 1319 | const and_token = p.nextToken(); |
| 1320 | const rhs = try p.parseCompareExpr(); | 1320 | const rhs = try p.parseCompareExpr(); |
| 1321 | if (rhs == 0) { | 1321 | if (rhs == 0) { |
| ... | @@ -1348,12 +1348,12 @@ const Parser = struct { | ... | @@ -1348,12 +1348,12 @@ const Parser = struct { |
| 1348 | if (expr == 0) return null_node; | 1348 | if (expr == 0) return null_node; |
| 1349 | 1349 | ||
| 1350 | const tag: Node.Tag = switch (p.token_tags[p.tok_i]) { | 1350 | const tag: Node.Tag = switch (p.token_tags[p.tok_i]) { |
| 1351 | .EqualEqual => .EqualEqual, | 1351 | .equal_equal => .EqualEqual, |
| 1352 | .BangEqual => .BangEqual, | 1352 | .bang_equal => .BangEqual, |
| 1353 | .AngleBracketLeft => .LessThan, | 1353 | .angle_bracket_left => .LessThan, |
| 1354 | .AngleBracketRight => .GreaterThan, | 1354 | .angle_bracket_right => .GreaterThan, |
| 1355 | .AngleBracketLeftEqual => .LessOrEqual, | 1355 | .angle_bracket_left_equal => .LessOrEqual, |
| 1356 | .AngleBracketRightEqual => .GreaterOrEqual, | 1356 | .angle_bracket_right_equal => .GreaterOrEqual, |
| 1357 | else => return expr, | 1357 | else => return expr, |
| 1358 | }; | 1358 | }; |
| 1359 | return p.addNode(.{ | 1359 | return p.addNode(.{ |
| ... | @@ -1379,11 +1379,11 @@ const Parser = struct { | ... | @@ -1379,11 +1379,11 @@ const Parser = struct { |
| 1379 | 1379 | ||
| 1380 | while (true) { | 1380 | while (true) { |
| 1381 | const tag: Node.Tag = switch (p.token_tags[p.tok_i]) { | 1381 | const tag: Node.Tag = switch (p.token_tags[p.tok_i]) { |
| 1382 | .Ampersand => .BitAnd, | 1382 | .ampersand => .BitAnd, |
| 1383 | .Caret => .BitXor, | 1383 | .caret => .BitXor, |
| 1384 | .Pipe => .BitOr, | 1384 | .pipe => .BitOr, |
| 1385 | .Keyword_orelse => .OrElse, | 1385 | .keyword_orelse => .OrElse, |
| 1386 | .Keyword_catch => { | 1386 | .keyword_catch => { |
| 1387 | const catch_token = p.nextToken(); | 1387 | const catch_token = p.nextToken(); |
| 1388 | _ = try p.parsePayload(); | 1388 | _ = try p.parsePayload(); |
| 1389 | const rhs = try p.parseBitShiftExpr(); | 1389 | const rhs = try p.parseBitShiftExpr(); |
| ... | @@ -1432,8 +1432,8 @@ const Parser = struct { | ... | @@ -1432,8 +1432,8 @@ const Parser = struct { |
| 1432 | 1432 | ||
| 1433 | while (true) { | 1433 | while (true) { |
| 1434 | const tag: Node.Tag = switch (p.token_tags[p.tok_i]) { | 1434 | const tag: Node.Tag = switch (p.token_tags[p.tok_i]) { |
| 1435 | .AngleBracketAngleBracketLeft => .BitShiftLeft, | 1435 | .angle_bracket_angle_bracket_left => .BitShiftLeft, |
| 1436 | .AngleBracketAngleBracketRight => .BitShiftRight, | 1436 | .angle_bracket_angle_bracket_right => .BitShiftRight, |
| 1437 | else => return res, | 1437 | else => return res, |
| 1438 | }; | 1438 | }; |
| 1439 | res = try p.addNode(.{ | 1439 | res = try p.addNode(.{ |
| ... | @@ -1469,11 +1469,11 @@ const Parser = struct { | ... | @@ -1469,11 +1469,11 @@ const Parser = struct { |
| 1469 | 1469 | ||
| 1470 | while (true) { | 1470 | while (true) { |
| 1471 | const tag: Node.Tag = switch (p.token_tags[p.tok_i]) { | 1471 | const tag: Node.Tag = switch (p.token_tags[p.tok_i]) { |
| 1472 | .Plus => .Add, | 1472 | .plus => .Add, |
| 1473 | .Minus => .Sub, | 1473 | .minus => .Sub, |
| 1474 | .PlusPlus => .ArrayCat, | 1474 | .plus_plus => .ArrayCat, |
| 1475 | .PlusPercent => .AddWrap, | 1475 | .plus_percent => .AddWrap, |
| 1476 | .MinusPercent => .SubWrap, | 1476 | .minus_percent => .SubWrap, |
| 1477 | else => return res, | 1477 | else => return res, |
| 1478 | }; | 1478 | }; |
| 1479 | res = try p.addNode(.{ | 1479 | res = try p.addNode(.{ |
| ... | @@ -1509,12 +1509,12 @@ const Parser = struct { | ... | @@ -1509,12 +1509,12 @@ const Parser = struct { |
| 1509 | 1509 | ||
| 1510 | while (true) { | 1510 | while (true) { |
| 1511 | const tag: Node.Tag = switch (p.token_tags[p.tok_i]) { | 1511 | const tag: Node.Tag = switch (p.token_tags[p.tok_i]) { |
| 1512 | .PipePipe => .MergeErrorSets, | 1512 | .pipe_pipe => .MergeErrorSets, |
| 1513 | .Asterisk => .Mul, | 1513 | .asterisk => .Mul, |
| 1514 | .Slash => .Div, | 1514 | .slash => .Div, |
| 1515 | .Percent => .Mod, | 1515 | .percent => .Mod, |
| 1516 | .AsteriskAsterisk => .ArrayMult, | 1516 | .asterisk_asterisk => .ArrayMult, |
| 1517 | .AsteriskPercent => .MulWrap, | 1517 | .asterisk_percent => .MulWrap, |
| 1518 | else => return res, | 1518 | else => return res, |
| 1519 | }; | 1519 | }; |
| 1520 | res = try p.addNode(.{ | 1520 | res = try p.addNode(.{ |
| ... | @@ -1547,13 +1547,13 @@ const Parser = struct { | ... | @@ -1547,13 +1547,13 @@ const Parser = struct { |
| 1547 | /// / KEYWORD_await | 1547 | /// / KEYWORD_await |
| 1548 | fn parsePrefixExpr(p: *Parser) Error!Node.Index { | 1548 | fn parsePrefixExpr(p: *Parser) Error!Node.Index { |
| 1549 | const tag: Node.Tag = switch (p.token_tags[p.tok_i]) { | 1549 | const tag: Node.Tag = switch (p.token_tags[p.tok_i]) { |
| 1550 | .Bang => .BoolNot, | 1550 | .bang => .BoolNot, |
| 1551 | .Minus => .Negation, | 1551 | .minus => .Negation, |
| 1552 | .Tilde => .BitNot, | 1552 | .tilde => .BitNot, |
| 1553 | .MinusPercent => .NegationWrap, | 1553 | .minus_percent => .NegationWrap, |
| 1554 | .Ampersand => .AddressOf, | 1554 | .ampersand => .AddressOf, |
| 1555 | .Keyword_try => .Try, | 1555 | .keyword_try => .Try, |
| 1556 | .Keyword_await => .Await, | 1556 | .keyword_await => .Await, |
| 1557 | else => return p.parsePrimaryExpr(), | 1557 | else => return p.parsePrimaryExpr(), |
| 1558 | }; | 1558 | }; |
| 1559 | return p.addNode(.{ | 1559 | return p.addNode(.{ |
| ... | @@ -1587,7 +1587,7 @@ const Parser = struct { | ... | @@ -1587,7 +1587,7 @@ const Parser = struct { |
| 1587 | /// ArrayTypeStart <- LBRACKET Expr? (COLON Expr)? RBRACKET | 1587 | /// ArrayTypeStart <- LBRACKET Expr? (COLON Expr)? RBRACKET |
| 1588 | fn parseTypeExpr(p: *Parser) Error!Node.Index { | 1588 | fn parseTypeExpr(p: *Parser) Error!Node.Index { |
| 1589 | switch (p.token_tags[p.tok_i]) { | 1589 | switch (p.token_tags[p.tok_i]) { |
| 1590 | .QuestionMark => return p.addNode(.{ | 1590 | .question_mark => return p.addNode(.{ |
| 1591 | .tag = .OptionalType, | 1591 | .tag = .OptionalType, |
| 1592 | .main_token = p.nextToken(), | 1592 | .main_token = p.nextToken(), |
| 1593 | .data = .{ | 1593 | .data = .{ |
| ... | @@ -1595,8 +1595,8 @@ const Parser = struct { | ... | @@ -1595,8 +1595,8 @@ const Parser = struct { |
| 1595 | .rhs = undefined, | 1595 | .rhs = undefined, |
| 1596 | }, | 1596 | }, |
| 1597 | }), | 1597 | }), |
| 1598 | .Keyword_anyframe => switch (p.token_tags[p.tok_i + 1]) { | 1598 | .keyword_anyframe => switch (p.token_tags[p.tok_i + 1]) { |
| 1599 | .Arrow => return p.addNode(.{ | 1599 | .arrow => return p.addNode(.{ |
| 1600 | .tag = .AnyFrameType, | 1600 | .tag = .AnyFrameType, |
| 1601 | .main_token = p.nextToken(), | 1601 | .main_token = p.nextToken(), |
| 1602 | .data = .{ | 1602 | .data = .{ |
| ... | @@ -1606,7 +1606,7 @@ const Parser = struct { | ... | @@ -1606,7 +1606,7 @@ const Parser = struct { |
| 1606 | }), | 1606 | }), |
| 1607 | else => return p.parseErrorUnionExpr(), | 1607 | else => return p.parseErrorUnionExpr(), |
| 1608 | }, | 1608 | }, |
| 1609 | .Asterisk => { | 1609 | .asterisk => { |
| 1610 | const asterisk = p.nextToken(); | 1610 | const asterisk = p.nextToken(); |
| 1611 | const mods = try p.parsePtrModifiers(); | 1611 | const mods = try p.parsePtrModifiers(); |
| 1612 | const elem_type = try p.expectTypeExpr(); | 1612 | const elem_type = try p.expectTypeExpr(); |
| ... | @@ -1635,7 +1635,7 @@ const Parser = struct { | ... | @@ -1635,7 +1635,7 @@ const Parser = struct { |
| 1635 | }); | 1635 | }); |
| 1636 | } | 1636 | } |
| 1637 | }, | 1637 | }, |
| 1638 | .AsteriskAsterisk => { | 1638 | .asterisk_asterisk => { |
| 1639 | const asterisk = p.nextToken(); | 1639 | const asterisk = p.nextToken(); |
| 1640 | const mods = try p.parsePtrModifiers(); | 1640 | const mods = try p.parsePtrModifiers(); |
| 1641 | const elem_type = try p.expectTypeExpr(); | 1641 | const elem_type = try p.expectTypeExpr(); |
| ... | @@ -1674,13 +1674,13 @@ const Parser = struct { | ... | @@ -1674,13 +1674,13 @@ const Parser = struct { |
| 1674 | }, | 1674 | }, |
| 1675 | }); | 1675 | }); |
| 1676 | }, | 1676 | }, |
| 1677 | .LBracket => switch (p.token_tags[p.tok_i + 1]) { | 1677 | .l_bracket => switch (p.token_tags[p.tok_i + 1]) { |
| 1678 | .Asterisk => { | 1678 | .asterisk => { |
| 1679 | const lbracket = p.nextToken(); | 1679 | const lbracket = p.nextToken(); |
| 1680 | const asterisk = p.nextToken(); | 1680 | const asterisk = p.nextToken(); |
| 1681 | var sentinel: Node.Index = 0; | 1681 | var sentinel: Node.Index = 0; |
| 1682 | prefix: { | 1682 | prefix: { |
| 1683 | if (p.eatToken(.Identifier)) |ident| { | 1683 | if (p.eatToken(.identifier)) |ident| { |
| 1684 | const token_slice = p.source[p.token_starts[ident]..][0..2]; | 1684 | const token_slice = p.source[p.token_starts[ident]..][0..2]; |
| 1685 | if (!std.mem.eql(u8, token_slice, "c]")) { | 1685 | if (!std.mem.eql(u8, token_slice, "c]")) { |
| 1686 | p.tok_i -= 1; | 1686 | p.tok_i -= 1; |
| ... | @@ -1688,11 +1688,11 @@ const Parser = struct { | ... | @@ -1688,11 +1688,11 @@ const Parser = struct { |
| 1688 | break :prefix; | 1688 | break :prefix; |
| 1689 | } | 1689 | } |
| 1690 | } | 1690 | } |
| 1691 | if (p.eatToken(.Colon)) |_| { | 1691 | if (p.eatToken(.colon)) |_| { |
| 1692 | sentinel = try p.expectExpr(); | 1692 | sentinel = try p.expectExpr(); |
| 1693 | } | 1693 | } |
| 1694 | } | 1694 | } |
| 1695 | _ = try p.expectToken(.RBracket); | 1695 | _ = try p.expectToken(.r_bracket); |
| 1696 | const mods = try p.parsePtrModifiers(); | 1696 | const mods = try p.parsePtrModifiers(); |
| 1697 | const elem_type = try p.expectTypeExpr(); | 1697 | const elem_type = try p.expectTypeExpr(); |
| 1698 | if (mods.bit_range_start == 0) { | 1698 | if (mods.bit_range_start == 0) { |
| ... | @@ -1746,11 +1746,11 @@ const Parser = struct { | ... | @@ -1746,11 +1746,11 @@ const Parser = struct { |
| 1746 | else => { | 1746 | else => { |
| 1747 | const lbracket = p.nextToken(); | 1747 | const lbracket = p.nextToken(); |
| 1748 | const len_expr = try p.parseExpr(); | 1748 | const len_expr = try p.parseExpr(); |
| 1749 | const sentinel: Node.Index = if (p.eatToken(.Colon)) |_| | 1749 | const sentinel: Node.Index = if (p.eatToken(.colon)) |_| |
| 1750 | try p.expectExpr() | 1750 | try p.expectExpr() |
| 1751 | else | 1751 | else |
| 1752 | 0; | 1752 | 0; |
| 1753 | _ = try p.expectToken(.RBracket); | 1753 | _ = try p.expectToken(.r_bracket); |
| 1754 | const mods = try p.parsePtrModifiers(); | 1754 | const mods = try p.parsePtrModifiers(); |
| 1755 | const elem_type = try p.expectTypeExpr(); | 1755 | const elem_type = try p.expectTypeExpr(); |
| 1756 | if (mods.bit_range_start != 0) { | 1756 | if (mods.bit_range_start != 0) { |
| ... | @@ -1849,9 +1849,9 @@ const Parser = struct { | ... | @@ -1849,9 +1849,9 @@ const Parser = struct { |
| 1849 | /// / CurlySuffixExpr | 1849 | /// / CurlySuffixExpr |
| 1850 | fn parsePrimaryExpr(p: *Parser) !Node.Index { | 1850 | fn parsePrimaryExpr(p: *Parser) !Node.Index { |
| 1851 | switch (p.token_tags[p.tok_i]) { | 1851 | switch (p.token_tags[p.tok_i]) { |
| 1852 | .Keyword_asm => return p.expectAsmExpr(), | 1852 | .keyword_asm => return p.expectAsmExpr(), |
| 1853 | .Keyword_if => return p.parseIfExpr(), | 1853 | .keyword_if => return p.parseIfExpr(), |
| 1854 | .Keyword_break => { | 1854 | .keyword_break => { |
| 1855 | p.tok_i += 1; | 1855 | p.tok_i += 1; |
| 1856 | return p.addNode(.{ | 1856 | return p.addNode(.{ |
| 1857 | .tag = .Break, | 1857 | .tag = .Break, |
| ... | @@ -1862,7 +1862,7 @@ const Parser = struct { | ... | @@ -1862,7 +1862,7 @@ const Parser = struct { |
| 1862 | }, | 1862 | }, |
| 1863 | }); | 1863 | }); |
| 1864 | }, | 1864 | }, |
| 1865 | .Keyword_continue => { | 1865 | .keyword_continue => { |
| 1866 | p.tok_i += 1; | 1866 | p.tok_i += 1; |
| 1867 | return p.addNode(.{ | 1867 | return p.addNode(.{ |
| 1868 | .tag = .Continue, | 1868 | .tag = .Continue, |
| ... | @@ -1873,7 +1873,7 @@ const Parser = struct { | ... | @@ -1873,7 +1873,7 @@ const Parser = struct { |
| 1873 | }, | 1873 | }, |
| 1874 | }); | 1874 | }); |
| 1875 | }, | 1875 | }, |
| 1876 | .Keyword_comptime => { | 1876 | .keyword_comptime => { |
| 1877 | p.tok_i += 1; | 1877 | p.tok_i += 1; |
| 1878 | return p.addNode(.{ | 1878 | return p.addNode(.{ |
| 1879 | .tag = .Comptime, | 1879 | .tag = .Comptime, |
| ... | @@ -1884,7 +1884,7 @@ const Parser = struct { | ... | @@ -1884,7 +1884,7 @@ const Parser = struct { |
| 1884 | }, | 1884 | }, |
| 1885 | }); | 1885 | }); |
| 1886 | }, | 1886 | }, |
| 1887 | .Keyword_nosuspend => { | 1887 | .keyword_nosuspend => { |
| 1888 | p.tok_i += 1; | 1888 | p.tok_i += 1; |
| 1889 | return p.addNode(.{ | 1889 | return p.addNode(.{ |
| 1890 | .tag = .Nosuspend, | 1890 | .tag = .Nosuspend, |
| ... | @@ -1895,7 +1895,7 @@ const Parser = struct { | ... | @@ -1895,7 +1895,7 @@ const Parser = struct { |
| 1895 | }, | 1895 | }, |
| 1896 | }); | 1896 | }); |
| 1897 | }, | 1897 | }, |
| 1898 | .Keyword_resume => { | 1898 | .keyword_resume => { |
| 1899 | p.tok_i += 1; | 1899 | p.tok_i += 1; |
| 1900 | return p.addNode(.{ | 1900 | return p.addNode(.{ |
| 1901 | .tag = .Resume, | 1901 | .tag = .Resume, |
| ... | @@ -1906,7 +1906,7 @@ const Parser = struct { | ... | @@ -1906,7 +1906,7 @@ const Parser = struct { |
| 1906 | }, | 1906 | }, |
| 1907 | }); | 1907 | }); |
| 1908 | }, | 1908 | }, |
| 1909 | .Keyword_return => { | 1909 | .keyword_return => { |
| 1910 | p.tok_i += 1; | 1910 | p.tok_i += 1; |
| 1911 | return p.addNode(.{ | 1911 | return p.addNode(.{ |
| 1912 | .tag = .Return, | 1912 | .tag = .Return, |
| ... | @@ -1917,28 +1917,28 @@ const Parser = struct { | ... | @@ -1917,28 +1917,28 @@ const Parser = struct { |
| 1917 | }, | 1917 | }, |
| 1918 | }); | 1918 | }); |
| 1919 | }, | 1919 | }, |
| 1920 | .Identifier => { | 1920 | .identifier => { |
| 1921 | if (p.token_tags[p.tok_i + 1] == .Colon) { | 1921 | if (p.token_tags[p.tok_i + 1] == .colon) { |
| 1922 | switch (p.token_tags[p.tok_i + 2]) { | 1922 | switch (p.token_tags[p.tok_i + 2]) { |
| 1923 | .Keyword_inline => { | 1923 | .keyword_inline => { |
| 1924 | p.tok_i += 3; | 1924 | p.tok_i += 3; |
| 1925 | switch (p.token_tags[p.tok_i]) { | 1925 | switch (p.token_tags[p.tok_i]) { |
| 1926 | .Keyword_for => return p.parseForExpr(), | 1926 | .keyword_for => return p.parseForExpr(), |
| 1927 | .Keyword_while => return p.parseWhileExpr(), | 1927 | .keyword_while => return p.parseWhileExpr(), |
| 1928 | else => return p.fail(.{ | 1928 | else => return p.fail(.{ |
| 1929 | .ExpectedInlinable = .{ .token = p.tok_i }, | 1929 | .ExpectedInlinable = .{ .token = p.tok_i }, |
| 1930 | }), | 1930 | }), |
| 1931 | } | 1931 | } |
| 1932 | }, | 1932 | }, |
| 1933 | .Keyword_for => { | 1933 | .keyword_for => { |
| 1934 | p.tok_i += 2; | 1934 | p.tok_i += 2; |
| 1935 | return p.parseForExpr(); | 1935 | return p.parseForExpr(); |
| 1936 | }, | 1936 | }, |
| 1937 | .Keyword_while => { | 1937 | .keyword_while => { |
| 1938 | p.tok_i += 2; | 1938 | p.tok_i += 2; |
| 1939 | return p.parseWhileExpr(); | 1939 | return p.parseWhileExpr(); |
| 1940 | }, | 1940 | }, |
| 1941 | .LBrace => { | 1941 | .l_brace => { |
| 1942 | p.tok_i += 2; | 1942 | p.tok_i += 2; |
| 1943 | return p.parseBlock(); | 1943 | return p.parseBlock(); |
| 1944 | }, | 1944 | }, |
| ... | @@ -1948,19 +1948,19 @@ const Parser = struct { | ... | @@ -1948,19 +1948,19 @@ const Parser = struct { |
| 1948 | return p.parseCurlySuffixExpr(); | 1948 | return p.parseCurlySuffixExpr(); |
| 1949 | } | 1949 | } |
| 1950 | }, | 1950 | }, |
| 1951 | .Keyword_inline => { | 1951 | .keyword_inline => { |
| 1952 | p.tok_i += 2; | 1952 | p.tok_i += 2; |
| 1953 | switch (p.token_tags[p.tok_i]) { | 1953 | switch (p.token_tags[p.tok_i]) { |
| 1954 | .Keyword_for => return p.parseForExpr(), | 1954 | .keyword_for => return p.parseForExpr(), |
| 1955 | .Keyword_while => return p.parseWhileExpr(), | 1955 | .keyword_while => return p.parseWhileExpr(), |
| 1956 | else => return p.fail(.{ | 1956 | else => return p.fail(.{ |
| 1957 | .ExpectedInlinable = .{ .token = p.tok_i }, | 1957 | .ExpectedInlinable = .{ .token = p.tok_i }, |
| 1958 | }), | 1958 | }), |
| 1959 | } | 1959 | } |
| 1960 | }, | 1960 | }, |
| 1961 | .Keyword_for => return p.parseForExpr(), | 1961 | .keyword_for => return p.parseForExpr(), |
| 1962 | .Keyword_while => return p.parseWhileExpr(), | 1962 | .keyword_while => return p.parseWhileExpr(), |
| 1963 | .LBrace => return p.parseBlock(), | 1963 | .l_brace => return p.parseBlock(), |
| 1964 | else => return p.parseCurlySuffixExpr(), | 1964 | else => return p.parseCurlySuffixExpr(), |
| 1965 | } | 1965 | } |
| 1966 | } | 1966 | } |
| ... | @@ -1972,9 +1972,9 @@ const Parser = struct { | ... | @@ -1972,9 +1972,9 @@ const Parser = struct { |
| 1972 | 1972 | ||
| 1973 | /// Block <- LBRACE Statement* RBRACE | 1973 | /// Block <- LBRACE Statement* RBRACE |
| 1974 | fn parseBlock(p: *Parser) !Node.Index { | 1974 | 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; |
| 1976 | 1976 | ||
| 1977 | if (p.eatToken(.RBrace)) |_| { | 1977 | if (p.eatToken(.r_brace)) |_| { |
| 1978 | return p.addNode(.{ | 1978 | return p.addNode(.{ |
| 1979 | .tag = .BlockTwo, | 1979 | .tag = .BlockTwo, |
| 1980 | .main_token = lbrace, | 1980 | .main_token = lbrace, |
| ... | @@ -1986,8 +1986,8 @@ const Parser = struct { | ... | @@ -1986,8 +1986,8 @@ const Parser = struct { |
| 1986 | } | 1986 | } |
| 1987 | 1987 | ||
| 1988 | const stmt_one = try p.expectStatementRecoverable(); | 1988 | const stmt_one = try p.expectStatementRecoverable(); |
| 1989 | if (p.eatToken(.RBrace)) |_| { | 1989 | if (p.eatToken(.r_brace)) |_| { |
| 1990 | const semicolon = p.token_tags[p.tok_i - 2] == .Semicolon; | 1990 | const semicolon = p.token_tags[p.tok_i - 2] == .semicolon; |
| 1991 | return p.addNode(.{ | 1991 | return p.addNode(.{ |
| 1992 | .tag = if (semicolon) .BlockTwoSemicolon else .BlockTwo, | 1992 | .tag = if (semicolon) .BlockTwoSemicolon else .BlockTwo, |
| 1993 | .main_token = lbrace, | 1993 | .main_token = lbrace, |
| ... | @@ -1998,8 +1998,8 @@ const Parser = struct { | ... | @@ -1998,8 +1998,8 @@ const Parser = struct { |
| 1998 | }); | 1998 | }); |
| 1999 | } | 1999 | } |
| 2000 | const stmt_two = try p.expectStatementRecoverable(); | 2000 | const stmt_two = try p.expectStatementRecoverable(); |
| 2001 | if (p.eatToken(.RBrace)) |_| { | 2001 | if (p.eatToken(.r_brace)) |_| { |
| 2002 | const semicolon = p.token_tags[p.tok_i - 2] == .Semicolon; | 2002 | const semicolon = p.token_tags[p.tok_i - 2] == .semicolon; |
| 2003 | return p.addNode(.{ | 2003 | return p.addNode(.{ |
| 2004 | .tag = if (semicolon) .BlockTwoSemicolon else .BlockTwo, | 2004 | .tag = if (semicolon) .BlockTwoSemicolon else .BlockTwo, |
| 2005 | .main_token = lbrace, | 2005 | .main_token = lbrace, |
| ... | @@ -2013,16 +2013,16 @@ const Parser = struct { | ... | @@ -2013,16 +2013,16 @@ const Parser = struct { |
| 2013 | var statements = std.ArrayList(Node.Index).init(p.gpa); | 2013 | var statements = std.ArrayList(Node.Index).init(p.gpa); |
| 2014 | defer statements.deinit(); | 2014 | defer statements.deinit(); |
| 2015 | 2015 | ||
| 2016 | try statements.appendSlice(&[_]Node.Index{ stmt_one, stmt_two }); | 2016 | try statements.appendSlice(&.{ stmt_one, stmt_two }); |
| 2017 | 2017 | ||
| 2018 | while (true) { | 2018 | while (true) { |
| 2019 | const statement = try p.expectStatementRecoverable(); | 2019 | const statement = try p.expectStatementRecoverable(); |
| 2020 | if (statement == 0) break; | 2020 | if (statement == 0) break; |
| 2021 | try statements.append(statement); | 2021 | 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; |
| 2023 | } | 2023 | } |
| 2024 | _ = try p.expectToken(.RBrace); | 2024 | _ = try p.expectToken(.r_brace); |
| 2025 | const semicolon = p.token_tags[p.tok_i - 2] == .Semicolon; | 2025 | const semicolon = p.token_tags[p.tok_i - 2] == .semicolon; |
| 2026 | const statements_span = try p.listToSpan(statements.items); | 2026 | const statements_span = try p.listToSpan(statements.items); |
| 2027 | return p.addNode(.{ | 2027 | return p.addNode(.{ |
| 2028 | .tag = if (semicolon) .BlockSemicolon else .Block, | 2028 | .tag = if (semicolon) .BlockSemicolon else .Block, |
| ... | @@ -2037,14 +2037,14 @@ const Parser = struct { | ... | @@ -2037,14 +2037,14 @@ const Parser = struct { |
| 2037 | /// ForPrefix <- KEYWORD_for LPAREN Expr RPAREN PtrIndexPayload | 2037 | /// ForPrefix <- KEYWORD_for LPAREN Expr RPAREN PtrIndexPayload |
| 2038 | /// ForExpr <- ForPrefix Expr (KEYWORD_else Expr)? | 2038 | /// ForExpr <- ForPrefix Expr (KEYWORD_else Expr)? |
| 2039 | fn parseForExpr(p: *Parser) !Node.Index { | 2039 | fn parseForExpr(p: *Parser) !Node.Index { |
| 2040 | const for_token = p.eatToken(.Keyword_for) orelse return null_node; | 2040 | const for_token = p.eatToken(.keyword_for) orelse return null_node; |
| 2041 | _ = try p.expectToken(.LParen); | 2041 | _ = try p.expectToken(.l_paren); |
| 2042 | const array_expr = try p.expectExpr(); | 2042 | const array_expr = try p.expectExpr(); |
| 2043 | _ = try p.expectToken(.RParen); | 2043 | _ = try p.expectToken(.r_paren); |
| 2044 | _ = try p.parsePtrIndexPayload(); | 2044 | _ = try p.parsePtrIndexPayload(); |
| 2045 | 2045 | ||
| 2046 | const then_expr = try p.expectExpr(); | 2046 | const then_expr = try p.expectExpr(); |
| 2047 | const else_token = p.eatToken(.Keyword_else) orelse { | 2047 | const else_token = p.eatToken(.keyword_else) orelse { |
| 2048 | return p.addNode(.{ | 2048 | return p.addNode(.{ |
| 2049 | .tag = .ForSimple, | 2049 | .tag = .ForSimple, |
| 2050 | .main_token = for_token, | 2050 | .main_token = for_token, |
| ... | @@ -2071,15 +2071,15 @@ const Parser = struct { | ... | @@ -2071,15 +2071,15 @@ const Parser = struct { |
| 2071 | /// WhilePrefix <- KEYWORD_while LPAREN Expr RPAREN PtrPayload? WhileContinueExpr? | 2071 | /// WhilePrefix <- KEYWORD_while LPAREN Expr RPAREN PtrPayload? WhileContinueExpr? |
| 2072 | /// WhileExpr <- WhilePrefix Expr (KEYWORD_else Payload? Expr)? | 2072 | /// WhileExpr <- WhilePrefix Expr (KEYWORD_else Payload? Expr)? |
| 2073 | fn parseWhileExpr(p: *Parser) !Node.Index { | 2073 | fn parseWhileExpr(p: *Parser) !Node.Index { |
| 2074 | const while_token = p.eatToken(.Keyword_while) orelse return null_node; | 2074 | const while_token = p.eatToken(.keyword_while) orelse return null_node; |
| 2075 | _ = try p.expectToken(.LParen); | 2075 | _ = try p.expectToken(.l_paren); |
| 2076 | const condition = try p.expectExpr(); | 2076 | const condition = try p.expectExpr(); |
| 2077 | _ = try p.expectToken(.RParen); | 2077 | _ = try p.expectToken(.r_paren); |
| 2078 | const then_payload = try p.parsePtrPayload(); | 2078 | const then_payload = try p.parsePtrPayload(); |
| 2079 | const cont_expr = try p.parseWhileContinueExpr(); | 2079 | const cont_expr = try p.parseWhileContinueExpr(); |
| 2080 | 2080 | ||
| 2081 | const then_expr = try p.expectExpr(); | 2081 | const then_expr = try p.expectExpr(); |
| 2082 | const else_token = p.eatToken(.Keyword_else) orelse { | 2082 | const else_token = p.eatToken(.keyword_else) orelse { |
| 2083 | if (cont_expr == 0) { | 2083 | if (cont_expr == 0) { |
| 2084 | return p.addNode(.{ | 2084 | return p.addNode(.{ |
| 2085 | .tag = .WhileSimple, | 2085 | .tag = .WhileSimple, |
| ... | @@ -2127,12 +2127,12 @@ const Parser = struct { | ... | @@ -2127,12 +2127,12 @@ const Parser = struct { |
| 2127 | fn parseCurlySuffixExpr(p: *Parser) !Node.Index { | 2127 | fn parseCurlySuffixExpr(p: *Parser) !Node.Index { |
| 2128 | const lhs = try p.parseTypeExpr(); | 2128 | const lhs = try p.parseTypeExpr(); |
| 2129 | if (lhs == 0) return null_node; | 2129 | 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; |
| 2131 | 2131 | ||
| 2132 | // If there are 0 or 1 items, we can use ArrayInitOne/StructInitOne; | 2132 | // If there are 0 or 1 items, we can use ArrayInitOne/StructInitOne; |
| 2133 | // otherwise we use the full ArrayInit/StructInit. | 2133 | // otherwise we use the full ArrayInit/StructInit. |
| 2134 | 2134 | ||
| 2135 | if (p.eatToken(.RBrace)) |_| { | 2135 | if (p.eatToken(.r_brace)) |_| { |
| 2136 | return p.addNode(.{ | 2136 | return p.addNode(.{ |
| 2137 | .tag = .StructInitOne, | 2137 | .tag = .StructInitOne, |
| 2138 | .main_token = lbrace, | 2138 | .main_token = lbrace, |
| ... | @@ -2144,8 +2144,8 @@ const Parser = struct { | ... | @@ -2144,8 +2144,8 @@ const Parser = struct { |
| 2144 | } | 2144 | } |
| 2145 | const field_init = try p.parseFieldInit(); | 2145 | const field_init = try p.parseFieldInit(); |
| 2146 | if (field_init != 0) { | 2146 | if (field_init != 0) { |
| 2147 | const comma_one = p.eatToken(.Comma); | 2147 | const comma_one = p.eatToken(.comma); |
| 2148 | if (p.eatToken(.RBrace)) |_| { | 2148 | if (p.eatToken(.r_brace)) |_| { |
| 2149 | return p.addNode(.{ | 2149 | return p.addNode(.{ |
| 2150 | .tag = if (comma_one != null) .StructInitOneComma else .StructInitOne, | 2150 | .tag = if (comma_one != null) .StructInitOneComma else .StructInitOne, |
| 2151 | .main_token = lbrace, | 2151 | .main_token = lbrace, |
| ... | @@ -2166,17 +2166,17 @@ const Parser = struct { | ... | @@ -2166,17 +2166,17 @@ const Parser = struct { |
| 2166 | try init_list.append(next); | 2166 | try init_list.append(next); |
| 2167 | 2167 | ||
| 2168 | switch (p.token_tags[p.nextToken()]) { | 2168 | switch (p.token_tags[p.nextToken()]) { |
| 2169 | .Comma => { | 2169 | .comma => { |
| 2170 | if (p.eatToken(.RBrace)) |_| break; | 2170 | if (p.eatToken(.r_brace)) |_| break; |
| 2171 | continue; | 2171 | continue; |
| 2172 | }, | 2172 | }, |
| 2173 | .RBrace => break, | 2173 | .r_brace => break, |
| 2174 | .Colon, .RParen, .RBracket => { | 2174 | .colon, .r_paren, .r_bracket => { |
| 2175 | p.tok_i -= 1; | 2175 | p.tok_i -= 1; |
| 2176 | return p.fail(.{ | 2176 | return p.fail(.{ |
| 2177 | .ExpectedToken = .{ | 2177 | .ExpectedToken = .{ |
| 2178 | .token = p.tok_i, | 2178 | .token = p.tok_i, |
| 2179 | .expected_id = .RBrace, | 2179 | .expected_id = .r_brace, |
| 2180 | }, | 2180 | }, |
| 2181 | }); | 2181 | }); |
| 2182 | }, | 2182 | }, |
| ... | @@ -2185,14 +2185,14 @@ const Parser = struct { | ... | @@ -2185,14 +2185,14 @@ const Parser = struct { |
| 2185 | // give an error but continue parsing this list. | 2185 | // give an error but continue parsing this list. |
| 2186 | p.tok_i -= 1; | 2186 | p.tok_i -= 1; |
| 2187 | try p.warn(.{ | 2187 | try p.warn(.{ |
| 2188 | .ExpectedToken = .{ .token = p.tok_i, .expected_id = .Comma }, | 2188 | .ExpectedToken = .{ .token = p.tok_i, .expected_id = .comma }, |
| 2189 | }); | 2189 | }); |
| 2190 | }, | 2190 | }, |
| 2191 | } | 2191 | } |
| 2192 | } | 2192 | } |
| 2193 | const span = try p.listToSpan(init_list.items); | 2193 | const span = try p.listToSpan(init_list.items); |
| 2194 | return p.addNode(.{ | 2194 | 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, |
| 2196 | .main_token = lbrace, | 2196 | .main_token = lbrace, |
| 2197 | .data = .{ | 2197 | .data = .{ |
| 2198 | .lhs = lhs, | 2198 | .lhs = lhs, |
| ... | @@ -2205,8 +2205,8 @@ const Parser = struct { | ... | @@ -2205,8 +2205,8 @@ const Parser = struct { |
| 2205 | } | 2205 | } |
| 2206 | 2206 | ||
| 2207 | const elem_init = try p.expectExpr(); | 2207 | const elem_init = try p.expectExpr(); |
| 2208 | const comma_one = p.eatToken(.Comma); | 2208 | const comma_one = p.eatToken(.comma); |
| 2209 | if (p.eatToken(.RBrace)) |_| { | 2209 | if (p.eatToken(.r_brace)) |_| { |
| 2210 | return p.addNode(.{ | 2210 | return p.addNode(.{ |
| 2211 | .tag = if (comma_one != null) .ArrayInitOneComma else .ArrayInitOne, | 2211 | .tag = if (comma_one != null) .ArrayInitOneComma else .ArrayInitOne, |
| 2212 | .main_token = lbrace, | 2212 | .main_token = lbrace, |
| ... | @@ -2218,7 +2218,7 @@ const Parser = struct { | ... | @@ -2218,7 +2218,7 @@ const Parser = struct { |
| 2218 | } | 2218 | } |
| 2219 | if (comma_one == null) { | 2219 | if (comma_one == null) { |
| 2220 | try p.warn(.{ | 2220 | try p.warn(.{ |
| 2221 | .ExpectedToken = .{ .token = p.tok_i, .expected_id = .Comma }, | 2221 | .ExpectedToken = .{ .token = p.tok_i, .expected_id = .comma }, |
| 2222 | }); | 2222 | }); |
| 2223 | } | 2223 | } |
| 2224 | 2224 | ||
| ... | @@ -2231,12 +2231,12 @@ const Parser = struct { | ... | @@ -2231,12 +2231,12 @@ const Parser = struct { |
| 2231 | var next = try p.parseExpr(); | 2231 | var next = try p.parseExpr(); |
| 2232 | while (next != 0) : (next = try p.parseExpr()) { | 2232 | while (next != 0) : (next = try p.parseExpr()) { |
| 2233 | try init_list.append(next); | 2233 | try init_list.append(next); |
| 2234 | if (p.eatToken(.Comma) == null) { | 2234 | if (p.eatToken(.comma) == null) { |
| 2235 | trailing_comma = false; | 2235 | trailing_comma = false; |
| 2236 | break; | 2236 | break; |
| 2237 | } | 2237 | } |
| 2238 | } | 2238 | } |
| 2239 | _ = try p.expectToken(.RBrace); | 2239 | _ = try p.expectToken(.r_brace); |
| 2240 | const span = try p.listToSpan(init_list.items); | 2240 | const span = try p.listToSpan(init_list.items); |
| 2241 | return p.addNode(.{ | 2241 | return p.addNode(.{ |
| 2242 | .tag = if (trailing_comma) .ArrayInitComma else .ArrayInit, | 2242 | .tag = if (trailing_comma) .ArrayInitComma else .ArrayInit, |
| ... | @@ -2255,7 +2255,7 @@ const Parser = struct { | ... | @@ -2255,7 +2255,7 @@ const Parser = struct { |
| 2255 | fn parseErrorUnionExpr(p: *Parser) !Node.Index { | 2255 | fn parseErrorUnionExpr(p: *Parser) !Node.Index { |
| 2256 | const suffix_expr = try p.parseSuffixExpr(); | 2256 | const suffix_expr = try p.parseSuffixExpr(); |
| 2257 | if (suffix_expr == 0) return null_node; | 2257 | 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; |
| 2259 | return p.addNode(.{ | 2259 | return p.addNode(.{ |
| 2260 | .tag = .ErrorUnion, | 2260 | .tag = .ErrorUnion, |
| 2261 | .main_token = bang, | 2261 | .main_token = bang, |
| ... | @@ -2272,7 +2272,7 @@ const Parser = struct { | ... | @@ -2272,7 +2272,7 @@ const Parser = struct { |
| 2272 | /// FnCallArguments <- LPAREN ExprList RPAREN | 2272 | /// FnCallArguments <- LPAREN ExprList RPAREN |
| 2273 | /// ExprList <- (Expr COMMA)* Expr? | 2273 | /// ExprList <- (Expr COMMA)* Expr? |
| 2274 | fn parseSuffixExpr(p: *Parser) !Node.Index { | 2274 | fn parseSuffixExpr(p: *Parser) !Node.Index { |
| 2275 | if (p.eatToken(.Keyword_async)) |async_token| { | 2275 | if (p.eatToken(.keyword_async)) |async_token| { |
| 2276 | var res = try p.expectPrimaryTypeExpr(); | 2276 | var res = try p.expectPrimaryTypeExpr(); |
| 2277 | 2277 | ||
| 2278 | while (true) { | 2278 | while (true) { |
| ... | @@ -2280,11 +2280,11 @@ const Parser = struct { | ... | @@ -2280,11 +2280,11 @@ const Parser = struct { |
| 2280 | if (node == 0) break; | 2280 | if (node == 0) break; |
| 2281 | res = node; | 2281 | res = node; |
| 2282 | } | 2282 | } |
| 2283 | const lparen = (try p.expectTokenRecoverable(.LParen)) orelse { | 2283 | const lparen = (try p.expectTokenRecoverable(.l_paren)) orelse { |
| 2284 | try p.warn(.{ .ExpectedParamList = .{ .token = p.tok_i } }); | 2284 | try p.warn(.{ .ExpectedParamList = .{ .token = p.tok_i } }); |
| 2285 | return res; | 2285 | return res; |
| 2286 | }; | 2286 | }; |
| 2287 | if (p.eatToken(.RParen)) |_| { | 2287 | if (p.eatToken(.r_paren)) |_| { |
| 2288 | return p.addNode(.{ | 2288 | return p.addNode(.{ |
| 2289 | .tag = .AsyncCallOne, | 2289 | .tag = .AsyncCallOne, |
| 2290 | .main_token = lparen, | 2290 | .main_token = lparen, |
| ... | @@ -2295,8 +2295,8 @@ const Parser = struct { | ... | @@ -2295,8 +2295,8 @@ const Parser = struct { |
| 2295 | }); | 2295 | }); |
| 2296 | } | 2296 | } |
| 2297 | const param_one = try p.expectExpr(); | 2297 | const param_one = try p.expectExpr(); |
| 2298 | const comma_one = p.eatToken(.Comma); | 2298 | const comma_one = p.eatToken(.comma); |
| 2299 | if (p.eatToken(.RParen)) |_| { | 2299 | if (p.eatToken(.r_paren)) |_| { |
| 2300 | return p.addNode(.{ | 2300 | return p.addNode(.{ |
| 2301 | .tag = if (comma_one == null) .AsyncCallOne else .AsyncCallOneComma, | 2301 | .tag = if (comma_one == null) .AsyncCallOne else .AsyncCallOneComma, |
| 2302 | .main_token = lparen, | 2302 | .main_token = lparen, |
| ... | @@ -2308,7 +2308,7 @@ const Parser = struct { | ... | @@ -2308,7 +2308,7 @@ const Parser = struct { |
| 2308 | } | 2308 | } |
| 2309 | if (comma_one == null) { | 2309 | if (comma_one == null) { |
| 2310 | try p.warn(.{ | 2310 | try p.warn(.{ |
| 2311 | .ExpectedToken = .{ .token = p.tok_i, .expected_id = .Comma }, | 2311 | .ExpectedToken = .{ .token = p.tok_i, .expected_id = .comma }, |
| 2312 | }); | 2312 | }); |
| 2313 | } | 2313 | } |
| 2314 | 2314 | ||
| ... | @@ -2321,8 +2321,8 @@ const Parser = struct { | ... | @@ -2321,8 +2321,8 @@ const Parser = struct { |
| 2321 | const next = try p.expectExpr(); | 2321 | const next = try p.expectExpr(); |
| 2322 | try param_list.append(next); | 2322 | try param_list.append(next); |
| 2323 | switch (p.token_tags[p.nextToken()]) { | 2323 | switch (p.token_tags[p.nextToken()]) { |
| 2324 | .Comma => { | 2324 | .comma => { |
| 2325 | if (p.eatToken(.RParen)) |_| { | 2325 | if (p.eatToken(.r_paren)) |_| { |
| 2326 | const span = try p.listToSpan(param_list.items); | 2326 | const span = try p.listToSpan(param_list.items); |
| 2327 | return p.addNode(.{ | 2327 | return p.addNode(.{ |
| 2328 | .tag = .AsyncCallComma, | 2328 | .tag = .AsyncCallComma, |
| ... | @@ -2339,7 +2339,7 @@ const Parser = struct { | ... | @@ -2339,7 +2339,7 @@ const Parser = struct { |
| 2339 | continue; | 2339 | continue; |
| 2340 | } | 2340 | } |
| 2341 | }, | 2341 | }, |
| 2342 | .RParen => { | 2342 | .r_paren => { |
| 2343 | const span = try p.listToSpan(param_list.items); | 2343 | const span = try p.listToSpan(param_list.items); |
| 2344 | return p.addNode(.{ | 2344 | return p.addNode(.{ |
| 2345 | .tag = .AsyncCall, | 2345 | .tag = .AsyncCall, |
| ... | @@ -2353,12 +2353,12 @@ const Parser = struct { | ... | @@ -2353,12 +2353,12 @@ const Parser = struct { |
| 2353 | }, | 2353 | }, |
| 2354 | }); | 2354 | }); |
| 2355 | }, | 2355 | }, |
| 2356 | .Colon, .RBrace, .RBracket => { | 2356 | .colon, .r_brace, .r_bracket => { |
| 2357 | p.tok_i -= 1; | 2357 | p.tok_i -= 1; |
| 2358 | return p.fail(.{ | 2358 | return p.fail(.{ |
| 2359 | .ExpectedToken = .{ | 2359 | .ExpectedToken = .{ |
| 2360 | .token = p.tok_i, | 2360 | .token = p.tok_i, |
| 2361 | .expected_id = .RParen, | 2361 | .expected_id = .r_paren, |
| 2362 | }, | 2362 | }, |
| 2363 | }); | 2363 | }); |
| 2364 | }, | 2364 | }, |
| ... | @@ -2367,7 +2367,7 @@ const Parser = struct { | ... | @@ -2367,7 +2367,7 @@ const Parser = struct { |
| 2367 | try p.warn(.{ | 2367 | try p.warn(.{ |
| 2368 | .ExpectedToken = .{ | 2368 | .ExpectedToken = .{ |
| 2369 | .token = p.tok_i, | 2369 | .token = p.tok_i, |
| 2370 | .expected_id = .Comma, | 2370 | .expected_id = .comma, |
| 2371 | }, | 2371 | }, |
| 2372 | }); | 2372 | }); |
| 2373 | }, | 2373 | }, |
| ... | @@ -2384,8 +2384,8 @@ const Parser = struct { | ... | @@ -2384,8 +2384,8 @@ const Parser = struct { |
| 2384 | continue; | 2384 | continue; |
| 2385 | } | 2385 | } |
| 2386 | res = res: { | 2386 | res = res: { |
| 2387 | const lparen = p.eatToken(.LParen) orelse return res; | 2387 | const lparen = p.eatToken(.l_paren) orelse return res; |
| 2388 | if (p.eatToken(.RParen)) |_| { | 2388 | if (p.eatToken(.r_paren)) |_| { |
| 2389 | break :res try p.addNode(.{ | 2389 | break :res try p.addNode(.{ |
| 2390 | .tag = .CallOne, | 2390 | .tag = .CallOne, |
| 2391 | .main_token = lparen, | 2391 | .main_token = lparen, |
| ... | @@ -2396,8 +2396,8 @@ const Parser = struct { | ... | @@ -2396,8 +2396,8 @@ const Parser = struct { |
| 2396 | }); | 2396 | }); |
| 2397 | } | 2397 | } |
| 2398 | const param_one = try p.expectExpr(); | 2398 | const param_one = try p.expectExpr(); |
| 2399 | const comma_one = p.eatToken(.Comma); | 2399 | const comma_one = p.eatToken(.comma); |
| 2400 | if (p.eatToken(.RParen)) |_| { | 2400 | if (p.eatToken(.r_paren)) |_| { |
| 2401 | break :res try p.addNode(.{ | 2401 | break :res try p.addNode(.{ |
| 2402 | .tag = if (comma_one == null) .CallOne else .CallOneComma, | 2402 | .tag = if (comma_one == null) .CallOne else .CallOneComma, |
| 2403 | .main_token = lparen, | 2403 | .main_token = lparen, |
| ... | @@ -2409,7 +2409,7 @@ const Parser = struct { | ... | @@ -2409,7 +2409,7 @@ const Parser = struct { |
| 2409 | } | 2409 | } |
| 2410 | if (comma_one == null) { | 2410 | if (comma_one == null) { |
| 2411 | try p.warn(.{ | 2411 | try p.warn(.{ |
| 2412 | .ExpectedToken = .{ .token = p.tok_i, .expected_id = .Comma }, | 2412 | .ExpectedToken = .{ .token = p.tok_i, .expected_id = .comma }, |
| 2413 | }); | 2413 | }); |
| 2414 | } | 2414 | } |
| 2415 | 2415 | ||
| ... | @@ -2422,8 +2422,8 @@ const Parser = struct { | ... | @@ -2422,8 +2422,8 @@ const Parser = struct { |
| 2422 | const next = try p.expectExpr(); | 2422 | const next = try p.expectExpr(); |
| 2423 | try param_list.append(next); | 2423 | try param_list.append(next); |
| 2424 | switch (p.token_tags[p.nextToken()]) { | 2424 | switch (p.token_tags[p.nextToken()]) { |
| 2425 | .Comma => { | 2425 | .comma => { |
| 2426 | if (p.eatToken(.RParen)) |_| { | 2426 | if (p.eatToken(.r_paren)) |_| { |
| 2427 | const span = try p.listToSpan(param_list.items); | 2427 | const span = try p.listToSpan(param_list.items); |
| 2428 | break :res try p.addNode(.{ | 2428 | break :res try p.addNode(.{ |
| 2429 | .tag = .CallComma, | 2429 | .tag = .CallComma, |
| ... | @@ -2440,7 +2440,7 @@ const Parser = struct { | ... | @@ -2440,7 +2440,7 @@ const Parser = struct { |
| 2440 | continue; | 2440 | continue; |
| 2441 | } | 2441 | } |
| 2442 | }, | 2442 | }, |
| 2443 | .RParen => { | 2443 | .r_paren => { |
| 2444 | const span = try p.listToSpan(param_list.items); | 2444 | const span = try p.listToSpan(param_list.items); |
| 2445 | break :res try p.addNode(.{ | 2445 | break :res try p.addNode(.{ |
| 2446 | .tag = .Call, | 2446 | .tag = .Call, |
| ... | @@ -2454,12 +2454,12 @@ const Parser = struct { | ... | @@ -2454,12 +2454,12 @@ const Parser = struct { |
| 2454 | }, | 2454 | }, |
| 2455 | }); | 2455 | }); |
| 2456 | }, | 2456 | }, |
| 2457 | .Colon, .RBrace, .RBracket => { | 2457 | .colon, .r_brace, .r_bracket => { |
| 2458 | p.tok_i -= 1; | 2458 | p.tok_i -= 1; |
| 2459 | return p.fail(.{ | 2459 | return p.fail(.{ |
| 2460 | .ExpectedToken = .{ | 2460 | .ExpectedToken = .{ |
| 2461 | .token = p.tok_i, | 2461 | .token = p.tok_i, |
| 2462 | .expected_id = .RParen, | 2462 | .expected_id = .r_paren, |
| 2463 | }, | 2463 | }, |
| 2464 | }); | 2464 | }); |
| 2465 | }, | 2465 | }, |
| ... | @@ -2468,7 +2468,7 @@ const Parser = struct { | ... | @@ -2468,7 +2468,7 @@ const Parser = struct { |
| 2468 | try p.warn(.{ | 2468 | try p.warn(.{ |
| 2469 | .ExpectedToken = .{ | 2469 | .ExpectedToken = .{ |
| 2470 | .token = p.tok_i, | 2470 | .token = p.tok_i, |
| 2471 | .expected_id = .Comma, | 2471 | .expected_id = .comma, |
| 2472 | }, | 2472 | }, |
| 2473 | }); | 2473 | }); |
| 2474 | }, | 2474 | }, |
| ... | @@ -2517,7 +2517,7 @@ const Parser = struct { | ... | @@ -2517,7 +2517,7 @@ const Parser = struct { |
| 2517 | /// LoopTypeExpr <- KEYWORD_inline? (ForTypeExpr / WhileTypeExpr) | 2517 | /// LoopTypeExpr <- KEYWORD_inline? (ForTypeExpr / WhileTypeExpr) |
| 2518 | fn parsePrimaryTypeExpr(p: *Parser) !Node.Index { | 2518 | fn parsePrimaryTypeExpr(p: *Parser) !Node.Index { |
| 2519 | switch (p.token_tags[p.tok_i]) { | 2519 | switch (p.token_tags[p.tok_i]) { |
| 2520 | .CharLiteral => return p.addNode(.{ | 2520 | .char_literal => return p.addNode(.{ |
| 2521 | .tag = .CharLiteral, | 2521 | .tag = .CharLiteral, |
| 2522 | .main_token = p.nextToken(), | 2522 | .main_token = p.nextToken(), |
| 2523 | .data = .{ | 2523 | .data = .{ |
| ... | @@ -2525,7 +2525,7 @@ const Parser = struct { | ... | @@ -2525,7 +2525,7 @@ const Parser = struct { |
| 2525 | .rhs = undefined, | 2525 | .rhs = undefined, |
| 2526 | }, | 2526 | }, |
| 2527 | }), | 2527 | }), |
| 2528 | .IntegerLiteral => return p.addNode(.{ | 2528 | .integer_literal => return p.addNode(.{ |
| 2529 | .tag = .IntegerLiteral, | 2529 | .tag = .IntegerLiteral, |
| 2530 | .main_token = p.nextToken(), | 2530 | .main_token = p.nextToken(), |
| 2531 | .data = .{ | 2531 | .data = .{ |
| ... | @@ -2533,7 +2533,7 @@ const Parser = struct { | ... | @@ -2533,7 +2533,7 @@ const Parser = struct { |
| 2533 | .rhs = undefined, | 2533 | .rhs = undefined, |
| 2534 | }, | 2534 | }, |
| 2535 | }), | 2535 | }), |
| 2536 | .FloatLiteral => return p.addNode(.{ | 2536 | .float_literal => return p.addNode(.{ |
| 2537 | .tag = .FloatLiteral, | 2537 | .tag = .FloatLiteral, |
| 2538 | .main_token = p.nextToken(), | 2538 | .main_token = p.nextToken(), |
| 2539 | .data = .{ | 2539 | .data = .{ |
| ... | @@ -2541,7 +2541,7 @@ const Parser = struct { | ... | @@ -2541,7 +2541,7 @@ const Parser = struct { |
| 2541 | .rhs = undefined, | 2541 | .rhs = undefined, |
| 2542 | }, | 2542 | }, |
| 2543 | }), | 2543 | }), |
| 2544 | .Keyword_false => return p.addNode(.{ | 2544 | .keyword_false => return p.addNode(.{ |
| 2545 | .tag = .FalseLiteral, | 2545 | .tag = .FalseLiteral, |
| 2546 | .main_token = p.nextToken(), | 2546 | .main_token = p.nextToken(), |
| 2547 | .data = .{ | 2547 | .data = .{ |
| ... | @@ -2549,7 +2549,7 @@ const Parser = struct { | ... | @@ -2549,7 +2549,7 @@ const Parser = struct { |
| 2549 | .rhs = undefined, | 2549 | .rhs = undefined, |
| 2550 | }, | 2550 | }, |
| 2551 | }), | 2551 | }), |
| 2552 | .Keyword_true => return p.addNode(.{ | 2552 | .keyword_true => return p.addNode(.{ |
| 2553 | .tag = .TrueLiteral, | 2553 | .tag = .TrueLiteral, |
| 2554 | .main_token = p.nextToken(), | 2554 | .main_token = p.nextToken(), |
| 2555 | .data = .{ | 2555 | .data = .{ |
| ... | @@ -2557,7 +2557,7 @@ const Parser = struct { | ... | @@ -2557,7 +2557,7 @@ const Parser = struct { |
| 2557 | .rhs = undefined, | 2557 | .rhs = undefined, |
| 2558 | }, | 2558 | }, |
| 2559 | }), | 2559 | }), |
| 2560 | .Keyword_null => return p.addNode(.{ | 2560 | .keyword_null => return p.addNode(.{ |
| 2561 | .tag = .NullLiteral, | 2561 | .tag = .NullLiteral, |
| 2562 | .main_token = p.nextToken(), | 2562 | .main_token = p.nextToken(), |
| 2563 | .data = .{ | 2563 | .data = .{ |
| ... | @@ -2565,7 +2565,7 @@ const Parser = struct { | ... | @@ -2565,7 +2565,7 @@ const Parser = struct { |
| 2565 | .rhs = undefined, | 2565 | .rhs = undefined, |
| 2566 | }, | 2566 | }, |
| 2567 | }), | 2567 | }), |
| 2568 | .Keyword_undefined => return p.addNode(.{ | 2568 | .keyword_undefined => return p.addNode(.{ |
| 2569 | .tag = .UndefinedLiteral, | 2569 | .tag = .UndefinedLiteral, |
| 2570 | .main_token = p.nextToken(), | 2570 | .main_token = p.nextToken(), |
| 2571 | .data = .{ | 2571 | .data = .{ |
| ... | @@ -2573,7 +2573,7 @@ const Parser = struct { | ... | @@ -2573,7 +2573,7 @@ const Parser = struct { |
| 2573 | .rhs = undefined, | 2573 | .rhs = undefined, |
| 2574 | }, | 2574 | }, |
| 2575 | }), | 2575 | }), |
| 2576 | .Keyword_unreachable => return p.addNode(.{ | 2576 | .keyword_unreachable => return p.addNode(.{ |
| 2577 | .tag = .UnreachableLiteral, | 2577 | .tag = .UnreachableLiteral, |
| 2578 | .main_token = p.nextToken(), | 2578 | .main_token = p.nextToken(), |
| 2579 | .data = .{ | 2579 | .data = .{ |
| ... | @@ -2581,7 +2581,7 @@ const Parser = struct { | ... | @@ -2581,7 +2581,7 @@ const Parser = struct { |
| 2581 | .rhs = undefined, | 2581 | .rhs = undefined, |
| 2582 | }, | 2582 | }, |
| 2583 | }), | 2583 | }), |
| 2584 | .Keyword_anyframe => return p.addNode(.{ | 2584 | .keyword_anyframe => return p.addNode(.{ |
| 2585 | .tag = .AnyFrameLiteral, | 2585 | .tag = .AnyFrameLiteral, |
| 2586 | .main_token = p.nextToken(), | 2586 | .main_token = p.nextToken(), |
| 2587 | .data = .{ | 2587 | .data = .{ |
| ... | @@ -2589,7 +2589,7 @@ const Parser = struct { | ... | @@ -2589,7 +2589,7 @@ const Parser = struct { |
| 2589 | .rhs = undefined, | 2589 | .rhs = undefined, |
| 2590 | }, | 2590 | }, |
| 2591 | }), | 2591 | }), |
| 2592 | .StringLiteral => { | 2592 | .string_literal => { |
| 2593 | const main_token = p.nextToken(); | 2593 | const main_token = p.nextToken(); |
| 2594 | return p.addNode(.{ | 2594 | return p.addNode(.{ |
| 2595 | .tag = .StringLiteral, | 2595 | .tag = .StringLiteral, |
| ... | @@ -2601,25 +2601,25 @@ const Parser = struct { | ... | @@ -2601,25 +2601,25 @@ const Parser = struct { |
| 2601 | }); | 2601 | }); |
| 2602 | }, | 2602 | }, |
| 2603 | 2603 | ||
| 2604 | .Builtin => return p.parseBuiltinCall(), | 2604 | .builtin => return p.parseBuiltinCall(), |
| 2605 | .Keyword_fn => return p.parseFnProto(), | 2605 | .keyword_fn => return p.parseFnProto(), |
| 2606 | .Keyword_if => return p.parseIf(parseTypeExpr), | 2606 | .keyword_if => return p.parseIf(parseTypeExpr), |
| 2607 | .Keyword_switch => return p.expectSwitchExpr(), | 2607 | .keyword_switch => return p.expectSwitchExpr(), |
| 2608 | 2608 | ||
| 2609 | .Keyword_extern, | 2609 | .keyword_extern, |
| 2610 | .Keyword_packed, | 2610 | .keyword_packed, |
| 2611 | => { | 2611 | => { |
| 2612 | p.tok_i += 1; | 2612 | p.tok_i += 1; |
| 2613 | return p.parseContainerDeclAuto(); | 2613 | return p.parseContainerDeclAuto(); |
| 2614 | }, | 2614 | }, |
| 2615 | 2615 | ||
| 2616 | .Keyword_struct, | 2616 | .keyword_struct, |
| 2617 | .Keyword_opaque, | 2617 | .keyword_opaque, |
| 2618 | .Keyword_enum, | 2618 | .keyword_enum, |
| 2619 | .Keyword_union, | 2619 | .keyword_union, |
| 2620 | => return p.parseContainerDeclAuto(), | 2620 | => return p.parseContainerDeclAuto(), |
| 2621 | 2621 | ||
| 2622 | .Keyword_comptime => return p.addNode(.{ | 2622 | .keyword_comptime => return p.addNode(.{ |
| 2623 | .tag = .Comptime, | 2623 | .tag = .Comptime, |
| 2624 | .main_token = p.nextToken(), | 2624 | .main_token = p.nextToken(), |
| 2625 | .data = .{ | 2625 | .data = .{ |
| ... | @@ -2627,9 +2627,9 @@ const Parser = struct { | ... | @@ -2627,9 +2627,9 @@ const Parser = struct { |
| 2627 | .rhs = undefined, | 2627 | .rhs = undefined, |
| 2628 | }, | 2628 | }, |
| 2629 | }), | 2629 | }), |
| 2630 | .MultilineStringLiteralLine => { | 2630 | .multiline_string_literal_line => { |
| 2631 | const first_line = p.nextToken(); | 2631 | 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) { |
| 2633 | p.tok_i += 1; | 2633 | p.tok_i += 1; |
| 2634 | } | 2634 | } |
| 2635 | return p.addNode(.{ | 2635 | return p.addNode(.{ |
| ... | @@ -2641,23 +2641,23 @@ const Parser = struct { | ... | @@ -2641,23 +2641,23 @@ const Parser = struct { |
| 2641 | }, | 2641 | }, |
| 2642 | }); | 2642 | }); |
| 2643 | }, | 2643 | }, |
| 2644 | .Identifier => switch (p.token_tags[p.tok_i + 1]) { | 2644 | .identifier => switch (p.token_tags[p.tok_i + 1]) { |
| 2645 | .Colon => switch (p.token_tags[p.tok_i + 2]) { | 2645 | .colon => switch (p.token_tags[p.tok_i + 2]) { |
| 2646 | .Keyword_inline => { | 2646 | .keyword_inline => { |
| 2647 | p.tok_i += 3; | 2647 | p.tok_i += 3; |
| 2648 | switch (p.token_tags[p.tok_i]) { | 2648 | switch (p.token_tags[p.tok_i]) { |
| 2649 | .Keyword_for => return p.parseForTypeExpr(), | 2649 | .keyword_for => return p.parseForTypeExpr(), |
| 2650 | .Keyword_while => return p.parseWhileTypeExpr(), | 2650 | .keyword_while => return p.parseWhileTypeExpr(), |
| 2651 | else => return p.fail(.{ | 2651 | else => return p.fail(.{ |
| 2652 | .ExpectedInlinable = .{ .token = p.tok_i }, | 2652 | .ExpectedInlinable = .{ .token = p.tok_i }, |
| 2653 | }), | 2653 | }), |
| 2654 | } | 2654 | } |
| 2655 | }, | 2655 | }, |
| 2656 | .Keyword_for => { | 2656 | .keyword_for => { |
| 2657 | p.tok_i += 2; | 2657 | p.tok_i += 2; |
| 2658 | return p.parseForTypeExpr(); | 2658 | return p.parseForTypeExpr(); |
| 2659 | }, | 2659 | }, |
| 2660 | .Keyword_while => { | 2660 | .keyword_while => { |
| 2661 | p.tok_i += 2; | 2661 | p.tok_i += 2; |
| 2662 | return p.parseWhileTypeExpr(); | 2662 | return p.parseWhileTypeExpr(); |
| 2663 | }, | 2663 | }, |
| ... | @@ -2679,8 +2679,8 @@ const Parser = struct { | ... | @@ -2679,8 +2679,8 @@ const Parser = struct { |
| 2679 | }, | 2679 | }, |
| 2680 | }), | 2680 | }), |
| 2681 | }, | 2681 | }, |
| 2682 | .Period => switch (p.token_tags[p.tok_i + 1]) { | 2682 | .period => switch (p.token_tags[p.tok_i + 1]) { |
| 2683 | .Identifier => return p.addNode(.{ | 2683 | .identifier => return p.addNode(.{ |
| 2684 | .tag = .EnumLiteral, | 2684 | .tag = .EnumLiteral, |
| 2685 | .data = .{ | 2685 | .data = .{ |
| 2686 | .lhs = p.nextToken(), // dot | 2686 | .lhs = p.nextToken(), // dot |
| ... | @@ -2688,14 +2688,14 @@ const Parser = struct { | ... | @@ -2688,14 +2688,14 @@ const Parser = struct { |
| 2688 | }, | 2688 | }, |
| 2689 | .main_token = p.nextToken(), // identifier | 2689 | .main_token = p.nextToken(), // identifier |
| 2690 | }), | 2690 | }), |
| 2691 | .LBrace => { | 2691 | .l_brace => { |
| 2692 | const lbrace = p.tok_i + 1; | 2692 | const lbrace = p.tok_i + 1; |
| 2693 | p.tok_i = lbrace + 1; | 2693 | p.tok_i = lbrace + 1; |
| 2694 | 2694 | ||
| 2695 | // If there are 0, 1, or 2 items, we can use ArrayInitDotTwo/StructInitDotTwo; | 2695 | // If there are 0, 1, or 2 items, we can use ArrayInitDotTwo/StructInitDotTwo; |
| 2696 | // otherwise we use the full ArrayInitDot/StructInitDot. | 2696 | // otherwise we use the full ArrayInitDot/StructInitDot. |
| 2697 | 2697 | ||
| 2698 | if (p.eatToken(.RBrace)) |_| { | 2698 | if (p.eatToken(.r_brace)) |_| { |
| 2699 | return p.addNode(.{ | 2699 | return p.addNode(.{ |
| 2700 | .tag = .StructInitDotTwo, | 2700 | .tag = .StructInitDotTwo, |
| 2701 | .main_token = lbrace, | 2701 | .main_token = lbrace, |
| ... | @@ -2707,8 +2707,8 @@ const Parser = struct { | ... | @@ -2707,8 +2707,8 @@ const Parser = struct { |
| 2707 | } | 2707 | } |
| 2708 | const field_init_one = try p.parseFieldInit(); | 2708 | const field_init_one = try p.parseFieldInit(); |
| 2709 | if (field_init_one != 0) { | 2709 | if (field_init_one != 0) { |
| 2710 | const comma_one = p.eatToken(.Comma); | 2710 | const comma_one = p.eatToken(.comma); |
| 2711 | if (p.eatToken(.RBrace)) |_| { | 2711 | if (p.eatToken(.r_brace)) |_| { |
| 2712 | return p.addNode(.{ | 2712 | return p.addNode(.{ |
| 2713 | .tag = if (comma_one != null) .StructInitDotTwoComma else .StructInitDotTwo, | 2713 | .tag = if (comma_one != null) .StructInitDotTwoComma else .StructInitDotTwo, |
| 2714 | .main_token = lbrace, | 2714 | .main_token = lbrace, |
| ... | @@ -2720,12 +2720,12 @@ const Parser = struct { | ... | @@ -2720,12 +2720,12 @@ const Parser = struct { |
| 2720 | } | 2720 | } |
| 2721 | if (comma_one == null) { | 2721 | if (comma_one == null) { |
| 2722 | try p.warn(.{ | 2722 | try p.warn(.{ |
| 2723 | .ExpectedToken = .{ .token = p.tok_i, .expected_id = .Comma }, | 2723 | .ExpectedToken = .{ .token = p.tok_i, .expected_id = .comma }, |
| 2724 | }); | 2724 | }); |
| 2725 | } | 2725 | } |
| 2726 | const field_init_two = try p.expectFieldInit(); | 2726 | const field_init_two = try p.expectFieldInit(); |
| 2727 | const comma_two = p.eatToken(.Comma); | 2727 | const comma_two = p.eatToken(.comma); |
| 2728 | if (p.eatToken(.RBrace)) |_| { | 2728 | if (p.eatToken(.r_brace)) |_| { |
| 2729 | return p.addNode(.{ | 2729 | return p.addNode(.{ |
| 2730 | .tag = if (comma_two != null) .StructInitDotTwoComma else .StructInitDotTwo, | 2730 | .tag = if (comma_two != null) .StructInitDotTwoComma else .StructInitDotTwo, |
| 2731 | .main_token = lbrace, | 2731 | .main_token = lbrace, |
| ... | @@ -2737,30 +2737,30 @@ const Parser = struct { | ... | @@ -2737,30 +2737,30 @@ const Parser = struct { |
| 2737 | } | 2737 | } |
| 2738 | if (comma_two == null) { | 2738 | if (comma_two == null) { |
| 2739 | try p.warn(.{ | 2739 | try p.warn(.{ |
| 2740 | .ExpectedToken = .{ .token = p.tok_i, .expected_id = .Comma }, | 2740 | .ExpectedToken = .{ .token = p.tok_i, .expected_id = .comma }, |
| 2741 | }); | 2741 | }); |
| 2742 | } | 2742 | } |
| 2743 | var init_list = std.ArrayList(Node.Index).init(p.gpa); | 2743 | var init_list = std.ArrayList(Node.Index).init(p.gpa); |
| 2744 | defer init_list.deinit(); | 2744 | defer init_list.deinit(); |
| 2745 | 2745 | ||
| 2746 | try init_list.appendSlice(&[_]Node.Index{ field_init_one, field_init_two }); | 2746 | try init_list.appendSlice(&.{ field_init_one, field_init_two }); |
| 2747 | 2747 | ||
| 2748 | while (true) { | 2748 | while (true) { |
| 2749 | const next = try p.expectFieldInit(); | 2749 | const next = try p.expectFieldInit(); |
| 2750 | assert(next != 0); | 2750 | assert(next != 0); |
| 2751 | try init_list.append(next); | 2751 | try init_list.append(next); |
| 2752 | switch (p.token_tags[p.nextToken()]) { | 2752 | switch (p.token_tags[p.nextToken()]) { |
| 2753 | .Comma => { | 2753 | .comma => { |
| 2754 | if (p.eatToken(.RBrace)) |_| break; | 2754 | if (p.eatToken(.r_brace)) |_| break; |
| 2755 | continue; | 2755 | continue; |
| 2756 | }, | 2756 | }, |
| 2757 | .RBrace => break, | 2757 | .r_brace => break, |
| 2758 | .Colon, .RParen, .RBracket => { | 2758 | .colon, .r_paren, .r_bracket => { |
| 2759 | p.tok_i -= 1; | 2759 | p.tok_i -= 1; |
| 2760 | return p.fail(.{ | 2760 | return p.fail(.{ |
| 2761 | .ExpectedToken = .{ | 2761 | .ExpectedToken = .{ |
| 2762 | .token = p.tok_i, | 2762 | .token = p.tok_i, |
| 2763 | .expected_id = .RBrace, | 2763 | .expected_id = .r_brace, |
| 2764 | }, | 2764 | }, |
| 2765 | }); | 2765 | }); |
| 2766 | }, | 2766 | }, |
| ... | @@ -2769,14 +2769,14 @@ const Parser = struct { | ... | @@ -2769,14 +2769,14 @@ const Parser = struct { |
| 2769 | try p.warn(.{ | 2769 | try p.warn(.{ |
| 2770 | .ExpectedToken = .{ | 2770 | .ExpectedToken = .{ |
| 2771 | .token = p.tok_i, | 2771 | .token = p.tok_i, |
| 2772 | .expected_id = .Comma, | 2772 | .expected_id = .comma, |
| 2773 | }, | 2773 | }, |
| 2774 | }); | 2774 | }); |
| 2775 | }, | 2775 | }, |
| 2776 | } | 2776 | } |
| 2777 | } | 2777 | } |
| 2778 | const span = try p.listToSpan(init_list.items); | 2778 | 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; |
| 2780 | return p.addNode(.{ | 2780 | return p.addNode(.{ |
| 2781 | .tag = if (trailing_comma) .StructInitDotComma else .StructInitDot, | 2781 | .tag = if (trailing_comma) .StructInitDotComma else .StructInitDot, |
| 2782 | .main_token = lbrace, | 2782 | .main_token = lbrace, |
| ... | @@ -2788,8 +2788,8 @@ const Parser = struct { | ... | @@ -2788,8 +2788,8 @@ const Parser = struct { |
| 2788 | } | 2788 | } |
| 2789 | 2789 | ||
| 2790 | const elem_init_one = try p.expectExpr(); | 2790 | const elem_init_one = try p.expectExpr(); |
| 2791 | const comma_one = p.eatToken(.Comma); | 2791 | const comma_one = p.eatToken(.comma); |
| 2792 | if (p.eatToken(.RBrace)) |_| { | 2792 | if (p.eatToken(.r_brace)) |_| { |
| 2793 | return p.addNode(.{ | 2793 | return p.addNode(.{ |
| 2794 | .tag = if (comma_one != null) .ArrayInitDotTwoComma else .ArrayInitDotTwo, | 2794 | .tag = if (comma_one != null) .ArrayInitDotTwoComma else .ArrayInitDotTwo, |
| 2795 | .main_token = lbrace, | 2795 | .main_token = lbrace, |
| ... | @@ -2801,12 +2801,12 @@ const Parser = struct { | ... | @@ -2801,12 +2801,12 @@ const Parser = struct { |
| 2801 | } | 2801 | } |
| 2802 | if (comma_one == null) { | 2802 | if (comma_one == null) { |
| 2803 | try p.warn(.{ | 2803 | try p.warn(.{ |
| 2804 | .ExpectedToken = .{ .token = p.tok_i, .expected_id = .Comma }, | 2804 | .ExpectedToken = .{ .token = p.tok_i, .expected_id = .comma }, |
| 2805 | }); | 2805 | }); |
| 2806 | } | 2806 | } |
| 2807 | const elem_init_two = try p.expectExpr(); | 2807 | const elem_init_two = try p.expectExpr(); |
| 2808 | const comma_two = p.eatToken(.Comma); | 2808 | const comma_two = p.eatToken(.comma); |
| 2809 | if (p.eatToken(.RBrace)) |_| { | 2809 | if (p.eatToken(.r_brace)) |_| { |
| 2810 | return p.addNode(.{ | 2810 | return p.addNode(.{ |
| 2811 | .tag = if (comma_two != null) .ArrayInitDotTwoComma else .ArrayInitDotTwo, | 2811 | .tag = if (comma_two != null) .ArrayInitDotTwoComma else .ArrayInitDotTwo, |
| 2812 | .main_token = lbrace, | 2812 | .main_token = lbrace, |
| ... | @@ -2818,30 +2818,30 @@ const Parser = struct { | ... | @@ -2818,30 +2818,30 @@ const Parser = struct { |
| 2818 | } | 2818 | } |
| 2819 | if (comma_two == null) { | 2819 | if (comma_two == null) { |
| 2820 | try p.warn(.{ | 2820 | try p.warn(.{ |
| 2821 | .ExpectedToken = .{ .token = p.tok_i, .expected_id = .Comma }, | 2821 | .ExpectedToken = .{ .token = p.tok_i, .expected_id = .comma }, |
| 2822 | }); | 2822 | }); |
| 2823 | } | 2823 | } |
| 2824 | var init_list = std.ArrayList(Node.Index).init(p.gpa); | 2824 | var init_list = std.ArrayList(Node.Index).init(p.gpa); |
| 2825 | defer init_list.deinit(); | 2825 | defer init_list.deinit(); |
| 2826 | 2826 | ||
| 2827 | try init_list.appendSlice(&[_]Node.Index{ elem_init_one, elem_init_two }); | 2827 | try init_list.appendSlice(&.{ elem_init_one, elem_init_two }); |
| 2828 | 2828 | ||
| 2829 | while (true) { | 2829 | while (true) { |
| 2830 | const next = try p.expectExpr(); | 2830 | const next = try p.expectExpr(); |
| 2831 | if (next == 0) break; | 2831 | if (next == 0) break; |
| 2832 | try init_list.append(next); | 2832 | try init_list.append(next); |
| 2833 | switch (p.token_tags[p.nextToken()]) { | 2833 | switch (p.token_tags[p.nextToken()]) { |
| 2834 | .Comma => { | 2834 | .comma => { |
| 2835 | if (p.eatToken(.RBrace)) |_| break; | 2835 | if (p.eatToken(.r_brace)) |_| break; |
| 2836 | continue; | 2836 | continue; |
| 2837 | }, | 2837 | }, |
| 2838 | .RBrace => break, | 2838 | .r_brace => break, |
| 2839 | .Colon, .RParen, .RBracket => { | 2839 | .colon, .r_paren, .r_bracket => { |
| 2840 | p.tok_i -= 1; | 2840 | p.tok_i -= 1; |
| 2841 | return p.fail(.{ | 2841 | return p.fail(.{ |
| 2842 | .ExpectedToken = .{ | 2842 | .ExpectedToken = .{ |
| 2843 | .token = p.tok_i, | 2843 | .token = p.tok_i, |
| 2844 | .expected_id = .RBrace, | 2844 | .expected_id = .r_brace, |
| 2845 | }, | 2845 | }, |
| 2846 | }); | 2846 | }); |
| 2847 | }, | 2847 | }, |
| ... | @@ -2850,7 +2850,7 @@ const Parser = struct { | ... | @@ -2850,7 +2850,7 @@ const Parser = struct { |
| 2850 | try p.warn(.{ | 2850 | try p.warn(.{ |
| 2851 | .ExpectedToken = .{ | 2851 | .ExpectedToken = .{ |
| 2852 | .token = p.tok_i, | 2852 | .token = p.tok_i, |
| 2853 | .expected_id = .Comma, | 2853 | .expected_id = .comma, |
| 2854 | }, | 2854 | }, |
| 2855 | }); | 2855 | }); |
| 2856 | }, | 2856 | }, |
| ... | @@ -2858,7 +2858,7 @@ const Parser = struct { | ... | @@ -2858,7 +2858,7 @@ const Parser = struct { |
| 2858 | } | 2858 | } |
| 2859 | const span = try p.listToSpan(init_list.items); | 2859 | const span = try p.listToSpan(init_list.items); |
| 2860 | return p.addNode(.{ | 2860 | 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, |
| 2862 | .main_token = lbrace, | 2862 | .main_token = lbrace, |
| 2863 | .data = .{ | 2863 | .data = .{ |
| 2864 | .lhs = span.start, | 2864 | .lhs = span.start, |
| ... | @@ -2868,12 +2868,12 @@ const Parser = struct { | ... | @@ -2868,12 +2868,12 @@ const Parser = struct { |
| 2868 | }, | 2868 | }, |
| 2869 | else => return null_node, | 2869 | else => return null_node, |
| 2870 | }, | 2870 | }, |
| 2871 | .Keyword_error => switch (p.token_tags[p.tok_i + 1]) { | 2871 | .keyword_error => switch (p.token_tags[p.tok_i + 1]) { |
| 2872 | .LBrace => { | 2872 | .l_brace => { |
| 2873 | const error_token = p.tok_i; | 2873 | const error_token = p.tok_i; |
| 2874 | p.tok_i += 2; | 2874 | p.tok_i += 2; |
| 2875 | 2875 | ||
| 2876 | if (p.eatToken(.RBrace)) |rbrace| { | 2876 | if (p.eatToken(.r_brace)) |rbrace| { |
| 2877 | return p.addNode(.{ | 2877 | return p.addNode(.{ |
| 2878 | .tag = .ErrorSetDecl, | 2878 | .tag = .ErrorSetDecl, |
| 2879 | .main_token = error_token, | 2879 | .main_token = error_token, |
| ... | @@ -2886,19 +2886,19 @@ const Parser = struct { | ... | @@ -2886,19 +2886,19 @@ const Parser = struct { |
| 2886 | 2886 | ||
| 2887 | while (true) { | 2887 | while (true) { |
| 2888 | const doc_comment = p.eatDocComments(); | 2888 | const doc_comment = p.eatDocComments(); |
| 2889 | const identifier = try p.expectToken(.Identifier); | 2889 | const identifier = try p.expectToken(.identifier); |
| 2890 | switch (p.token_tags[p.nextToken()]) { | 2890 | switch (p.token_tags[p.nextToken()]) { |
| 2891 | .Comma => { | 2891 | .comma => { |
| 2892 | if (p.eatToken(.RBrace)) |_| break; | 2892 | if (p.eatToken(.r_brace)) |_| break; |
| 2893 | continue; | 2893 | continue; |
| 2894 | }, | 2894 | }, |
| 2895 | .RBrace => break, | 2895 | .r_brace => break, |
| 2896 | .Colon, .RParen, .RBracket => { | 2896 | .colon, .r_paren, .r_bracket => { |
| 2897 | p.tok_i -= 1; | 2897 | p.tok_i -= 1; |
| 2898 | return p.fail(.{ | 2898 | return p.fail(.{ |
| 2899 | .ExpectedToken = .{ | 2899 | .ExpectedToken = .{ |
| 2900 | .token = p.tok_i, | 2900 | .token = p.tok_i, |
| 2901 | .expected_id = .RBrace, | 2901 | .expected_id = .r_brace, |
| 2902 | }, | 2902 | }, |
| 2903 | }); | 2903 | }); |
| 2904 | }, | 2904 | }, |
| ... | @@ -2907,7 +2907,7 @@ const Parser = struct { | ... | @@ -2907,7 +2907,7 @@ const Parser = struct { |
| 2907 | // give an error but continue parsing this list. | 2907 | // give an error but continue parsing this list. |
| 2908 | p.tok_i -= 1; | 2908 | p.tok_i -= 1; |
| 2909 | try p.warn(.{ | 2909 | try p.warn(.{ |
| 2910 | .ExpectedToken = .{ .token = p.tok_i, .expected_id = .Comma }, | 2910 | .ExpectedToken = .{ .token = p.tok_i, .expected_id = .comma }, |
| 2911 | }); | 2911 | }); |
| 2912 | }, | 2912 | }, |
| 2913 | } | 2913 | } |
| ... | @@ -2925,17 +2925,17 @@ const Parser = struct { | ... | @@ -2925,17 +2925,17 @@ const Parser = struct { |
| 2925 | .tag = .ErrorValue, | 2925 | .tag = .ErrorValue, |
| 2926 | .main_token = p.nextToken(), | 2926 | .main_token = p.nextToken(), |
| 2927 | .data = .{ | 2927 | .data = .{ |
| 2928 | .lhs = try p.expectToken(.Period), | 2928 | .lhs = try p.expectToken(.period), |
| 2929 | .rhs = try p.expectToken(.Identifier), | 2929 | .rhs = try p.expectToken(.identifier), |
| 2930 | }, | 2930 | }, |
| 2931 | }), | 2931 | }), |
| 2932 | }, | 2932 | }, |
| 2933 | .LParen => return p.addNode(.{ | 2933 | .l_paren => return p.addNode(.{ |
| 2934 | .tag = .GroupedExpression, | 2934 | .tag = .GroupedExpression, |
| 2935 | .main_token = p.nextToken(), | 2935 | .main_token = p.nextToken(), |
| 2936 | .data = .{ | 2936 | .data = .{ |
| 2937 | .lhs = try p.expectExpr(), | 2937 | .lhs = try p.expectExpr(), |
| 2938 | .rhs = try p.expectToken(.RParen), | 2938 | .rhs = try p.expectToken(.r_paren), |
| 2939 | }, | 2939 | }, |
| 2940 | }), | 2940 | }), |
| 2941 | else => return null_node, | 2941 | else => return null_node, |
| ... | @@ -2953,14 +2953,14 @@ const Parser = struct { | ... | @@ -2953,14 +2953,14 @@ const Parser = struct { |
| 2953 | /// ForPrefix <- KEYWORD_for LPAREN Expr RPAREN PtrIndexPayload | 2953 | /// ForPrefix <- KEYWORD_for LPAREN Expr RPAREN PtrIndexPayload |
| 2954 | /// ForTypeExpr <- ForPrefix TypeExpr (KEYWORD_else TypeExpr)? | 2954 | /// ForTypeExpr <- ForPrefix TypeExpr (KEYWORD_else TypeExpr)? |
| 2955 | fn parseForTypeExpr(p: *Parser) !Node.Index { | 2955 | fn parseForTypeExpr(p: *Parser) !Node.Index { |
| 2956 | const for_token = p.eatToken(.Keyword_for) orelse return null_node; | 2956 | const for_token = p.eatToken(.keyword_for) orelse return null_node; |
| 2957 | _ = try p.expectToken(.LParen); | 2957 | _ = try p.expectToken(.l_paren); |
| 2958 | const array_expr = try p.expectTypeExpr(); | 2958 | const array_expr = try p.expectTypeExpr(); |
| 2959 | _ = try p.expectToken(.RParen); | 2959 | _ = try p.expectToken(.r_paren); |
| 2960 | _ = try p.parsePtrIndexPayload(); | 2960 | _ = try p.parsePtrIndexPayload(); |
| 2961 | 2961 | ||
| 2962 | const then_expr = try p.expectExpr(); | 2962 | const then_expr = try p.expectExpr(); |
| 2963 | const else_token = p.eatToken(.Keyword_else) orelse { | 2963 | const else_token = p.eatToken(.keyword_else) orelse { |
| 2964 | return p.addNode(.{ | 2964 | return p.addNode(.{ |
| 2965 | .tag = .ForSimple, | 2965 | .tag = .ForSimple, |
| 2966 | .main_token = for_token, | 2966 | .main_token = for_token, |
| ... | @@ -2987,15 +2987,15 @@ const Parser = struct { | ... | @@ -2987,15 +2987,15 @@ const Parser = struct { |
| 2987 | /// WhilePrefix <- KEYWORD_while LPAREN Expr RPAREN PtrPayload? WhileContinueExpr? | 2987 | /// WhilePrefix <- KEYWORD_while LPAREN Expr RPAREN PtrPayload? WhileContinueExpr? |
| 2988 | /// WhileTypeExpr <- WhilePrefix TypeExpr (KEYWORD_else Payload? TypeExpr)? | 2988 | /// WhileTypeExpr <- WhilePrefix TypeExpr (KEYWORD_else Payload? TypeExpr)? |
| 2989 | fn parseWhileTypeExpr(p: *Parser) !Node.Index { | 2989 | fn parseWhileTypeExpr(p: *Parser) !Node.Index { |
| 2990 | const while_token = p.eatToken(.Keyword_while) orelse return null_node; | 2990 | const while_token = p.eatToken(.keyword_while) orelse return null_node; |
| 2991 | _ = try p.expectToken(.LParen); | 2991 | _ = try p.expectToken(.l_paren); |
| 2992 | const condition = try p.expectExpr(); | 2992 | const condition = try p.expectExpr(); |
| 2993 | _ = try p.expectToken(.RParen); | 2993 | _ = try p.expectToken(.r_paren); |
| 2994 | const then_payload = try p.parsePtrPayload(); | 2994 | const then_payload = try p.parsePtrPayload(); |
| 2995 | const cont_expr = try p.parseWhileContinueExpr(); | 2995 | const cont_expr = try p.parseWhileContinueExpr(); |
| 2996 | 2996 | ||
| 2997 | const then_expr = try p.expectTypeExpr(); | 2997 | const then_expr = try p.expectTypeExpr(); |
| 2998 | const else_token = p.eatToken(.Keyword_else) orelse { | 2998 | const else_token = p.eatToken(.keyword_else) orelse { |
| 2999 | if (cont_expr == 0) { | 2999 | if (cont_expr == 0) { |
| 3000 | return p.addNode(.{ | 3000 | return p.addNode(.{ |
| 3001 | .tag = .WhileSimple, | 3001 | .tag = .WhileSimple, |
| ... | @@ -3037,14 +3037,14 @@ const Parser = struct { | ... | @@ -3037,14 +3037,14 @@ const Parser = struct { |
| 3037 | 3037 | ||
| 3038 | /// SwitchExpr <- KEYWORD_switch LPAREN Expr RPAREN LBRACE SwitchProngList RBRACE | 3038 | /// SwitchExpr <- KEYWORD_switch LPAREN Expr RPAREN LBRACE SwitchProngList RBRACE |
| 3039 | fn expectSwitchExpr(p: *Parser) !Node.Index { | 3039 | fn expectSwitchExpr(p: *Parser) !Node.Index { |
| 3040 | const switch_token = p.assertToken(.Keyword_switch); | 3040 | const switch_token = p.assertToken(.keyword_switch); |
| 3041 | _ = try p.expectToken(.LParen); | 3041 | _ = try p.expectToken(.l_paren); |
| 3042 | const expr_node = try p.expectExpr(); | 3042 | const expr_node = try p.expectExpr(); |
| 3043 | _ = try p.expectToken(.RParen); | 3043 | _ = try p.expectToken(.r_paren); |
| 3044 | _ = try p.expectToken(.LBrace); | 3044 | _ = try p.expectToken(.l_brace); |
| 3045 | const cases = try p.parseSwitchProngList(); | 3045 | const cases = try p.parseSwitchProngList(); |
| 3046 | const trailing_comma = p.token_tags[p.tok_i - 1] == .Comma; | 3046 | const trailing_comma = p.token_tags[p.tok_i - 1] == .comma; |
| 3047 | _ = try p.expectToken(.RBrace); | 3047 | _ = try p.expectToken(.r_brace); |
| 3048 | 3048 | ||
| 3049 | return p.addNode(.{ | 3049 | return p.addNode(.{ |
| 3050 | .tag = if (trailing_comma) .SwitchComma else .Switch, | 3050 | .tag = if (trailing_comma) .SwitchComma else .Switch, |
| ... | @@ -3067,12 +3067,12 @@ const Parser = struct { | ... | @@ -3067,12 +3067,12 @@ const Parser = struct { |
| 3067 | /// AsmOutputList <- (AsmOutputItem COMMA)* AsmOutputItem? | 3067 | /// AsmOutputList <- (AsmOutputItem COMMA)* AsmOutputItem? |
| 3068 | /// AsmInputList <- (AsmInputItem COMMA)* AsmInputItem? | 3068 | /// AsmInputList <- (AsmInputItem COMMA)* AsmInputItem? |
| 3069 | fn expectAsmExpr(p: *Parser) !Node.Index { | 3069 | fn expectAsmExpr(p: *Parser) !Node.Index { |
| 3070 | const asm_token = p.assertToken(.Keyword_asm); | 3070 | const asm_token = p.assertToken(.keyword_asm); |
| 3071 | _ = p.eatToken(.Keyword_volatile); | 3071 | _ = p.eatToken(.keyword_volatile); |
| 3072 | _ = try p.expectToken(.LParen); | 3072 | _ = try p.expectToken(.l_paren); |
| 3073 | const template = try p.expectExpr(); | 3073 | const template = try p.expectExpr(); |
| 3074 | 3074 | ||
| 3075 | if (p.eatToken(.RParen)) |rparen| { | 3075 | if (p.eatToken(.r_paren)) |rparen| { |
| 3076 | return p.addNode(.{ | 3076 | return p.addNode(.{ |
| 3077 | .tag = .AsmSimple, | 3077 | .tag = .AsmSimple, |
| 3078 | .main_token = asm_token, | 3078 | .main_token = asm_token, |
| ... | @@ -3083,7 +3083,7 @@ const Parser = struct { | ... | @@ -3083,7 +3083,7 @@ const Parser = struct { |
| 3083 | }); | 3083 | }); |
| 3084 | } | 3084 | } |
| 3085 | 3085 | ||
| 3086 | _ = try p.expectToken(.Colon); | 3086 | _ = try p.expectToken(.colon); |
| 3087 | 3087 | ||
| 3088 | var list = std.ArrayList(Node.Index).init(p.gpa); | 3088 | var list = std.ArrayList(Node.Index).init(p.gpa); |
| 3089 | defer list.deinit(); | 3089 | defer list.deinit(); |
| ... | @@ -3093,51 +3093,51 @@ const Parser = struct { | ... | @@ -3093,51 +3093,51 @@ const Parser = struct { |
| 3093 | if (output_item == 0) break; | 3093 | if (output_item == 0) break; |
| 3094 | try list.append(output_item); | 3094 | try list.append(output_item); |
| 3095 | switch (p.token_tags[p.tok_i]) { | 3095 | switch (p.token_tags[p.tok_i]) { |
| 3096 | .Comma => p.tok_i += 1, | 3096 | .comma => p.tok_i += 1, |
| 3097 | .Colon, .RParen, .RBrace, .RBracket => break, // All possible delimiters. | 3097 | .colon, .r_paren, .r_brace, .r_bracket => break, // All possible delimiters. |
| 3098 | else => { | 3098 | else => { |
| 3099 | // This is likely just a missing comma; | 3099 | // This is likely just a missing comma; |
| 3100 | // give an error but continue parsing this list. | 3100 | // give an error but continue parsing this list. |
| 3101 | try p.warn(.{ | 3101 | try p.warn(.{ |
| 3102 | .ExpectedToken = .{ .token = p.tok_i, .expected_id = .Comma }, | 3102 | .ExpectedToken = .{ .token = p.tok_i, .expected_id = .comma }, |
| 3103 | }); | 3103 | }); |
| 3104 | }, | 3104 | }, |
| 3105 | } | 3105 | } |
| 3106 | } | 3106 | } |
| 3107 | if (p.eatToken(.Colon)) |_| { | 3107 | if (p.eatToken(.colon)) |_| { |
| 3108 | while (true) { | 3108 | while (true) { |
| 3109 | const input_item = try p.parseAsmInputItem(); | 3109 | const input_item = try p.parseAsmInputItem(); |
| 3110 | if (input_item == 0) break; | 3110 | if (input_item == 0) break; |
| 3111 | try list.append(input_item); | 3111 | try list.append(input_item); |
| 3112 | switch (p.token_tags[p.tok_i]) { | 3112 | switch (p.token_tags[p.tok_i]) { |
| 3113 | .Comma => p.tok_i += 1, | 3113 | .comma => p.tok_i += 1, |
| 3114 | .Colon, .RParen, .RBrace, .RBracket => break, // All possible delimiters. | 3114 | .colon, .r_paren, .r_brace, .r_bracket => break, // All possible delimiters. |
| 3115 | else => { | 3115 | else => { |
| 3116 | // This is likely just a missing comma; | 3116 | // This is likely just a missing comma; |
| 3117 | // give an error but continue parsing this list. | 3117 | // give an error but continue parsing this list. |
| 3118 | try p.warn(.{ | 3118 | try p.warn(.{ |
| 3119 | .ExpectedToken = .{ .token = p.tok_i, .expected_id = .Comma }, | 3119 | .ExpectedToken = .{ .token = p.tok_i, .expected_id = .comma }, |
| 3120 | }); | 3120 | }); |
| 3121 | }, | 3121 | }, |
| 3122 | } | 3122 | } |
| 3123 | } | 3123 | } |
| 3124 | if (p.eatToken(.Colon)) |_| { | 3124 | if (p.eatToken(.colon)) |_| { |
| 3125 | while (p.eatToken(.StringLiteral)) |_| { | 3125 | while (p.eatToken(.string_literal)) |_| { |
| 3126 | switch (p.token_tags[p.tok_i]) { | 3126 | switch (p.token_tags[p.tok_i]) { |
| 3127 | .Comma => p.tok_i += 1, | 3127 | .comma => p.tok_i += 1, |
| 3128 | .Colon, .RParen, .RBrace, .RBracket => break, | 3128 | .colon, .r_paren, .r_brace, .r_bracket => break, |
| 3129 | else => { | 3129 | else => { |
| 3130 | // This is likely just a missing comma; | 3130 | // This is likely just a missing comma; |
| 3131 | // give an error but continue parsing this list. | 3131 | // give an error but continue parsing this list. |
| 3132 | try p.warn(.{ | 3132 | try p.warn(.{ |
| 3133 | .ExpectedToken = .{ .token = p.tok_i, .expected_id = .Comma }, | 3133 | .ExpectedToken = .{ .token = p.tok_i, .expected_id = .comma }, |
| 3134 | }); | 3134 | }); |
| 3135 | }, | 3135 | }, |
| 3136 | } | 3136 | } |
| 3137 | } | 3137 | } |
| 3138 | } | 3138 | } |
| 3139 | } | 3139 | } |
| 3140 | const rparen = try p.expectToken(.RParen); | 3140 | const rparen = try p.expectToken(.r_paren); |
| 3141 | const span = try p.listToSpan(list.items); | 3141 | const span = try p.listToSpan(list.items); |
| 3142 | return p.addNode(.{ | 3142 | return p.addNode(.{ |
| 3143 | .tag = .Asm, | 3143 | .tag = .Asm, |
| ... | @@ -3155,20 +3155,20 @@ const Parser = struct { | ... | @@ -3155,20 +3155,20 @@ const Parser = struct { |
| 3155 | 3155 | ||
| 3156 | /// AsmOutputItem <- LBRACKET IDENTIFIER RBRACKET STRINGLITERAL LPAREN (MINUSRARROW TypeExpr / IDENTIFIER) RPAREN | 3156 | /// AsmOutputItem <- LBRACKET IDENTIFIER RBRACKET STRINGLITERAL LPAREN (MINUSRARROW TypeExpr / IDENTIFIER) RPAREN |
| 3157 | fn parseAsmOutputItem(p: *Parser) !Node.Index { | 3157 | fn parseAsmOutputItem(p: *Parser) !Node.Index { |
| 3158 | _ = p.eatToken(.LBracket) orelse return null_node; | 3158 | _ = p.eatToken(.l_bracket) orelse return null_node; |
| 3159 | const identifier = try p.expectToken(.Identifier); | 3159 | const identifier = try p.expectToken(.identifier); |
| 3160 | _ = try p.expectToken(.RBracket); | 3160 | _ = try p.expectToken(.r_bracket); |
| 3161 | _ = try p.expectToken(.StringLiteral); | 3161 | _ = try p.expectToken(.string_literal); |
| 3162 | _ = try p.expectToken(.LParen); | 3162 | _ = try p.expectToken(.l_paren); |
| 3163 | const type_expr: Node.Index = blk: { | 3163 | const type_expr: Node.Index = blk: { |
| 3164 | if (p.eatToken(.Arrow)) |_| { | 3164 | if (p.eatToken(.arrow)) |_| { |
| 3165 | break :blk try p.expectTypeExpr(); | 3165 | break :blk try p.expectTypeExpr(); |
| 3166 | } else { | 3166 | } else { |
| 3167 | _ = try p.expectToken(.Identifier); | 3167 | _ = try p.expectToken(.identifier); |
| 3168 | break :blk null_node; | 3168 | break :blk null_node; |
| 3169 | } | 3169 | } |
| 3170 | }; | 3170 | }; |
| 3171 | const rparen = try p.expectToken(.RParen); | 3171 | const rparen = try p.expectToken(.r_paren); |
| 3172 | return p.addNode(.{ | 3172 | return p.addNode(.{ |
| 3173 | .tag = .AsmOutput, | 3173 | .tag = .AsmOutput, |
| 3174 | .main_token = identifier, | 3174 | .main_token = identifier, |
| ... | @@ -3181,13 +3181,13 @@ const Parser = struct { | ... | @@ -3181,13 +3181,13 @@ const Parser = struct { |
| 3181 | 3181 | ||
| 3182 | /// AsmInputItem <- LBRACKET IDENTIFIER RBRACKET STRINGLITERAL LPAREN Expr RPAREN | 3182 | /// AsmInputItem <- LBRACKET IDENTIFIER RBRACKET STRINGLITERAL LPAREN Expr RPAREN |
| 3183 | fn parseAsmInputItem(p: *Parser) !Node.Index { | 3183 | fn parseAsmInputItem(p: *Parser) !Node.Index { |
| 3184 | _ = p.eatToken(.LBracket) orelse return null_node; | 3184 | _ = p.eatToken(.l_bracket) orelse return null_node; |
| 3185 | const identifier = try p.expectToken(.Identifier); | 3185 | const identifier = try p.expectToken(.identifier); |
| 3186 | _ = try p.expectToken(.RBracket); | 3186 | _ = try p.expectToken(.r_bracket); |
| 3187 | _ = try p.expectToken(.StringLiteral); | 3187 | _ = try p.expectToken(.string_literal); |
| 3188 | _ = try p.expectToken(.LParen); | 3188 | _ = try p.expectToken(.l_paren); |
| 3189 | const expr = try p.expectExpr(); | 3189 | const expr = try p.expectExpr(); |
| 3190 | const rparen = try p.expectToken(.RParen); | 3190 | const rparen = try p.expectToken(.r_paren); |
| 3191 | return p.addNode(.{ | 3191 | return p.addNode(.{ |
| 3192 | .tag = .AsmInput, | 3192 | .tag = .AsmInput, |
| 3193 | .main_token = identifier, | 3193 | .main_token = identifier, |
| ... | @@ -3200,14 +3200,14 @@ const Parser = struct { | ... | @@ -3200,14 +3200,14 @@ const Parser = struct { |
| 3200 | 3200 | ||
| 3201 | /// BreakLabel <- COLON IDENTIFIER | 3201 | /// BreakLabel <- COLON IDENTIFIER |
| 3202 | fn parseBreakLabel(p: *Parser) !TokenIndex { | 3202 | fn parseBreakLabel(p: *Parser) !TokenIndex { |
| 3203 | _ = p.eatToken(.Colon) orelse return @as(TokenIndex, 0); | 3203 | _ = p.eatToken(.colon) orelse return @as(TokenIndex, 0); |
| 3204 | return p.expectToken(.Identifier); | 3204 | return p.expectToken(.identifier); |
| 3205 | } | 3205 | } |
| 3206 | 3206 | ||
| 3207 | /// BlockLabel <- IDENTIFIER COLON | 3207 | /// BlockLabel <- IDENTIFIER COLON |
| 3208 | fn parseBlockLabel(p: *Parser) TokenIndex { | 3208 | fn parseBlockLabel(p: *Parser) TokenIndex { |
| 3209 | if (p.token_tags[p.tok_i] == .Identifier and | 3209 | if (p.token_tags[p.tok_i] == .identifier and |
| 3210 | p.token_tags[p.tok_i + 1] == .Colon) | 3210 | p.token_tags[p.tok_i + 1] == .colon) |
| 3211 | { | 3211 | { |
| 3212 | const identifier = p.tok_i; | 3212 | const identifier = p.tok_i; |
| 3213 | p.tok_i += 2; | 3213 | p.tok_i += 2; |
| ... | @@ -3218,9 +3218,9 @@ const Parser = struct { | ... | @@ -3218,9 +3218,9 @@ const Parser = struct { |
| 3218 | 3218 | ||
| 3219 | /// FieldInit <- DOT IDENTIFIER EQUAL Expr | 3219 | /// FieldInit <- DOT IDENTIFIER EQUAL Expr |
| 3220 | fn parseFieldInit(p: *Parser) !Node.Index { | 3220 | fn parseFieldInit(p: *Parser) !Node.Index { |
| 3221 | if (p.token_tags[p.tok_i + 0] == .Period and | 3221 | if (p.token_tags[p.tok_i + 0] == .period and |
| 3222 | p.token_tags[p.tok_i + 1] == .Identifier and | 3222 | p.token_tags[p.tok_i + 1] == .identifier and |
| 3223 | p.token_tags[p.tok_i + 2] == .Equal) | 3223 | p.token_tags[p.tok_i + 2] == .equal) |
| 3224 | { | 3224 | { |
| 3225 | p.tok_i += 3; | 3225 | p.tok_i += 3; |
| 3226 | return p.expectExpr(); | 3226 | return p.expectExpr(); |
| ... | @@ -3230,37 +3230,37 @@ const Parser = struct { | ... | @@ -3230,37 +3230,37 @@ const Parser = struct { |
| 3230 | } | 3230 | } |
| 3231 | 3231 | ||
| 3232 | fn expectFieldInit(p: *Parser) !Node.Index { | 3232 | fn expectFieldInit(p: *Parser) !Node.Index { |
| 3233 | _ = try p.expectToken(.Period); | 3233 | _ = try p.expectToken(.period); |
| 3234 | _ = try p.expectToken(.Identifier); | 3234 | _ = try p.expectToken(.identifier); |
| 3235 | _ = try p.expectToken(.Equal); | 3235 | _ = try p.expectToken(.equal); |
| 3236 | return p.expectExpr(); | 3236 | return p.expectExpr(); |
| 3237 | } | 3237 | } |
| 3238 | 3238 | ||
| 3239 | /// WhileContinueExpr <- COLON LPAREN AssignExpr RPAREN | 3239 | /// WhileContinueExpr <- COLON LPAREN AssignExpr RPAREN |
| 3240 | fn parseWhileContinueExpr(p: *Parser) !Node.Index { | 3240 | fn parseWhileContinueExpr(p: *Parser) !Node.Index { |
| 3241 | _ = p.eatToken(.Colon) orelse return null_node; | 3241 | _ = p.eatToken(.colon) orelse return null_node; |
| 3242 | _ = try p.expectToken(.LParen); | 3242 | _ = try p.expectToken(.l_paren); |
| 3243 | const node = try p.parseAssignExpr(); | 3243 | const node = try p.parseAssignExpr(); |
| 3244 | if (node == 0) return p.fail(.{ .ExpectedExprOrAssignment = .{ .token = p.tok_i } }); | 3244 | if (node == 0) return p.fail(.{ .ExpectedExprOrAssignment = .{ .token = p.tok_i } }); |
| 3245 | _ = try p.expectToken(.RParen); | 3245 | _ = try p.expectToken(.r_paren); |
| 3246 | return node; | 3246 | return node; |
| 3247 | } | 3247 | } |
| 3248 | 3248 | ||
| 3249 | /// LinkSection <- KEYWORD_linksection LPAREN Expr RPAREN | 3249 | /// LinkSection <- KEYWORD_linksection LPAREN Expr RPAREN |
| 3250 | fn parseLinkSection(p: *Parser) !Node.Index { | 3250 | fn parseLinkSection(p: *Parser) !Node.Index { |
| 3251 | _ = p.eatToken(.Keyword_linksection) orelse return null_node; | 3251 | _ = p.eatToken(.keyword_linksection) orelse return null_node; |
| 3252 | _ = try p.expectToken(.LParen); | 3252 | _ = try p.expectToken(.l_paren); |
| 3253 | const expr_node = try p.expectExpr(); | 3253 | const expr_node = try p.expectExpr(); |
| 3254 | _ = try p.expectToken(.RParen); | 3254 | _ = try p.expectToken(.r_paren); |
| 3255 | return expr_node; | 3255 | return expr_node; |
| 3256 | } | 3256 | } |
| 3257 | 3257 | ||
| 3258 | /// CallConv <- KEYWORD_callconv LPAREN Expr RPAREN | 3258 | /// CallConv <- KEYWORD_callconv LPAREN Expr RPAREN |
| 3259 | fn parseCallconv(p: *Parser) !Node.Index { | 3259 | fn parseCallconv(p: *Parser) !Node.Index { |
| 3260 | _ = p.eatToken(.Keyword_callconv) orelse return null_node; | 3260 | _ = p.eatToken(.keyword_callconv) orelse return null_node; |
| 3261 | _ = try p.expectToken(.LParen); | 3261 | _ = try p.expectToken(.l_paren); |
| 3262 | const expr_node = try p.expectExpr(); | 3262 | const expr_node = try p.expectExpr(); |
| 3263 | _ = try p.expectToken(.RParen); | 3263 | _ = try p.expectToken(.r_paren); |
| 3264 | return expr_node; | 3264 | return expr_node; |
| 3265 | } | 3265 | } |
| 3266 | 3266 | ||
| ... | @@ -3276,20 +3276,20 @@ const Parser = struct { | ... | @@ -3276,20 +3276,20 @@ const Parser = struct { |
| 3276 | fn expectParamDecl(p: *Parser) !Node.Index { | 3276 | fn expectParamDecl(p: *Parser) !Node.Index { |
| 3277 | _ = p.eatDocComments(); | 3277 | _ = p.eatDocComments(); |
| 3278 | switch (p.token_tags[p.tok_i]) { | 3278 | switch (p.token_tags[p.tok_i]) { |
| 3279 | .Keyword_noalias, .Keyword_comptime => p.tok_i += 1, | 3279 | .keyword_noalias, .keyword_comptime => p.tok_i += 1, |
| 3280 | .Ellipsis3 => { | 3280 | .ellipsis3 => { |
| 3281 | p.tok_i += 1; | 3281 | p.tok_i += 1; |
| 3282 | return null_node; | 3282 | return null_node; |
| 3283 | }, | 3283 | }, |
| 3284 | else => {}, | 3284 | else => {}, |
| 3285 | } | 3285 | } |
| 3286 | if (p.token_tags[p.tok_i] == .Identifier and | 3286 | if (p.token_tags[p.tok_i] == .identifier and |
| 3287 | p.token_tags[p.tok_i + 1] == .Colon) | 3287 | p.token_tags[p.tok_i + 1] == .colon) |
| 3288 | { | 3288 | { |
| 3289 | p.tok_i += 2; | 3289 | p.tok_i += 2; |
| 3290 | } | 3290 | } |
| 3291 | switch (p.token_tags[p.tok_i]) { | 3291 | switch (p.token_tags[p.tok_i]) { |
| 3292 | .Keyword_anytype => { | 3292 | .keyword_anytype => { |
| 3293 | p.tok_i += 1; | 3293 | p.tok_i += 1; |
| 3294 | return null_node; | 3294 | return null_node; |
| 3295 | }, | 3295 | }, |
| ... | @@ -3299,31 +3299,31 @@ const Parser = struct { | ... | @@ -3299,31 +3299,31 @@ const Parser = struct { |
| 3299 | 3299 | ||
| 3300 | /// Payload <- PIPE IDENTIFIER PIPE | 3300 | /// Payload <- PIPE IDENTIFIER PIPE |
| 3301 | fn parsePayload(p: *Parser) !TokenIndex { | 3301 | fn parsePayload(p: *Parser) !TokenIndex { |
| 3302 | _ = p.eatToken(.Pipe) orelse return @as(TokenIndex, 0); | 3302 | _ = p.eatToken(.pipe) orelse return @as(TokenIndex, 0); |
| 3303 | const identifier = try p.expectToken(.Identifier); | 3303 | const identifier = try p.expectToken(.identifier); |
| 3304 | _ = try p.expectToken(.Pipe); | 3304 | _ = try p.expectToken(.pipe); |
| 3305 | return identifier; | 3305 | return identifier; |
| 3306 | } | 3306 | } |
| 3307 | 3307 | ||
| 3308 | /// PtrPayload <- PIPE ASTERISK? IDENTIFIER PIPE | 3308 | /// PtrPayload <- PIPE ASTERISK? IDENTIFIER PIPE |
| 3309 | fn parsePtrPayload(p: *Parser) !TokenIndex { | 3309 | fn parsePtrPayload(p: *Parser) !TokenIndex { |
| 3310 | _ = p.eatToken(.Pipe) orelse return @as(TokenIndex, 0); | 3310 | _ = p.eatToken(.pipe) orelse return @as(TokenIndex, 0); |
| 3311 | _ = p.eatToken(.Asterisk); | 3311 | _ = p.eatToken(.asterisk); |
| 3312 | const identifier = try p.expectToken(.Identifier); | 3312 | const identifier = try p.expectToken(.identifier); |
| 3313 | _ = try p.expectToken(.Pipe); | 3313 | _ = try p.expectToken(.pipe); |
| 3314 | return identifier; | 3314 | return identifier; |
| 3315 | } | 3315 | } |
| 3316 | 3316 | ||
| 3317 | /// PtrIndexPayload <- PIPE ASTERISK? IDENTIFIER (COMMA IDENTIFIER)? PIPE | 3317 | /// PtrIndexPayload <- PIPE ASTERISK? IDENTIFIER (COMMA IDENTIFIER)? PIPE |
| 3318 | /// Returns the first identifier token, if any. | 3318 | /// Returns the first identifier token, if any. |
| 3319 | fn parsePtrIndexPayload(p: *Parser) !TokenIndex { | 3319 | fn parsePtrIndexPayload(p: *Parser) !TokenIndex { |
| 3320 | _ = p.eatToken(.Pipe) orelse return @as(TokenIndex, 0); | 3320 | _ = p.eatToken(.pipe) orelse return @as(TokenIndex, 0); |
| 3321 | _ = p.eatToken(.Asterisk); | 3321 | _ = p.eatToken(.asterisk); |
| 3322 | const identifier = try p.expectToken(.Identifier); | 3322 | const identifier = try p.expectToken(.identifier); |
| 3323 | if (p.eatToken(.Comma) != null) { | 3323 | if (p.eatToken(.comma) != null) { |
| 3324 | _ = try p.expectToken(.Identifier); | 3324 | _ = try p.expectToken(.identifier); |
| 3325 | } | 3325 | } |
| 3326 | _ = try p.expectToken(.Pipe); | 3326 | _ = try p.expectToken(.pipe); |
| 3327 | return identifier; | 3327 | return identifier; |
| 3328 | } | 3328 | } |
| 3329 | 3329 | ||
| ... | @@ -3332,8 +3332,8 @@ const Parser = struct { | ... | @@ -3332,8 +3332,8 @@ const Parser = struct { |
| 3332 | /// <- SwitchItem (COMMA SwitchItem)* COMMA? | 3332 | /// <- SwitchItem (COMMA SwitchItem)* COMMA? |
| 3333 | /// / KEYWORD_else | 3333 | /// / KEYWORD_else |
| 3334 | fn parseSwitchProng(p: *Parser) !Node.Index { | 3334 | fn parseSwitchProng(p: *Parser) !Node.Index { |
| 3335 | if (p.eatToken(.Keyword_else)) |_| { | 3335 | if (p.eatToken(.keyword_else)) |_| { |
| 3336 | const arrow_token = try p.expectToken(.EqualAngleBracketRight); | 3336 | const arrow_token = try p.expectToken(.equal_angle_bracket_right); |
| 3337 | _ = try p.parsePtrPayload(); | 3337 | _ = try p.parsePtrPayload(); |
| 3338 | return p.addNode(.{ | 3338 | return p.addNode(.{ |
| 3339 | .tag = .SwitchCaseOne, | 3339 | .tag = .SwitchCaseOne, |
| ... | @@ -3347,7 +3347,7 @@ const Parser = struct { | ... | @@ -3347,7 +3347,7 @@ const Parser = struct { |
| 3347 | const first_item = try p.parseSwitchItem(); | 3347 | const first_item = try p.parseSwitchItem(); |
| 3348 | if (first_item == 0) return null_node; | 3348 | if (first_item == 0) return null_node; |
| 3349 | 3349 | ||
| 3350 | if (p.eatToken(.EqualAngleBracketRight)) |arrow_token| { | 3350 | if (p.eatToken(.equal_angle_bracket_right)) |arrow_token| { |
| 3351 | _ = try p.parsePtrPayload(); | 3351 | _ = try p.parsePtrPayload(); |
| 3352 | return p.addNode(.{ | 3352 | return p.addNode(.{ |
| 3353 | .tag = .SwitchCaseOne, | 3353 | .tag = .SwitchCaseOne, |
| ... | @@ -3363,13 +3363,13 @@ const Parser = struct { | ... | @@ -3363,13 +3363,13 @@ const Parser = struct { |
| 3363 | defer list.deinit(); | 3363 | defer list.deinit(); |
| 3364 | 3364 | ||
| 3365 | try list.append(first_item); | 3365 | try list.append(first_item); |
| 3366 | while (p.eatToken(.Comma)) |_| { | 3366 | while (p.eatToken(.comma)) |_| { |
| 3367 | const next_item = try p.parseSwitchItem(); | 3367 | const next_item = try p.parseSwitchItem(); |
| 3368 | if (next_item == 0) break; | 3368 | if (next_item == 0) break; |
| 3369 | try list.append(next_item); | 3369 | try list.append(next_item); |
| 3370 | } | 3370 | } |
| 3371 | const span = try p.listToSpan(list.items); | 3371 | 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); |
| 3373 | _ = try p.parsePtrPayload(); | 3373 | _ = try p.parsePtrPayload(); |
| 3374 | return p.addNode(.{ | 3374 | return p.addNode(.{ |
| 3375 | .tag = .SwitchCase, | 3375 | .tag = .SwitchCase, |
| ... | @@ -3389,7 +3389,7 @@ const Parser = struct { | ... | @@ -3389,7 +3389,7 @@ const Parser = struct { |
| 3389 | const expr = try p.parseExpr(); | 3389 | const expr = try p.parseExpr(); |
| 3390 | if (expr == 0) return null_node; | 3390 | if (expr == 0) return null_node; |
| 3391 | 3391 | ||
| 3392 | if (p.eatToken(.Ellipsis3)) |token| { | 3392 | if (p.eatToken(.ellipsis3)) |token| { |
| 3393 | return p.addNode(.{ | 3393 | return p.addNode(.{ |
| 3394 | .tag = .SwitchRange, | 3394 | .tag = .SwitchRange, |
| 3395 | .main_token = token, | 3395 | .main_token = token, |
| ... | @@ -3419,25 +3419,25 @@ const Parser = struct { | ... | @@ -3419,25 +3419,25 @@ const Parser = struct { |
| 3419 | var saw_allowzero = false; | 3419 | var saw_allowzero = false; |
| 3420 | while (true) { | 3420 | while (true) { |
| 3421 | switch (p.token_tags[p.tok_i]) { | 3421 | switch (p.token_tags[p.tok_i]) { |
| 3422 | .Keyword_align => { | 3422 | .keyword_align => { |
| 3423 | if (result.align_node != 0) { | 3423 | if (result.align_node != 0) { |
| 3424 | try p.warn(.{ | 3424 | try p.warn(.{ |
| 3425 | .ExtraAlignQualifier = .{ .token = p.tok_i }, | 3425 | .ExtraAlignQualifier = .{ .token = p.tok_i }, |
| 3426 | }); | 3426 | }); |
| 3427 | } | 3427 | } |
| 3428 | p.tok_i += 1; | 3428 | p.tok_i += 1; |
| 3429 | _ = try p.expectToken(.LParen); | 3429 | _ = try p.expectToken(.l_paren); |
| 3430 | result.align_node = try p.expectExpr(); | 3430 | result.align_node = try p.expectExpr(); |
| 3431 | 3431 | ||
| 3432 | if (p.eatToken(.Colon)) |_| { | 3432 | if (p.eatToken(.colon)) |_| { |
| 3433 | result.bit_range_start = try p.expectExpr(); | 3433 | result.bit_range_start = try p.expectExpr(); |
| 3434 | _ = try p.expectToken(.Colon); | 3434 | _ = try p.expectToken(.colon); |
| 3435 | result.bit_range_end = try p.expectExpr(); | 3435 | result.bit_range_end = try p.expectExpr(); |
| 3436 | } | 3436 | } |
| 3437 | 3437 | ||
| 3438 | _ = try p.expectToken(.RParen); | 3438 | _ = try p.expectToken(.r_paren); |
| 3439 | }, | 3439 | }, |
| 3440 | .Keyword_const => { | 3440 | .keyword_const => { |
| 3441 | if (saw_const) { | 3441 | if (saw_const) { |
| 3442 | try p.warn(.{ | 3442 | try p.warn(.{ |
| 3443 | .ExtraConstQualifier = .{ .token = p.tok_i }, | 3443 | .ExtraConstQualifier = .{ .token = p.tok_i }, |
| ... | @@ -3446,7 +3446,7 @@ const Parser = struct { | ... | @@ -3446,7 +3446,7 @@ const Parser = struct { |
| 3446 | p.tok_i += 1; | 3446 | p.tok_i += 1; |
| 3447 | saw_const = true; | 3447 | saw_const = true; |
| 3448 | }, | 3448 | }, |
| 3449 | .Keyword_volatile => { | 3449 | .keyword_volatile => { |
| 3450 | if (saw_volatile) { | 3450 | if (saw_volatile) { |
| 3451 | try p.warn(.{ | 3451 | try p.warn(.{ |
| 3452 | .ExtraVolatileQualifier = .{ .token = p.tok_i }, | 3452 | .ExtraVolatileQualifier = .{ .token = p.tok_i }, |
| ... | @@ -3455,7 +3455,7 @@ const Parser = struct { | ... | @@ -3455,7 +3455,7 @@ const Parser = struct { |
| 3455 | p.tok_i += 1; | 3455 | p.tok_i += 1; |
| 3456 | saw_volatile = true; | 3456 | saw_volatile = true; |
| 3457 | }, | 3457 | }, |
| 3458 | .Keyword_allowzero => { | 3458 | .keyword_allowzero => { |
| 3459 | if (saw_allowzero) { | 3459 | if (saw_allowzero) { |
| 3460 | try p.warn(.{ | 3460 | try p.warn(.{ |
| 3461 | .ExtraAllowZeroQualifier = .{ .token = p.tok_i }, | 3461 | .ExtraAllowZeroQualifier = .{ .token = p.tok_i }, |
| ... | @@ -3476,14 +3476,14 @@ const Parser = struct { | ... | @@ -3476,14 +3476,14 @@ const Parser = struct { |
| 3476 | /// / DOTQUESTIONMARK | 3476 | /// / DOTQUESTIONMARK |
| 3477 | fn parseSuffixOp(p: *Parser, lhs: Node.Index) !Node.Index { | 3477 | fn parseSuffixOp(p: *Parser, lhs: Node.Index) !Node.Index { |
| 3478 | switch (p.token_tags[p.tok_i]) { | 3478 | switch (p.token_tags[p.tok_i]) { |
| 3479 | .LBracket => { | 3479 | .l_bracket => { |
| 3480 | const lbracket = p.nextToken(); | 3480 | const lbracket = p.nextToken(); |
| 3481 | const index_expr = try p.expectExpr(); | 3481 | const index_expr = try p.expectExpr(); |
| 3482 | 3482 | ||
| 3483 | if (p.eatToken(.Ellipsis2)) |_| { | 3483 | if (p.eatToken(.ellipsis2)) |_| { |
| 3484 | const end_expr = try p.parseExpr(); | 3484 | const end_expr = try p.parseExpr(); |
| 3485 | if (end_expr == 0) { | 3485 | if (end_expr == 0) { |
| 3486 | _ = try p.expectToken(.RBracket); | 3486 | _ = try p.expectToken(.r_bracket); |
| 3487 | return p.addNode(.{ | 3487 | return p.addNode(.{ |
| 3488 | .tag = .SliceOpen, | 3488 | .tag = .SliceOpen, |
| 3489 | .main_token = lbracket, | 3489 | .main_token = lbracket, |
| ... | @@ -3493,9 +3493,9 @@ const Parser = struct { | ... | @@ -3493,9 +3493,9 @@ const Parser = struct { |
| 3493 | }, | 3493 | }, |
| 3494 | }); | 3494 | }); |
| 3495 | } | 3495 | } |
| 3496 | if (p.eatToken(.Colon)) |_| { | 3496 | if (p.eatToken(.colon)) |_| { |
| 3497 | const sentinel = try p.parseExpr(); | 3497 | const sentinel = try p.parseExpr(); |
| 3498 | _ = try p.expectToken(.RBracket); | 3498 | _ = try p.expectToken(.r_bracket); |
| 3499 | return p.addNode(.{ | 3499 | return p.addNode(.{ |
| 3500 | .tag = .SliceSentinel, | 3500 | .tag = .SliceSentinel, |
| 3501 | .main_token = lbracket, | 3501 | .main_token = lbracket, |
| ... | @@ -3509,7 +3509,7 @@ const Parser = struct { | ... | @@ -3509,7 +3509,7 @@ const Parser = struct { |
| 3509 | }, | 3509 | }, |
| 3510 | }); | 3510 | }); |
| 3511 | } else { | 3511 | } else { |
| 3512 | _ = try p.expectToken(.RBracket); | 3512 | _ = try p.expectToken(.r_bracket); |
| 3513 | return p.addNode(.{ | 3513 | return p.addNode(.{ |
| 3514 | .tag = .Slice, | 3514 | .tag = .Slice, |
| 3515 | .main_token = lbracket, | 3515 | .main_token = lbracket, |
| ... | @@ -3523,7 +3523,7 @@ const Parser = struct { | ... | @@ -3523,7 +3523,7 @@ const Parser = struct { |
| 3523 | }); | 3523 | }); |
| 3524 | } | 3524 | } |
| 3525 | } | 3525 | } |
| 3526 | _ = try p.expectToken(.RBracket); | 3526 | _ = try p.expectToken(.r_bracket); |
| 3527 | return p.addNode(.{ | 3527 | return p.addNode(.{ |
| 3528 | .tag = .ArrayAccess, | 3528 | .tag = .ArrayAccess, |
| 3529 | .main_token = lbracket, | 3529 | .main_token = lbracket, |
| ... | @@ -3533,7 +3533,7 @@ const Parser = struct { | ... | @@ -3533,7 +3533,7 @@ const Parser = struct { |
| 3533 | }, | 3533 | }, |
| 3534 | }); | 3534 | }); |
| 3535 | }, | 3535 | }, |
| 3536 | .PeriodAsterisk => return p.addNode(.{ | 3536 | .period_asterisk => return p.addNode(.{ |
| 3537 | .tag = .Deref, | 3537 | .tag = .Deref, |
| 3538 | .main_token = p.nextToken(), | 3538 | .main_token = p.nextToken(), |
| 3539 | .data = .{ | 3539 | .data = .{ |
| ... | @@ -3541,7 +3541,7 @@ const Parser = struct { | ... | @@ -3541,7 +3541,7 @@ const Parser = struct { |
| 3541 | .rhs = undefined, | 3541 | .rhs = undefined, |
| 3542 | }, | 3542 | }, |
| 3543 | }), | 3543 | }), |
| 3544 | .Invalid_periodasterisks => { | 3544 | .invalid_periodasterisks => { |
| 3545 | const period_asterisk = p.nextToken(); | 3545 | const period_asterisk = p.nextToken(); |
| 3546 | try p.warn(.{ .AsteriskAfterPointerDereference = .{ .token = period_asterisk } }); | 3546 | try p.warn(.{ .AsteriskAfterPointerDereference = .{ .token = period_asterisk } }); |
| 3547 | return p.addNode(.{ | 3547 | return p.addNode(.{ |
| ... | @@ -3553,8 +3553,8 @@ const Parser = struct { | ... | @@ -3553,8 +3553,8 @@ const Parser = struct { |
| 3553 | }, | 3553 | }, |
| 3554 | }); | 3554 | }); |
| 3555 | }, | 3555 | }, |
| 3556 | .Period => switch (p.token_tags[p.tok_i + 1]) { | 3556 | .period => switch (p.token_tags[p.tok_i + 1]) { |
| 3557 | .Identifier => return p.addNode(.{ | 3557 | .identifier => return p.addNode(.{ |
| 3558 | .tag = .FieldAccess, | 3558 | .tag = .FieldAccess, |
| 3559 | .main_token = p.nextToken(), | 3559 | .main_token = p.nextToken(), |
| 3560 | .data = .{ | 3560 | .data = .{ |
| ... | @@ -3562,7 +3562,7 @@ const Parser = struct { | ... | @@ -3562,7 +3562,7 @@ const Parser = struct { |
| 3562 | .rhs = p.nextToken(), | 3562 | .rhs = p.nextToken(), |
| 3563 | }, | 3563 | }, |
| 3564 | }), | 3564 | }), |
| 3565 | .QuestionMark => return p.addNode(.{ | 3565 | .question_mark => return p.addNode(.{ |
| 3566 | .tag = .UnwrapOptional, | 3566 | .tag = .UnwrapOptional, |
| 3567 | .main_token = p.nextToken(), | 3567 | .main_token = p.nextToken(), |
| 3568 | .data = .{ | 3568 | .data = .{ |
| ... | @@ -3589,28 +3589,28 @@ const Parser = struct { | ... | @@ -3589,28 +3589,28 @@ const Parser = struct { |
| 3589 | fn parseContainerDeclAuto(p: *Parser) !Node.Index { | 3589 | fn parseContainerDeclAuto(p: *Parser) !Node.Index { |
| 3590 | const main_token = p.nextToken(); | 3590 | const main_token = p.nextToken(); |
| 3591 | const arg_expr = switch (p.token_tags[main_token]) { | 3591 | const arg_expr = switch (p.token_tags[main_token]) { |
| 3592 | .Keyword_struct, .Keyword_opaque => null_node, | 3592 | .keyword_struct, .keyword_opaque => null_node, |
| 3593 | .Keyword_enum => blk: { | 3593 | .keyword_enum => blk: { |
| 3594 | if (p.eatToken(.LParen)) |_| { | 3594 | if (p.eatToken(.l_paren)) |_| { |
| 3595 | const expr = try p.expectExpr(); | 3595 | const expr = try p.expectExpr(); |
| 3596 | _ = try p.expectToken(.RParen); | 3596 | _ = try p.expectToken(.r_paren); |
| 3597 | break :blk expr; | 3597 | break :blk expr; |
| 3598 | } else { | 3598 | } else { |
| 3599 | break :blk null_node; | 3599 | break :blk null_node; |
| 3600 | } | 3600 | } |
| 3601 | }, | 3601 | }, |
| 3602 | .Keyword_union => blk: { | 3602 | .keyword_union => blk: { |
| 3603 | if (p.eatToken(.LParen)) |_| { | 3603 | if (p.eatToken(.l_paren)) |_| { |
| 3604 | if (p.eatToken(.Keyword_enum)) |_| { | 3604 | if (p.eatToken(.keyword_enum)) |_| { |
| 3605 | if (p.eatToken(.LParen)) |_| { | 3605 | if (p.eatToken(.l_paren)) |_| { |
| 3606 | const enum_tag_expr = try p.expectExpr(); | 3606 | const enum_tag_expr = try p.expectExpr(); |
| 3607 | _ = try p.expectToken(.RParen); | 3607 | _ = try p.expectToken(.r_paren); |
| 3608 | _ = try p.expectToken(.RParen); | 3608 | _ = try p.expectToken(.r_paren); |
| 3609 | 3609 | ||
| 3610 | _ = try p.expectToken(.LBrace); | 3610 | _ = try p.expectToken(.l_brace); |
| 3611 | const members = try p.parseContainerMembers(); | 3611 | const members = try p.parseContainerMembers(); |
| 3612 | const members_span = try members.toSpan(p); | 3612 | const members_span = try members.toSpan(p); |
| 3613 | _ = try p.expectToken(.RBrace); | 3613 | _ = try p.expectToken(.r_brace); |
| 3614 | return p.addNode(.{ | 3614 | return p.addNode(.{ |
| 3615 | .tag = switch (members.trailing_comma) { | 3615 | .tag = switch (members.trailing_comma) { |
| 3616 | true => .TaggedUnionEnumTagComma, | 3616 | true => .TaggedUnionEnumTagComma, |
| ... | @@ -3623,11 +3623,11 @@ const Parser = struct { | ... | @@ -3623,11 +3623,11 @@ const Parser = struct { |
| 3623 | }, | 3623 | }, |
| 3624 | }); | 3624 | }); |
| 3625 | } else { | 3625 | } else { |
| 3626 | _ = try p.expectToken(.RParen); | 3626 | _ = try p.expectToken(.r_paren); |
| 3627 | 3627 | ||
| 3628 | _ = try p.expectToken(.LBrace); | 3628 | _ = try p.expectToken(.l_brace); |
| 3629 | const members = try p.parseContainerMembers(); | 3629 | const members = try p.parseContainerMembers(); |
| 3630 | _ = try p.expectToken(.RBrace); | 3630 | _ = try p.expectToken(.r_brace); |
| 3631 | if (members.len <= 2) { | 3631 | if (members.len <= 2) { |
| 3632 | return p.addNode(.{ | 3632 | return p.addNode(.{ |
| 3633 | .tag = switch (members.trailing_comma) { | 3633 | .tag = switch (members.trailing_comma) { |
| ... | @@ -3657,7 +3657,7 @@ const Parser = struct { | ... | @@ -3657,7 +3657,7 @@ const Parser = struct { |
| 3657 | } | 3657 | } |
| 3658 | } else { | 3658 | } else { |
| 3659 | const expr = try p.expectExpr(); | 3659 | const expr = try p.expectExpr(); |
| 3660 | _ = try p.expectToken(.RParen); | 3660 | _ = try p.expectToken(.r_paren); |
| 3661 | break :blk expr; | 3661 | break :blk expr; |
| 3662 | } | 3662 | } |
| 3663 | } else { | 3663 | } else { |
| ... | @@ -3666,9 +3666,9 @@ const Parser = struct { | ... | @@ -3666,9 +3666,9 @@ const Parser = struct { |
| 3666 | }, | 3666 | }, |
| 3667 | else => unreachable, | 3667 | else => unreachable, |
| 3668 | }; | 3668 | }; |
| 3669 | _ = try p.expectToken(.LBrace); | 3669 | _ = try p.expectToken(.l_brace); |
| 3670 | const members = try p.parseContainerMembers(); | 3670 | const members = try p.parseContainerMembers(); |
| 3671 | _ = try p.expectToken(.RBrace); | 3671 | _ = try p.expectToken(.r_brace); |
| 3672 | if (arg_expr == 0) { | 3672 | if (arg_expr == 0) { |
| 3673 | if (members.len <= 2) { | 3673 | if (members.len <= 2) { |
| 3674 | return p.addNode(.{ | 3674 | return p.addNode(.{ |
| ... | @@ -3718,10 +3718,10 @@ const Parser = struct { | ... | @@ -3718,10 +3718,10 @@ const Parser = struct { |
| 3718 | /// Holds temporary data until we are ready to construct the full ContainerDecl AST node. | 3718 | /// Holds temporary data until we are ready to construct the full ContainerDecl AST node. |
| 3719 | /// ByteAlign <- KEYWORD_align LPAREN Expr RPAREN | 3719 | /// ByteAlign <- KEYWORD_align LPAREN Expr RPAREN |
| 3720 | fn parseByteAlign(p: *Parser) !Node.Index { | 3720 | fn parseByteAlign(p: *Parser) !Node.Index { |
| 3721 | _ = p.eatToken(.Keyword_align) orelse return null_node; | 3721 | _ = p.eatToken(.keyword_align) orelse return null_node; |
| 3722 | _ = try p.expectToken(.LParen); | 3722 | _ = try p.expectToken(.l_paren); |
| 3723 | const expr = try p.expectExpr(); | 3723 | const expr = try p.expectExpr(); |
| 3724 | _ = try p.expectToken(.RParen); | 3724 | _ = try p.expectToken(.r_paren); |
| 3725 | return expr; | 3725 | return expr; |
| 3726 | } | 3726 | } |
| 3727 | 3727 | ||
| ... | @@ -3732,22 +3732,22 @@ const Parser = struct { | ... | @@ -3732,22 +3732,22 @@ const Parser = struct { |
| 3732 | 3732 | ||
| 3733 | /// ParamDeclList <- (ParamDecl COMMA)* ParamDecl? | 3733 | /// ParamDeclList <- (ParamDecl COMMA)* ParamDecl? |
| 3734 | fn parseParamDeclList(p: *Parser) !SmallSpan { | 3734 | fn parseParamDeclList(p: *Parser) !SmallSpan { |
| 3735 | _ = try p.expectToken(.LParen); | 3735 | _ = try p.expectToken(.l_paren); |
| 3736 | if (p.eatToken(.RParen)) |_| { | 3736 | if (p.eatToken(.r_paren)) |_| { |
| 3737 | return SmallSpan{ .zero_or_one = 0 }; | 3737 | return SmallSpan{ .zero_or_one = 0 }; |
| 3738 | } | 3738 | } |
| 3739 | const param_one = while (true) { | 3739 | const param_one = while (true) { |
| 3740 | const param = try p.expectParamDecl(); | 3740 | const param = try p.expectParamDecl(); |
| 3741 | if (param != 0) break param; | 3741 | if (param != 0) break param; |
| 3742 | switch (p.token_tags[p.nextToken()]) { | 3742 | switch (p.token_tags[p.nextToken()]) { |
| 3743 | .Comma => continue, | 3743 | .comma => continue, |
| 3744 | .RParen => return SmallSpan{ .zero_or_one = 0 }, | 3744 | .r_paren => return SmallSpan{ .zero_or_one = 0 }, |
| 3745 | else => { | 3745 | else => { |
| 3746 | // This is likely just a missing comma; | 3746 | // This is likely just a missing comma; |
| 3747 | // give an error but continue parsing this list. | 3747 | // give an error but continue parsing this list. |
| 3748 | p.tok_i -= 1; | 3748 | p.tok_i -= 1; |
| 3749 | try p.warn(.{ | 3749 | try p.warn(.{ |
| 3750 | .ExpectedToken = .{ .token = p.tok_i, .expected_id = .Comma }, | 3750 | .ExpectedToken = .{ .token = p.tok_i, .expected_id = .comma }, |
| 3751 | }); | 3751 | }); |
| 3752 | }, | 3752 | }, |
| 3753 | } | 3753 | } |
| ... | @@ -3755,19 +3755,19 @@ const Parser = struct { | ... | @@ -3755,19 +3755,19 @@ const Parser = struct { |
| 3755 | 3755 | ||
| 3756 | const param_two = while (true) { | 3756 | const param_two = while (true) { |
| 3757 | switch (p.token_tags[p.nextToken()]) { | 3757 | switch (p.token_tags[p.nextToken()]) { |
| 3758 | .Comma => { | 3758 | .comma => { |
| 3759 | if (p.eatToken(.RParen)) |_| { | 3759 | if (p.eatToken(.r_paren)) |_| { |
| 3760 | return SmallSpan{ .zero_or_one = param_one }; | 3760 | return SmallSpan{ .zero_or_one = param_one }; |
| 3761 | } | 3761 | } |
| 3762 | const param = try p.expectParamDecl(); | 3762 | const param = try p.expectParamDecl(); |
| 3763 | if (param != 0) break param; | 3763 | if (param != 0) break param; |
| 3764 | continue; | 3764 | continue; |
| 3765 | }, | 3765 | }, |
| 3766 | .RParen => return SmallSpan{ .zero_or_one = param_one }, | 3766 | .r_paren => return SmallSpan{ .zero_or_one = param_one }, |
| 3767 | .Colon, .RBrace, .RBracket => { | 3767 | .colon, .r_brace, .r_bracket => { |
| 3768 | p.tok_i -= 1; | 3768 | p.tok_i -= 1; |
| 3769 | return p.fail(.{ | 3769 | return p.fail(.{ |
| 3770 | .ExpectedToken = .{ .token = p.tok_i, .expected_id = .RParen }, | 3770 | .ExpectedToken = .{ .token = p.tok_i, .expected_id = .r_paren }, |
| 3771 | }); | 3771 | }); |
| 3772 | }, | 3772 | }, |
| 3773 | else => { | 3773 | else => { |
| ... | @@ -3775,7 +3775,7 @@ const Parser = struct { | ... | @@ -3775,7 +3775,7 @@ const Parser = struct { |
| 3775 | // give an error but continue parsing this list. | 3775 | // give an error but continue parsing this list. |
| 3776 | p.tok_i -= 1; | 3776 | p.tok_i -= 1; |
| 3777 | try p.warn(.{ | 3777 | try p.warn(.{ |
| 3778 | .ExpectedToken = .{ .token = p.tok_i, .expected_id = .Comma }, | 3778 | .ExpectedToken = .{ .token = p.tok_i, .expected_id = .comma }, |
| 3779 | }); | 3779 | }); |
| 3780 | }, | 3780 | }, |
| 3781 | } | 3781 | } |
| ... | @@ -3784,12 +3784,12 @@ const Parser = struct { | ... | @@ -3784,12 +3784,12 @@ const Parser = struct { |
| 3784 | var list = std.ArrayList(Node.Index).init(p.gpa); | 3784 | var list = std.ArrayList(Node.Index).init(p.gpa); |
| 3785 | defer list.deinit(); | 3785 | defer list.deinit(); |
| 3786 | 3786 | ||
| 3787 | try list.appendSlice(&[_]Node.Index{ param_one, param_two }); | 3787 | try list.appendSlice(&.{ param_one, param_two }); |
| 3788 | 3788 | ||
| 3789 | while (true) { | 3789 | while (true) { |
| 3790 | switch (p.token_tags[p.nextToken()]) { | 3790 | switch (p.token_tags[p.nextToken()]) { |
| 3791 | .Comma => { | 3791 | .comma => { |
| 3792 | if (p.token_tags[p.tok_i] == .RParen) { | 3792 | if (p.token_tags[p.tok_i] == .r_paren) { |
| 3793 | p.tok_i += 1; | 3793 | p.tok_i += 1; |
| 3794 | return SmallSpan{ .multi = list.toOwnedSlice() }; | 3794 | return SmallSpan{ .multi = list.toOwnedSlice() }; |
| 3795 | } | 3795 | } |
| ... | @@ -3799,11 +3799,11 @@ const Parser = struct { | ... | @@ -3799,11 +3799,11 @@ const Parser = struct { |
| 3799 | } | 3799 | } |
| 3800 | continue; | 3800 | continue; |
| 3801 | }, | 3801 | }, |
| 3802 | .RParen => return SmallSpan{ .multi = list.toOwnedSlice() }, | 3802 | .r_paren => return SmallSpan{ .multi = list.toOwnedSlice() }, |
| 3803 | .Colon, .RBrace, .RBracket => { | 3803 | .colon, .r_brace, .r_bracket => { |
| 3804 | p.tok_i -= 1; | 3804 | p.tok_i -= 1; |
| 3805 | return p.fail(.{ | 3805 | return p.fail(.{ |
| 3806 | .ExpectedToken = .{ .token = p.tok_i, .expected_id = .RParen }, | 3806 | .ExpectedToken = .{ .token = p.tok_i, .expected_id = .r_paren }, |
| 3807 | }); | 3807 | }); |
| 3808 | }, | 3808 | }, |
| 3809 | else => { | 3809 | else => { |
| ... | @@ -3811,7 +3811,7 @@ const Parser = struct { | ... | @@ -3811,7 +3811,7 @@ const Parser = struct { |
| 3811 | // give an error but continue parsing this list. | 3811 | // give an error but continue parsing this list. |
| 3812 | p.tok_i -= 1; | 3812 | p.tok_i -= 1; |
| 3813 | try p.warn(.{ | 3813 | try p.warn(.{ |
| 3814 | .ExpectedToken = .{ .token = p.tok_i, .expected_id = .Comma }, | 3814 | .ExpectedToken = .{ .token = p.tok_i, .expected_id = .comma }, |
| 3815 | }); | 3815 | }); |
| 3816 | }, | 3816 | }, |
| 3817 | } | 3817 | } |
| ... | @@ -3833,14 +3833,14 @@ const Parser = struct { | ... | @@ -3833,14 +3833,14 @@ const Parser = struct { |
| 3833 | try list.append(item); | 3833 | try list.append(item); |
| 3834 | 3834 | ||
| 3835 | switch (p.token_tags[p.tok_i]) { | 3835 | switch (p.token_tags[p.tok_i]) { |
| 3836 | .Comma => p.tok_i += 1, | 3836 | .comma => p.tok_i += 1, |
| 3837 | // all possible delimiters | 3837 | // all possible delimiters |
| 3838 | .Colon, .RParen, .RBrace, .RBracket => break, | 3838 | .colon, .r_paren, .r_brace, .r_bracket => break, |
| 3839 | else => { | 3839 | else => { |
| 3840 | // This is likely just a missing comma; | 3840 | // This is likely just a missing comma; |
| 3841 | // give an error but continue parsing this list. | 3841 | // give an error but continue parsing this list. |
| 3842 | try p.warn(.{ | 3842 | try p.warn(.{ |
| 3843 | .ExpectedToken = .{ .token = p.tok_i, .expected_id = .Comma }, | 3843 | .ExpectedToken = .{ .token = p.tok_i, .expected_id = .comma }, |
| 3844 | }); | 3844 | }); |
| 3845 | }, | 3845 | }, |
| 3846 | } | 3846 | } |
| ... | @@ -3853,8 +3853,8 @@ const Parser = struct { | ... | @@ -3853,8 +3853,8 @@ const Parser = struct { |
| 3853 | /// FnCallArguments <- LPAREN ExprList RPAREN | 3853 | /// FnCallArguments <- LPAREN ExprList RPAREN |
| 3854 | /// ExprList <- (Expr COMMA)* Expr? | 3854 | /// ExprList <- (Expr COMMA)* Expr? |
| 3855 | fn parseBuiltinCall(p: *Parser) !Node.Index { | 3855 | fn parseBuiltinCall(p: *Parser) !Node.Index { |
| 3856 | const builtin_token = p.assertToken(.Builtin); | 3856 | const builtin_token = p.assertToken(.builtin); |
| 3857 | _ = (try p.expectTokenRecoverable(.LParen)) orelse { | 3857 | _ = (try p.expectTokenRecoverable(.l_paren)) orelse { |
| 3858 | try p.warn(.{ | 3858 | try p.warn(.{ |
| 3859 | .ExpectedParamList = .{ .token = p.tok_i }, | 3859 | .ExpectedParamList = .{ .token = p.tok_i }, |
| 3860 | }); | 3860 | }); |
| ... | @@ -3868,7 +3868,7 @@ const Parser = struct { | ... | @@ -3868,7 +3868,7 @@ const Parser = struct { |
| 3868 | }, | 3868 | }, |
| 3869 | }); | 3869 | }); |
| 3870 | }; | 3870 | }; |
| 3871 | if (p.eatToken(.RParen)) |_| { | 3871 | if (p.eatToken(.r_paren)) |_| { |
| 3872 | return p.addNode(.{ | 3872 | return p.addNode(.{ |
| 3873 | .tag = .BuiltinCallTwo, | 3873 | .tag = .BuiltinCallTwo, |
| 3874 | .main_token = builtin_token, | 3874 | .main_token = builtin_token, |
| ... | @@ -3880,8 +3880,8 @@ const Parser = struct { | ... | @@ -3880,8 +3880,8 @@ const Parser = struct { |
| 3880 | } | 3880 | } |
| 3881 | const param_one = try p.expectExpr(); | 3881 | const param_one = try p.expectExpr(); |
| 3882 | switch (p.token_tags[p.nextToken()]) { | 3882 | switch (p.token_tags[p.nextToken()]) { |
| 3883 | .Comma => { | 3883 | .comma => { |
| 3884 | if (p.eatToken(.RParen)) |_| { | 3884 | if (p.eatToken(.r_paren)) |_| { |
| 3885 | return p.addNode(.{ | 3885 | return p.addNode(.{ |
| 3886 | .tag = .BuiltinCallTwoComma, | 3886 | .tag = .BuiltinCallTwoComma, |
| 3887 | .main_token = builtin_token, | 3887 | .main_token = builtin_token, |
| ... | @@ -3892,7 +3892,7 @@ const Parser = struct { | ... | @@ -3892,7 +3892,7 @@ const Parser = struct { |
| 3892 | }); | 3892 | }); |
| 3893 | } | 3893 | } |
| 3894 | }, | 3894 | }, |
| 3895 | .RParen => return p.addNode(.{ | 3895 | .r_paren => return p.addNode(.{ |
| 3896 | .tag = .BuiltinCallTwo, | 3896 | .tag = .BuiltinCallTwo, |
| 3897 | .main_token = builtin_token, | 3897 | .main_token = builtin_token, |
| 3898 | .data = .{ | 3898 | .data = .{ |
| ... | @@ -3905,14 +3905,14 @@ const Parser = struct { | ... | @@ -3905,14 +3905,14 @@ const Parser = struct { |
| 3905 | // give an error but continue parsing this list. | 3905 | // give an error but continue parsing this list. |
| 3906 | p.tok_i -= 1; | 3906 | p.tok_i -= 1; |
| 3907 | try p.warn(.{ | 3907 | try p.warn(.{ |
| 3908 | .ExpectedToken = .{ .token = p.tok_i, .expected_id = .Comma }, | 3908 | .ExpectedToken = .{ .token = p.tok_i, .expected_id = .comma }, |
| 3909 | }); | 3909 | }); |
| 3910 | }, | 3910 | }, |
| 3911 | } | 3911 | } |
| 3912 | const param_two = try p.expectExpr(); | 3912 | const param_two = try p.expectExpr(); |
| 3913 | switch (p.token_tags[p.nextToken()]) { | 3913 | switch (p.token_tags[p.nextToken()]) { |
| 3914 | .Comma => { | 3914 | .comma => { |
| 3915 | if (p.eatToken(.RParen)) |_| { | 3915 | if (p.eatToken(.r_paren)) |_| { |
| 3916 | return p.addNode(.{ | 3916 | return p.addNode(.{ |
| 3917 | .tag = .BuiltinCallTwoComma, | 3917 | .tag = .BuiltinCallTwoComma, |
| 3918 | .main_token = builtin_token, | 3918 | .main_token = builtin_token, |
| ... | @@ -3923,7 +3923,7 @@ const Parser = struct { | ... | @@ -3923,7 +3923,7 @@ const Parser = struct { |
| 3923 | }); | 3923 | }); |
| 3924 | } | 3924 | } |
| 3925 | }, | 3925 | }, |
| 3926 | .RParen => return p.addNode(.{ | 3926 | .r_paren => return p.addNode(.{ |
| 3927 | .tag = .BuiltinCallTwo, | 3927 | .tag = .BuiltinCallTwo, |
| 3928 | .main_token = builtin_token, | 3928 | .main_token = builtin_token, |
| 3929 | .data = .{ | 3929 | .data = .{ |
| ... | @@ -3936,7 +3936,7 @@ const Parser = struct { | ... | @@ -3936,7 +3936,7 @@ const Parser = struct { |
| 3936 | // give an error but continue parsing this list. | 3936 | // give an error but continue parsing this list. |
| 3937 | p.tok_i -= 1; | 3937 | p.tok_i -= 1; |
| 3938 | try p.warn(.{ | 3938 | try p.warn(.{ |
| 3939 | .ExpectedToken = .{ .token = p.tok_i, .expected_id = .Comma }, | 3939 | .ExpectedToken = .{ .token = p.tok_i, .expected_id = .comma }, |
| 3940 | }); | 3940 | }); |
| 3941 | }, | 3941 | }, |
| 3942 | } | 3942 | } |
| ... | @@ -3944,14 +3944,14 @@ const Parser = struct { | ... | @@ -3944,14 +3944,14 @@ const Parser = struct { |
| 3944 | var list = std.ArrayList(Node.Index).init(p.gpa); | 3944 | var list = std.ArrayList(Node.Index).init(p.gpa); |
| 3945 | defer list.deinit(); | 3945 | defer list.deinit(); |
| 3946 | 3946 | ||
| 3947 | try list.appendSlice(&[_]Node.Index{ param_one, param_two }); | 3947 | try list.appendSlice(&.{ param_one, param_two }); |
| 3948 | 3948 | ||
| 3949 | while (true) { | 3949 | while (true) { |
| 3950 | const param = try p.expectExpr(); | 3950 | const param = try p.expectExpr(); |
| 3951 | try list.append(param); | 3951 | try list.append(param); |
| 3952 | switch (p.token_tags[p.nextToken()]) { | 3952 | switch (p.token_tags[p.nextToken()]) { |
| 3953 | .Comma => { | 3953 | .comma => { |
| 3954 | if (p.eatToken(.RParen)) |_| { | 3954 | if (p.eatToken(.r_paren)) |_| { |
| 3955 | const params = try p.listToSpan(list.items); | 3955 | const params = try p.listToSpan(list.items); |
| 3956 | return p.addNode(.{ | 3956 | return p.addNode(.{ |
| 3957 | .tag = .BuiltinCallComma, | 3957 | .tag = .BuiltinCallComma, |
| ... | @@ -3964,7 +3964,7 @@ const Parser = struct { | ... | @@ -3964,7 +3964,7 @@ const Parser = struct { |
| 3964 | } | 3964 | } |
| 3965 | continue; | 3965 | continue; |
| 3966 | }, | 3966 | }, |
| 3967 | .RParen => { | 3967 | .r_paren => { |
| 3968 | const params = try p.listToSpan(list.items); | 3968 | const params = try p.listToSpan(list.items); |
| 3969 | return p.addNode(.{ | 3969 | return p.addNode(.{ |
| 3970 | .tag = .BuiltinCall, | 3970 | .tag = .BuiltinCall, |
| ... | @@ -3980,7 +3980,7 @@ const Parser = struct { | ... | @@ -3980,7 +3980,7 @@ const Parser = struct { |
| 3980 | // give an error but continue parsing this list. | 3980 | // give an error but continue parsing this list. |
| 3981 | p.tok_i -= 1; | 3981 | p.tok_i -= 1; |
| 3982 | try p.warn(.{ | 3982 | try p.warn(.{ |
| 3983 | .ExpectedToken = .{ .token = p.tok_i, .expected_id = .Comma }, | 3983 | .ExpectedToken = .{ .token = p.tok_i, .expected_id = .comma }, |
| 3984 | }); | 3984 | }); |
| 3985 | }, | 3985 | }, |
| 3986 | } | 3986 | } |
| ... | @@ -3990,7 +3990,7 @@ const Parser = struct { | ... | @@ -3990,7 +3990,7 @@ const Parser = struct { |
| 3990 | // string literal or multiline string literal | 3990 | // string literal or multiline string literal |
| 3991 | fn parseStringLiteral(p: *Parser) !Node.Index { | 3991 | fn parseStringLiteral(p: *Parser) !Node.Index { |
| 3992 | switch (p.token_tags[p.tok_i]) { | 3992 | switch (p.token_tags[p.tok_i]) { |
| 3993 | .StringLiteral => { | 3993 | .string_literal => { |
| 3994 | const main_token = p.nextToken(); | 3994 | const main_token = p.nextToken(); |
| 3995 | return p.addNode(.{ | 3995 | return p.addNode(.{ |
| 3996 | .tag = .StringLiteral, | 3996 | .tag = .StringLiteral, |
| ... | @@ -4001,9 +4001,9 @@ const Parser = struct { | ... | @@ -4001,9 +4001,9 @@ const Parser = struct { |
| 4001 | }, | 4001 | }, |
| 4002 | }); | 4002 | }); |
| 4003 | }, | 4003 | }, |
| 4004 | .MultilineStringLiteralLine => { | 4004 | .multiline_string_literal_line => { |
| 4005 | const first_line = p.nextToken(); | 4005 | 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) { |
| 4007 | p.tok_i += 1; | 4007 | p.tok_i += 1; |
| 4008 | } | 4008 | } |
| 4009 | return p.addNode(.{ | 4009 | return p.addNode(.{ |
| ... | @@ -4030,7 +4030,7 @@ const Parser = struct { | ... | @@ -4030,7 +4030,7 @@ const Parser = struct { |
| 4030 | fn expectIntegerLiteral(p: *Parser) !Node.Index { | 4030 | fn expectIntegerLiteral(p: *Parser) !Node.Index { |
| 4031 | return p.addNode(.{ | 4031 | return p.addNode(.{ |
| 4032 | .tag = .IntegerLiteral, | 4032 | .tag = .IntegerLiteral, |
| 4033 | .main_token = try p.expectToken(.IntegerLiteral), | 4033 | .main_token = try p.expectToken(.integer_literal), |
| 4034 | .data = .{ | 4034 | .data = .{ |
| 4035 | .lhs = undefined, | 4035 | .lhs = undefined, |
| 4036 | .rhs = undefined, | 4036 | .rhs = undefined, |
| ... | @@ -4040,16 +4040,16 @@ const Parser = struct { | ... | @@ -4040,16 +4040,16 @@ const Parser = struct { |
| 4040 | 4040 | ||
| 4041 | /// KEYWORD_if LPAREN Expr RPAREN PtrPayload? Body (KEYWORD_else Payload? Body)? | 4041 | /// KEYWORD_if LPAREN Expr RPAREN PtrPayload? Body (KEYWORD_else Payload? Body)? |
| 4042 | fn parseIf(p: *Parser, bodyParseFn: NodeParseFn) !Node.Index { | 4042 | fn parseIf(p: *Parser, bodyParseFn: NodeParseFn) !Node.Index { |
| 4043 | const if_token = p.eatToken(.Keyword_if) orelse return null_node; | 4043 | const if_token = p.eatToken(.keyword_if) orelse return null_node; |
| 4044 | _ = try p.expectToken(.LParen); | 4044 | _ = try p.expectToken(.l_paren); |
| 4045 | const condition = try p.expectExpr(); | 4045 | const condition = try p.expectExpr(); |
| 4046 | _ = try p.expectToken(.RParen); | 4046 | _ = try p.expectToken(.r_paren); |
| 4047 | const then_payload = try p.parsePtrPayload(); | 4047 | const then_payload = try p.parsePtrPayload(); |
| 4048 | 4048 | ||
| 4049 | const then_expr = try bodyParseFn(p); | 4049 | const then_expr = try bodyParseFn(p); |
| 4050 | if (then_expr == 0) return p.fail(.{ .InvalidToken = .{ .token = p.tok_i } }); | 4050 | if (then_expr == 0) return p.fail(.{ .InvalidToken = .{ .token = p.tok_i } }); |
| 4051 | 4051 | ||
| 4052 | const else_token = p.eatToken(.Keyword_else) orelse return p.addNode(.{ | 4052 | const else_token = p.eatToken(.keyword_else) orelse return p.addNode(.{ |
| 4053 | .tag = .IfSimple, | 4053 | .tag = .IfSimple, |
| 4054 | .main_token = if_token, | 4054 | .main_token = if_token, |
| 4055 | .data = .{ | 4055 | .data = .{ |
| ... | @@ -4076,8 +4076,8 @@ const Parser = struct { | ... | @@ -4076,8 +4076,8 @@ const Parser = struct { |
| 4076 | 4076 | ||
| 4077 | /// Skips over doc comment tokens. Returns the first one, if any. | 4077 | /// Skips over doc comment tokens. Returns the first one, if any. |
| 4078 | fn eatDocComments(p: *Parser) ?TokenIndex { | 4078 | fn eatDocComments(p: *Parser) ?TokenIndex { |
| 4079 | if (p.eatToken(.DocComment)) |first_line| { | 4079 | if (p.eatToken(.doc_comment)) |first_line| { |
| 4080 | while (p.eatToken(.DocComment)) |_| {} | 4080 | while (p.eatToken(.doc_comment)) |_| {} |
| 4081 | return first_line; | 4081 | return first_line; |
| 4082 | } | 4082 | } |
| 4083 | return null; | 4083 | return null; |
| ... | @@ -4089,7 +4089,7 @@ const Parser = struct { | ... | @@ -4089,7 +4089,7 @@ const Parser = struct { |
| 4089 | 4089 | ||
| 4090 | /// Eat a single-line doc comment on the same line as another node | 4090 | /// Eat a single-line doc comment on the same line as another node |
| 4091 | fn parseAppendedDocComment(p: *Parser, after_token: TokenIndex) !void { | 4091 | 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; |
| 4093 | if (!p.tokensOnSameLine(after_token, comment_token)) { | 4093 | if (!p.tokensOnSameLine(after_token, comment_token)) { |
| 4094 | p.tok_i -= 1; | 4094 | p.tok_i -= 1; |
| 4095 | } | 4095 | } |
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 | ... | @@ -107,12 +107,12 @@ fn renderMember(ais: *Ais, tree: ast.Tree, decl: ast.Node.Index, space: Space) E |
| 107 | while (i > 0) { | 107 | while (i > 0) { |
| 108 | i -= 1; | 108 | i -= 1; |
| 109 | switch (token_tags[i]) { | 109 | switch (token_tags[i]) { |
| 110 | .Keyword_extern, | 110 | .keyword_extern, |
| 111 | .Keyword_export, | 111 | .keyword_export, |
| 112 | .Keyword_pub, | 112 | .keyword_pub, |
| 113 | .StringLiteral, | 113 | .string_literal, |
| 114 | .Keyword_inline, | 114 | .keyword_inline, |
| 115 | .Keyword_noinline, | 115 | .keyword_noinline, |
| 116 | => continue, | 116 | => continue, |
| 117 | 117 | ||
| 118 | else => { | 118 | else => { |
| ... | @@ -144,7 +144,7 @@ fn renderMember(ais: *Ais, tree: ast.Tree, decl: ast.Node.Index, space: Space) E | ... | @@ -144,7 +144,7 @@ fn renderMember(ais: *Ais, tree: ast.Tree, decl: ast.Node.Index, space: Space) E |
| 144 | .UsingNamespace => { | 144 | .UsingNamespace => { |
| 145 | const main_token = main_tokens[decl]; | 145 | const main_token = main_tokens[decl]; |
| 146 | const expr = datas[decl].lhs; | 146 | 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) { |
| 148 | try renderToken(ais, tree, main_token - 1, .Space); // pub | 148 | try renderToken(ais, tree, main_token - 1, .Space); // pub |
| 149 | } | 149 | } |
| 150 | try renderToken(ais, tree, main_token, .Space); // usingnamespace | 150 | 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 | ... | @@ -160,7 +160,7 @@ fn renderMember(ais: *Ais, tree: ast.Tree, decl: ast.Node.Index, space: Space) E |
| 160 | .TestDecl => { | 160 | .TestDecl => { |
| 161 | const test_token = main_tokens[decl]; | 161 | const test_token = main_tokens[decl]; |
| 162 | try renderToken(ais, tree, test_token, .Space); | 162 | try renderToken(ais, tree, test_token, .Space); |
| 163 | if (token_tags[test_token + 1] == .StringLiteral) { | 163 | if (token_tags[test_token + 1] == .string_literal) { |
| 164 | try renderToken(ais, tree, test_token + 1, .Space); | 164 | try renderToken(ais, tree, test_token + 1, .Space); |
| 165 | } | 165 | } |
| 166 | try renderExpression(ais, tree, datas[decl].rhs, space); | 166 | 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 | ... | @@ -269,13 +269,13 @@ fn renderExpression(ais: *Ais, tree: ast.Tree, node: ast.Node.Index, space: Spac |
| 269 | 269 | ||
| 270 | try renderExpression(ais, tree, datas[node].lhs, .Space); // target | 270 | try renderExpression(ais, tree, datas[node].lhs, .Space); // target |
| 271 | 271 | ||
| 272 | if (token_tags[fallback_first - 1] == .Pipe) { | 272 | if (token_tags[fallback_first - 1] == .pipe) { |
| 273 | try renderToken(ais, tree, main_token, .Space); // catch keyword | 273 | try renderToken(ais, tree, main_token, .Space); // catch keyword |
| 274 | try renderToken(ais, tree, main_token + 1, .None); // pipe | 274 | try renderToken(ais, tree, main_token + 1, .None); // pipe |
| 275 | try renderToken(ais, tree, main_token + 2, .None); // payload identifier | 275 | try renderToken(ais, tree, main_token + 2, .None); // payload identifier |
| 276 | try renderToken(ais, tree, main_token + 3, after_op_space); // pipe | 276 | try renderToken(ais, tree, main_token + 3, after_op_space); // pipe |
| 277 | } else { | 277 | } else { |
| 278 | assert(token_tags[fallback_first - 1] == .Keyword_catch); | 278 | assert(token_tags[fallback_first - 1] == .keyword_catch); |
| 279 | try renderToken(ais, tree, main_token, after_op_space); // catch keyword | 279 | try renderToken(ais, tree, main_token, after_op_space); // catch keyword |
| 280 | } | 280 | } |
| 281 | 281 | ||
| ... | @@ -532,22 +532,22 @@ fn renderExpression(ais: *Ais, tree: ast.Tree, node: ast.Node.Index, space: Spac | ... | @@ -532,22 +532,22 @@ fn renderExpression(ais: *Ais, tree: ast.Tree, node: ast.Node.Index, space: Spac |
| 532 | // There is nothing between the braces so render condensed: `error{}` | 532 | // There is nothing between the braces so render condensed: `error{}` |
| 533 | try renderToken(ais, tree, lbrace, .None); | 533 | try renderToken(ais, tree, lbrace, .None); |
| 534 | return renderToken(ais, tree, rbrace, space); | 534 | 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) { |
| 536 | // There is exactly one member and no trailing comma or | 536 | // There is exactly one member and no trailing comma or |
| 537 | // comments, so render without surrounding spaces: `error{Foo}` | 537 | // comments, so render without surrounding spaces: `error{Foo}` |
| 538 | try renderToken(ais, tree, lbrace, .None); | 538 | try renderToken(ais, tree, lbrace, .None); |
| 539 | try renderToken(ais, tree, lbrace + 1, .None); // identifier | 539 | try renderToken(ais, tree, lbrace + 1, .None); // identifier |
| 540 | return renderToken(ais, tree, rbrace, space); | 540 | return renderToken(ais, tree, rbrace, space); |
| 541 | } else if (token_tags[rbrace - 1] == .Comma) { | 541 | } else if (token_tags[rbrace - 1] == .comma) { |
| 542 | // There is a trailing comma so render each member on a new line. | 542 | // There is a trailing comma so render each member on a new line. |
| 543 | try renderToken(ais, tree, lbrace, .Newline); | 543 | try renderToken(ais, tree, lbrace, .Newline); |
| 544 | ais.pushIndent(); | 544 | ais.pushIndent(); |
| 545 | var i = lbrace + 1; | 545 | var i = lbrace + 1; |
| 546 | while (i < rbrace) : (i += 1) { | 546 | while (i < rbrace) : (i += 1) { |
| 547 | switch (token_tags[i]) { | 547 | switch (token_tags[i]) { |
| 548 | .DocComment => try renderToken(ais, tree, i, .Newline), | 548 | .doc_comment => try renderToken(ais, tree, i, .Newline), |
| 549 | .Identifier => try renderToken(ais, tree, i, .Comma), | 549 | .identifier => try renderToken(ais, tree, i, .Comma), |
| 550 | .Comma => {}, | 550 | .comma => {}, |
| 551 | else => unreachable, | 551 | else => unreachable, |
| 552 | } | 552 | } |
| 553 | } | 553 | } |
| ... | @@ -559,9 +559,9 @@ fn renderExpression(ais: *Ais, tree: ast.Tree, node: ast.Node.Index, space: Spac | ... | @@ -559,9 +559,9 @@ fn renderExpression(ais: *Ais, tree: ast.Tree, node: ast.Node.Index, space: Spac |
| 559 | var i = lbrace + 1; | 559 | var i = lbrace + 1; |
| 560 | while (i < rbrace) : (i += 1) { | 560 | while (i < rbrace) : (i += 1) { |
| 561 | switch (token_tags[i]) { | 561 | switch (token_tags[i]) { |
| 562 | .DocComment => unreachable, // TODO | 562 | .doc_comment => unreachable, // TODO |
| 563 | .Identifier => try renderToken(ais, tree, i, .CommaSpace), | 563 | .identifier => try renderToken(ais, tree, i, .CommaSpace), |
| 564 | .Comma => {}, | 564 | .comma => {}, |
| 565 | else => unreachable, | 565 | else => unreachable, |
| 566 | } | 566 | } |
| 567 | } | 567 | } |
| ... | @@ -701,7 +701,7 @@ fn renderPtrType( | ... | @@ -701,7 +701,7 @@ fn renderPtrType( |
| 701 | // in such a relationship. If so, skip rendering anything for | 701 | // in such a relationship. If so, skip rendering anything for |
| 702 | // this pointer type and rely on the child to render our asterisk | 702 | // this pointer type and rely on the child to render our asterisk |
| 703 | // as well when it renders the ** token. | 703 | // 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 |
| 705 | ptr_type.ast.main_token == tree.nodes.items(.main_token)[ptr_type.ast.child_type]) | 705 | ptr_type.ast.main_token == tree.nodes.items(.main_token)[ptr_type.ast.child_type]) |
| 706 | { | 706 | { |
| 707 | return renderExpression(ais, tree, ptr_type.ast.child_type, space); | 707 | return renderExpression(ais, tree, ptr_type.ast.child_type, space); |
| ... | @@ -823,7 +823,7 @@ fn renderAsmOutput( | ... | @@ -823,7 +823,7 @@ fn renderAsmOutput( |
| 823 | try renderToken(ais, tree, symbolic_name + 2, .Space); // "constraint" | 823 | try renderToken(ais, tree, symbolic_name + 2, .Space); // "constraint" |
| 824 | try renderToken(ais, tree, symbolic_name + 3, .None); // lparen | 824 | try renderToken(ais, tree, symbolic_name + 3, .None); // lparen |
| 825 | 825 | ||
| 826 | if (token_tags[symbolic_name + 4] == .Arrow) { | 826 | if (token_tags[symbolic_name + 4] == .arrow) { |
| 827 | try renderToken(ais, tree, symbolic_name + 4, .Space); // -> | 827 | try renderToken(ais, tree, symbolic_name + 4, .Space); // -> |
| 828 | try renderExpression(ais, tree, datas[asm_output].lhs, Space.None); | 828 | try renderExpression(ais, tree, datas[asm_output].lhs, Space.None); |
| 829 | return renderToken(ais, tree, datas[asm_output].rhs, space); // rparen | 829 | 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 | ... | @@ -982,7 +982,7 @@ fn renderWhile(ais: *Ais, tree: ast.Tree, while_node: ast.full.While, space: Spa |
| 982 | try renderToken(ais, tree, payload_token - 2, .Space); // ) | 982 | try renderToken(ais, tree, payload_token - 2, .Space); // ) |
| 983 | try renderToken(ais, tree, payload_token - 1, .None); // | | 983 | try renderToken(ais, tree, payload_token - 1, .None); // | |
| 984 | const ident = blk: { | 984 | const ident = blk: { |
| 985 | if (token_tags[payload_token] == .Asterisk) { | 985 | if (token_tags[payload_token] == .asterisk) { |
| 986 | try renderToken(ais, tree, payload_token, .None); // * | 986 | try renderToken(ais, tree, payload_token, .None); // * |
| 987 | break :blk payload_token + 1; | 987 | break :blk payload_token + 1; |
| 988 | } else { | 988 | } else { |
| ... | @@ -991,7 +991,7 @@ fn renderWhile(ais: *Ais, tree: ast.Tree, while_node: ast.full.While, space: Spa | ... | @@ -991,7 +991,7 @@ fn renderWhile(ais: *Ais, tree: ast.Tree, while_node: ast.full.While, space: Spa |
| 991 | }; | 991 | }; |
| 992 | try renderToken(ais, tree, ident, .None); // identifier | 992 | try renderToken(ais, tree, ident, .None); // identifier |
| 993 | const pipe = blk: { | 993 | const pipe = blk: { |
| 994 | if (token_tags[ident + 1] == .Comma) { | 994 | if (token_tags[ident + 1] == .comma) { |
| 995 | try renderToken(ais, tree, ident + 1, .Space); // , | 995 | try renderToken(ais, tree, ident + 1, .Space); // , |
| 996 | try renderToken(ais, tree, ident + 2, .None); // index | 996 | try renderToken(ais, tree, ident + 2, .None); // index |
| 997 | break :blk payload_token + 3; | 997 | break :blk payload_token + 3; |
| ... | @@ -1035,7 +1035,7 @@ fn renderWhile(ais: *Ais, tree: ast.Tree, while_node: ast.full.While, space: Spa | ... | @@ -1035,7 +1035,7 @@ fn renderWhile(ais: *Ais, tree: ast.Tree, while_node: ast.full.While, space: Spa |
| 1035 | try renderToken(ais, tree, payload_token - 2, .Space); // ) | 1035 | try renderToken(ais, tree, payload_token - 2, .Space); // ) |
| 1036 | try renderToken(ais, tree, payload_token - 1, .None); // | | 1036 | try renderToken(ais, tree, payload_token - 1, .None); // | |
| 1037 | const ident = blk: { | 1037 | const ident = blk: { |
| 1038 | if (token_tags[payload_token] == .Asterisk) { | 1038 | if (token_tags[payload_token] == .asterisk) { |
| 1039 | try renderToken(ais, tree, payload_token, .None); // * | 1039 | try renderToken(ais, tree, payload_token, .None); // * |
| 1040 | break :blk payload_token + 1; | 1040 | break :blk payload_token + 1; |
| 1041 | } else { | 1041 | } else { |
| ... | @@ -1044,7 +1044,7 @@ fn renderWhile(ais: *Ais, tree: ast.Tree, while_node: ast.full.While, space: Spa | ... | @@ -1044,7 +1044,7 @@ fn renderWhile(ais: *Ais, tree: ast.Tree, while_node: ast.full.While, space: Spa |
| 1044 | }; | 1044 | }; |
| 1045 | try renderToken(ais, tree, ident, .None); // identifier | 1045 | try renderToken(ais, tree, ident, .None); // identifier |
| 1046 | const pipe = blk: { | 1046 | const pipe = blk: { |
| 1047 | if (token_tags[ident + 1] == .Comma) { | 1047 | if (token_tags[ident + 1] == .comma) { |
| 1048 | try renderToken(ais, tree, ident + 1, .Space); // , | 1048 | try renderToken(ais, tree, ident + 1, .Space); // , |
| 1049 | try renderToken(ais, tree, ident + 2, .None); // index | 1049 | try renderToken(ais, tree, ident + 2, .None); // index |
| 1050 | break :blk payload_token + 3; | 1050 | break :blk payload_token + 3; |
| ... | @@ -1108,7 +1108,7 @@ fn renderWhile(ais: *Ais, tree: ast.Tree, while_node: ast.full.While, space: Spa | ... | @@ -1108,7 +1108,7 @@ fn renderWhile(ais: *Ais, tree: ast.Tree, while_node: ast.full.While, space: Spa |
| 1108 | try renderToken(ais, tree, payload_token - 2, .Space); // ) | 1108 | try renderToken(ais, tree, payload_token - 2, .Space); // ) |
| 1109 | try renderToken(ais, tree, payload_token - 1, .None); // | | 1109 | try renderToken(ais, tree, payload_token - 1, .None); // | |
| 1110 | const ident = blk: { | 1110 | const ident = blk: { |
| 1111 | if (token_tags[payload_token] == .Asterisk) { | 1111 | if (token_tags[payload_token] == .asterisk) { |
| 1112 | try renderToken(ais, tree, payload_token, .None); // * | 1112 | try renderToken(ais, tree, payload_token, .None); // * |
| 1113 | break :blk payload_token + 1; | 1113 | break :blk payload_token + 1; |
| 1114 | } else { | 1114 | } else { |
| ... | @@ -1117,7 +1117,7 @@ fn renderWhile(ais: *Ais, tree: ast.Tree, while_node: ast.full.While, space: Spa | ... | @@ -1117,7 +1117,7 @@ fn renderWhile(ais: *Ais, tree: ast.Tree, while_node: ast.full.While, space: Spa |
| 1117 | }; | 1117 | }; |
| 1118 | try renderToken(ais, tree, ident, .None); // identifier | 1118 | try renderToken(ais, tree, ident, .None); // identifier |
| 1119 | const pipe = blk: { | 1119 | const pipe = blk: { |
| 1120 | if (token_tags[ident + 1] == .Comma) { | 1120 | if (token_tags[ident + 1] == .comma) { |
| 1121 | try renderToken(ais, tree, ident + 1, .Space); // , | 1121 | try renderToken(ais, tree, ident + 1, .Space); // , |
| 1122 | try renderToken(ais, tree, ident + 2, .None); // index | 1122 | try renderToken(ais, tree, ident + 2, .None); // index |
| 1123 | break :blk payload_token + 3; | 1123 | break :blk payload_token + 3; |
| ... | @@ -1227,7 +1227,7 @@ fn renderBuiltinCall( | ... | @@ -1227,7 +1227,7 @@ fn renderBuiltinCall( |
| 1227 | const last_param = params[params.len - 1]; | 1227 | const last_param = params[params.len - 1]; |
| 1228 | const after_last_param_token = tree.lastToken(last_param) + 1; | 1228 | const after_last_param_token = tree.lastToken(last_param) + 1; |
| 1229 | 1229 | ||
| 1230 | if (token_tags[after_last_param_token] != .Comma) { | 1230 | if (token_tags[after_last_param_token] != .comma) { |
| 1231 | // Render all on one line, no trailing comma. | 1231 | // Render all on one line, no trailing comma. |
| 1232 | try renderToken(ais, tree, builtin_token + 1, .None); // ( | 1232 | try renderToken(ais, tree, builtin_token + 1, .None); // ( |
| 1233 | 1233 | ||
| ... | @@ -1259,7 +1259,7 @@ fn renderFnProto(ais: *Ais, tree: ast.Tree, fn_proto: ast.full.FnProto, space: S | ... | @@ -1259,7 +1259,7 @@ fn renderFnProto(ais: *Ais, tree: ast.Tree, fn_proto: ast.full.FnProto, space: S |
| 1259 | const token_starts = tree.tokens.items(.start); | 1259 | const token_starts = tree.tokens.items(.start); |
| 1260 | 1260 | ||
| 1261 | const after_fn_token = fn_proto.ast.fn_token + 1; | 1261 | 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: { |
| 1263 | try renderToken(ais, tree, fn_proto.ast.fn_token, .Space); // fn | 1263 | try renderToken(ais, tree, fn_proto.ast.fn_token, .Space); // fn |
| 1264 | try renderToken(ais, tree, after_fn_token, .None); // name | 1264 | try renderToken(ais, tree, after_fn_token, .None); // name |
| 1265 | break :blk after_fn_token + 1; | 1265 | break :blk after_fn_token + 1; |
| ... | @@ -1267,7 +1267,7 @@ fn renderFnProto(ais: *Ais, tree: ast.Tree, fn_proto: ast.full.FnProto, space: S | ... | @@ -1267,7 +1267,7 @@ fn renderFnProto(ais: *Ais, tree: ast.Tree, fn_proto: ast.full.FnProto, space: S |
| 1267 | try renderToken(ais, tree, fn_proto.ast.fn_token, .Space); // fn | 1267 | try renderToken(ais, tree, fn_proto.ast.fn_token, .Space); // fn |
| 1268 | break :blk fn_proto.ast.fn_token + 1; | 1268 | break :blk fn_proto.ast.fn_token + 1; |
| 1269 | }; | 1269 | }; |
| 1270 | assert(token_tags[lparen] == .LParen); | 1270 | assert(token_tags[lparen] == .l_paren); |
| 1271 | 1271 | ||
| 1272 | const maybe_bang = tree.firstToken(fn_proto.ast.return_type) - 1; | 1272 | const maybe_bang = tree.firstToken(fn_proto.ast.return_type) - 1; |
| 1273 | const rparen = blk: { | 1273 | const rparen = blk: { |
| ... | @@ -1301,11 +1301,11 @@ fn renderFnProto(ais: *Ais, tree: ast.Tree, fn_proto: ast.full.FnProto, space: S | ... | @@ -1301,11 +1301,11 @@ fn renderFnProto(ais: *Ais, tree: ast.Tree, fn_proto: ast.full.FnProto, space: S |
| 1301 | } | 1301 | } |
| 1302 | break :blk rparen; | 1302 | break :blk rparen; |
| 1303 | }; | 1303 | }; |
| 1304 | assert(token_tags[rparen] == .RParen); | 1304 | assert(token_tags[rparen] == .r_paren); |
| 1305 | 1305 | ||
| 1306 | // The params list is a sparse set that does *not* include anytype or ... parameters. | 1306 | // The params list is a sparse set that does *not* include anytype or ... parameters. |
| 1307 | 1307 | ||
| 1308 | if (token_tags[rparen - 1] != .Comma) { | 1308 | if (token_tags[rparen - 1] != .comma) { |
| 1309 | // Render all on one line, no trailing comma. | 1309 | // Render all on one line, no trailing comma. |
| 1310 | try renderToken(ais, tree, lparen, .None); // ( | 1310 | try renderToken(ais, tree, lparen, .None); // ( |
| 1311 | 1311 | ||
| ... | @@ -1314,39 +1314,39 @@ fn renderFnProto(ais: *Ais, tree: ast.Tree, fn_proto: ast.full.FnProto, space: S | ... | @@ -1314,39 +1314,39 @@ fn renderFnProto(ais: *Ais, tree: ast.Tree, fn_proto: ast.full.FnProto, space: S |
| 1314 | while (true) { | 1314 | while (true) { |
| 1315 | last_param_token += 1; | 1315 | last_param_token += 1; |
| 1316 | switch (token_tags[last_param_token]) { | 1316 | switch (token_tags[last_param_token]) { |
| 1317 | .DocComment => { | 1317 | .doc_comment => { |
| 1318 | try renderToken(ais, tree, last_param_token, .Newline); | 1318 | try renderToken(ais, tree, last_param_token, .Newline); |
| 1319 | continue; | 1319 | continue; |
| 1320 | }, | 1320 | }, |
| 1321 | .Ellipsis3 => { | 1321 | .ellipsis3 => { |
| 1322 | try renderToken(ais, tree, last_param_token, .None); // ... | 1322 | try renderToken(ais, tree, last_param_token, .None); // ... |
| 1323 | break; | 1323 | break; |
| 1324 | }, | 1324 | }, |
| 1325 | .Keyword_noalias, .Keyword_comptime => { | 1325 | .keyword_noalias, .keyword_comptime => { |
| 1326 | try renderToken(ais, tree, last_param_token, .Space); | 1326 | try renderToken(ais, tree, last_param_token, .Space); |
| 1327 | last_param_token += 1; | 1327 | last_param_token += 1; |
| 1328 | }, | 1328 | }, |
| 1329 | .Identifier => {}, | 1329 | .identifier => {}, |
| 1330 | .Keyword_anytype => { | 1330 | .keyword_anytype => { |
| 1331 | try renderToken(ais, tree, last_param_token, .None); // anytype | 1331 | try renderToken(ais, tree, last_param_token, .None); // anytype |
| 1332 | continue; | 1332 | continue; |
| 1333 | }, | 1333 | }, |
| 1334 | .RParen => break, | 1334 | .r_paren => break, |
| 1335 | .Comma => { | 1335 | .comma => { |
| 1336 | try renderToken(ais, tree, last_param_token, .Space); // , | 1336 | try renderToken(ais, tree, last_param_token, .Space); // , |
| 1337 | last_param_token += 1; | 1337 | last_param_token += 1; |
| 1338 | }, | 1338 | }, |
| 1339 | else => {}, // Parameter type without a name. | 1339 | else => {}, // Parameter type without a name. |
| 1340 | } | 1340 | } |
| 1341 | if (token_tags[last_param_token] == .Identifier and | 1341 | if (token_tags[last_param_token] == .identifier and |
| 1342 | token_tags[last_param_token + 1] == .Colon) | 1342 | token_tags[last_param_token + 1] == .colon) |
| 1343 | { | 1343 | { |
| 1344 | try renderToken(ais, tree, last_param_token, .None); // name | 1344 | try renderToken(ais, tree, last_param_token, .None); // name |
| 1345 | last_param_token += 1; | 1345 | last_param_token += 1; |
| 1346 | try renderToken(ais, tree, last_param_token, .Space); // : | 1346 | try renderToken(ais, tree, last_param_token, .Space); // : |
| 1347 | last_param_token += 1; | 1347 | last_param_token += 1; |
| 1348 | } | 1348 | } |
| 1349 | if (token_tags[last_param_token] == .Keyword_anytype) { | 1349 | if (token_tags[last_param_token] == .keyword_anytype) { |
| 1350 | try renderToken(ais, tree, last_param_token, .None); // anytype | 1350 | try renderToken(ais, tree, last_param_token, .None); // anytype |
| 1351 | continue; | 1351 | continue; |
| 1352 | } | 1352 | } |
| ... | @@ -1365,33 +1365,33 @@ fn renderFnProto(ais: *Ais, tree: ast.Tree, fn_proto: ast.full.FnProto, space: S | ... | @@ -1365,33 +1365,33 @@ fn renderFnProto(ais: *Ais, tree: ast.Tree, fn_proto: ast.full.FnProto, space: S |
| 1365 | while (true) { | 1365 | while (true) { |
| 1366 | last_param_token += 1; | 1366 | last_param_token += 1; |
| 1367 | switch (token_tags[last_param_token]) { | 1367 | switch (token_tags[last_param_token]) { |
| 1368 | .DocComment => { | 1368 | .doc_comment => { |
| 1369 | try renderToken(ais, tree, last_param_token, .Newline); | 1369 | try renderToken(ais, tree, last_param_token, .Newline); |
| 1370 | continue; | 1370 | continue; |
| 1371 | }, | 1371 | }, |
| 1372 | .Ellipsis3 => { | 1372 | .ellipsis3 => { |
| 1373 | try renderToken(ais, tree, last_param_token, .Comma); // ... | 1373 | try renderToken(ais, tree, last_param_token, .Comma); // ... |
| 1374 | break; | 1374 | break; |
| 1375 | }, | 1375 | }, |
| 1376 | .Keyword_noalias, .Keyword_comptime => { | 1376 | .keyword_noalias, .keyword_comptime => { |
| 1377 | try renderToken(ais, tree, last_param_token, .Space); | 1377 | try renderToken(ais, tree, last_param_token, .Space); |
| 1378 | last_param_token += 1; | 1378 | last_param_token += 1; |
| 1379 | }, | 1379 | }, |
| 1380 | .Identifier => {}, | 1380 | .identifier => {}, |
| 1381 | .Keyword_anytype => { | 1381 | .keyword_anytype => { |
| 1382 | try renderToken(ais, tree, last_param_token, .Comma); // anytype | 1382 | try renderToken(ais, tree, last_param_token, .Comma); // anytype |
| 1383 | continue; | 1383 | continue; |
| 1384 | }, | 1384 | }, |
| 1385 | .RParen => break, | 1385 | .r_paren => break, |
| 1386 | else => unreachable, | 1386 | else => unreachable, |
| 1387 | } | 1387 | } |
| 1388 | if (token_tags[last_param_token] == .Identifier) { | 1388 | if (token_tags[last_param_token] == .identifier) { |
| 1389 | try renderToken(ais, tree, last_param_token, .None); // name | 1389 | try renderToken(ais, tree, last_param_token, .None); // name |
| 1390 | last_param_token += 1; | 1390 | last_param_token += 1; |
| 1391 | try renderToken(ais, tree, last_param_token, .Space); // : | 1391 | try renderToken(ais, tree, last_param_token, .Space); // : |
| 1392 | last_param_token += 1; | 1392 | last_param_token += 1; |
| 1393 | } | 1393 | } |
| 1394 | if (token_tags[last_param_token] == .Keyword_anytype) { | 1394 | if (token_tags[last_param_token] == .keyword_anytype) { |
| 1395 | try renderToken(ais, tree, last_param_token, .Comma); // anytype | 1395 | try renderToken(ais, tree, last_param_token, .Comma); // anytype |
| 1396 | continue; | 1396 | continue; |
| 1397 | } | 1397 | } |
| ... | @@ -1435,7 +1435,7 @@ fn renderFnProto(ais: *Ais, tree: ast.Tree, fn_proto: ast.full.FnProto, space: S | ... | @@ -1435,7 +1435,7 @@ fn renderFnProto(ais: *Ais, tree: ast.Tree, fn_proto: ast.full.FnProto, space: S |
| 1435 | try renderToken(ais, tree, callconv_rparen, .Space); // ) | 1435 | try renderToken(ais, tree, callconv_rparen, .Space); // ) |
| 1436 | } | 1436 | } |
| 1437 | 1437 | ||
| 1438 | if (token_tags[maybe_bang] == .Bang) { | 1438 | if (token_tags[maybe_bang] == .bang) { |
| 1439 | try renderToken(ais, tree, maybe_bang, .None); // ! | 1439 | try renderToken(ais, tree, maybe_bang, .None); // ! |
| 1440 | } | 1440 | } |
| 1441 | return renderExpression(ais, tree, fn_proto.ast.return_type, space); | 1441 | return renderExpression(ais, tree, fn_proto.ast.return_type, space); |
| ... | @@ -1448,7 +1448,7 @@ fn renderSwitchCase( | ... | @@ -1448,7 +1448,7 @@ fn renderSwitchCase( |
| 1448 | space: Space, | 1448 | space: Space, |
| 1449 | ) Error!void { | 1449 | ) Error!void { |
| 1450 | const token_tags = tree.tokens.items(.tag); | 1450 | 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; |
| 1452 | 1452 | ||
| 1453 | // Render everything before the arrow | 1453 | // Render everything before the arrow |
| 1454 | if (switch_case.ast.values.len == 0) { | 1454 | if (switch_case.ast.values.len == 0) { |
| ... | @@ -1473,7 +1473,7 @@ fn renderSwitchCase( | ... | @@ -1473,7 +1473,7 @@ fn renderSwitchCase( |
| 1473 | 1473 | ||
| 1474 | if (switch_case.payload_token) |payload_token| { | 1474 | if (switch_case.payload_token) |payload_token| { |
| 1475 | try renderToken(ais, tree, payload_token - 1, .None); // pipe | 1475 | try renderToken(ais, tree, payload_token - 1, .None); // pipe |
| 1476 | if (token_tags[payload_token] == .Asterisk) { | 1476 | if (token_tags[payload_token] == .asterisk) { |
| 1477 | try renderToken(ais, tree, payload_token, .None); // asterisk | 1477 | try renderToken(ais, tree, payload_token, .None); // asterisk |
| 1478 | try renderToken(ais, tree, payload_token + 1, .None); // identifier | 1478 | try renderToken(ais, tree, payload_token + 1, .None); // identifier |
| 1479 | try renderToken(ais, tree, payload_token + 2, .Space); // pipe | 1479 | try renderToken(ais, tree, payload_token + 2, .Space); // pipe |
| ... | @@ -1498,8 +1498,8 @@ fn renderBlock( | ... | @@ -1498,8 +1498,8 @@ fn renderBlock( |
| 1498 | const nodes_data = tree.nodes.items(.data); | 1498 | const nodes_data = tree.nodes.items(.data); |
| 1499 | const lbrace = tree.nodes.items(.main_token)[block_node]; | 1499 | const lbrace = tree.nodes.items(.main_token)[block_node]; |
| 1500 | 1500 | ||
| 1501 | if (token_tags[lbrace - 1] == .Colon and | 1501 | if (token_tags[lbrace - 1] == .colon and |
| 1502 | token_tags[lbrace - 2] == .Identifier) | 1502 | token_tags[lbrace - 2] == .identifier) |
| 1503 | { | 1503 | { |
| 1504 | try renderToken(ais, tree, lbrace - 2, .None); | 1504 | try renderToken(ais, tree, lbrace - 2, .None); |
| 1505 | try renderToken(ais, tree, lbrace - 1, .Space); | 1505 | try renderToken(ais, tree, lbrace - 1, .Space); |
| ... | @@ -1547,7 +1547,7 @@ fn renderStructInit( | ... | @@ -1547,7 +1547,7 @@ fn renderStructInit( |
| 1547 | } | 1547 | } |
| 1548 | const last_field = struct_init.ast.fields[struct_init.ast.fields.len - 1]; | 1548 | const last_field = struct_init.ast.fields[struct_init.ast.fields.len - 1]; |
| 1549 | const last_field_token = tree.lastToken(last_field); | 1549 | 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) { |
| 1551 | // Render one field init per line. | 1551 | // Render one field init per line. |
| 1552 | ais.pushIndent(); | 1552 | ais.pushIndent(); |
| 1553 | try renderToken(ais, tree, struct_init.ast.lbrace, .Newline); | 1553 | try renderToken(ais, tree, struct_init.ast.lbrace, .Newline); |
| ... | @@ -1597,7 +1597,7 @@ fn renderArrayInit( | ... | @@ -1597,7 +1597,7 @@ fn renderArrayInit( |
| 1597 | } | 1597 | } |
| 1598 | const last_elem = array_init.ast.elements[array_init.ast.elements.len - 1]; | 1598 | const last_elem = array_init.ast.elements[array_init.ast.elements.len - 1]; |
| 1599 | const last_elem_token = tree.lastToken(last_elem); | 1599 | 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) { |
| 1601 | // Render one element per line. | 1601 | // Render one element per line. |
| 1602 | ais.pushIndent(); | 1602 | ais.pushIndent(); |
| 1603 | try renderToken(ais, tree, array_init.ast.lbrace, .Newline); | 1603 | try renderToken(ais, tree, array_init.ast.lbrace, .Newline); |
| ... | @@ -1673,16 +1673,16 @@ fn renderContainerDecl( | ... | @@ -1673,16 +1673,16 @@ fn renderContainerDecl( |
| 1673 | const last_member = container_decl.ast.members[container_decl.ast.members.len - 1]; | 1673 | const last_member = container_decl.ast.members[container_decl.ast.members.len - 1]; |
| 1674 | const last_member_token = tree.lastToken(last_member); | 1674 | const last_member_token = tree.lastToken(last_member); |
| 1675 | const rbrace = switch (token_tags[last_member_token + 1]) { | 1675 | const rbrace = switch (token_tags[last_member_token + 1]) { |
| 1676 | .DocComment => last_member_token + 2, | 1676 | .doc_comment => last_member_token + 2, |
| 1677 | .Comma, .Semicolon => switch (token_tags[last_member_token + 2]) { | 1677 | .comma, .semicolon => switch (token_tags[last_member_token + 2]) { |
| 1678 | .DocComment => last_member_token + 3, | 1678 | .doc_comment => last_member_token + 3, |
| 1679 | .RBrace => last_member_token + 2, | 1679 | .r_brace => last_member_token + 2, |
| 1680 | else => unreachable, | 1680 | else => unreachable, |
| 1681 | }, | 1681 | }, |
| 1682 | .RBrace => last_member_token + 1, | 1682 | .r_brace => last_member_token + 1, |
| 1683 | else => unreachable, | 1683 | else => unreachable, |
| 1684 | }; | 1684 | }; |
| 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; |
| 1686 | 1686 | ||
| 1687 | if (!src_has_trailing_comma) one_line: { | 1687 | if (!src_has_trailing_comma) one_line: { |
| 1688 | // We can only print all the members in-line if all the members are fields. | 1688 | // We can only print all the members in-line if all the members are fields. |
| ... | @@ -1734,8 +1734,8 @@ fn renderAsm( | ... | @@ -1734,8 +1734,8 @@ fn renderAsm( |
| 1734 | try renderToken(ais, tree, tok_i, .None); | 1734 | try renderToken(ais, tree, tok_i, .None); |
| 1735 | tok_i += 1; | 1735 | tok_i += 1; |
| 1736 | switch (token_tags[tok_i]) { | 1736 | switch (token_tags[tok_i]) { |
| 1737 | .RParen => return 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), | 1738 | .comma => try renderToken(ais, tree, tok_i, .Space), |
| 1739 | else => unreachable, | 1739 | else => unreachable, |
| 1740 | } | 1740 | } |
| 1741 | } | 1741 | } |
| ... | @@ -1775,7 +1775,7 @@ fn renderAsm( | ... | @@ -1775,7 +1775,7 @@ fn renderAsm( |
| 1775 | const comma_or_colon = tree.lastToken(asm_output) + 1; | 1775 | const comma_or_colon = tree.lastToken(asm_output) + 1; |
| 1776 | ais.popIndent(); | 1776 | ais.popIndent(); |
| 1777 | break :colon2 switch (token_tags[comma_or_colon]) { | 1777 | break :colon2 switch (token_tags[comma_or_colon]) { |
| 1778 | .Comma => comma_or_colon + 1, | 1778 | .comma => comma_or_colon + 1, |
| 1779 | else => comma_or_colon, | 1779 | else => comma_or_colon, |
| 1780 | }; | 1780 | }; |
| 1781 | } | 1781 | } |
| ... | @@ -1806,7 +1806,7 @@ fn renderAsm( | ... | @@ -1806,7 +1806,7 @@ fn renderAsm( |
| 1806 | const comma_or_colon = tree.lastToken(asm_input) + 1; | 1806 | const comma_or_colon = tree.lastToken(asm_input) + 1; |
| 1807 | ais.popIndent(); | 1807 | ais.popIndent(); |
| 1808 | break :colon3 switch (token_tags[comma_or_colon]) { | 1808 | break :colon3 switch (token_tags[comma_or_colon]) { |
| 1809 | .Comma => comma_or_colon + 1, | 1809 | .comma => comma_or_colon + 1, |
| 1810 | else => comma_or_colon, | 1810 | else => comma_or_colon, |
| 1811 | }; | 1811 | }; |
| 1812 | } | 1812 | } |
| ... | @@ -1819,13 +1819,13 @@ fn renderAsm( | ... | @@ -1819,13 +1819,13 @@ fn renderAsm( |
| 1819 | var tok_i = first_clobber; | 1819 | var tok_i = first_clobber; |
| 1820 | while (true) { | 1820 | while (true) { |
| 1821 | switch (token_tags[tok_i + 1]) { | 1821 | switch (token_tags[tok_i + 1]) { |
| 1822 | .RParen => { | 1822 | .r_paren => { |
| 1823 | ais.setIndentDelta(indent_delta); | 1823 | ais.setIndentDelta(indent_delta); |
| 1824 | ais.popIndent(); | 1824 | ais.popIndent(); |
| 1825 | try renderToken(ais, tree, tok_i, .Newline); | 1825 | try renderToken(ais, tree, tok_i, .Newline); |
| 1826 | return renderToken(ais, tree, tok_i + 1, space); | 1826 | return renderToken(ais, tree, tok_i + 1, space); |
| 1827 | }, | 1827 | }, |
| 1828 | .Comma => { | 1828 | .comma => { |
| 1829 | try renderToken(ais, tree, tok_i, .None); | 1829 | try renderToken(ais, tree, tok_i, .None); |
| 1830 | try renderToken(ais, tree, tok_i + 1, .Space); | 1830 | try renderToken(ais, tree, tok_i + 1, .Space); |
| 1831 | tok_i += 2; | 1831 | tok_i += 2; |
| ... | @@ -1859,7 +1859,7 @@ fn renderCall( | ... | @@ -1859,7 +1859,7 @@ fn renderCall( |
| 1859 | 1859 | ||
| 1860 | const last_param = params[params.len - 1]; | 1860 | const last_param = params[params.len - 1]; |
| 1861 | const after_last_param_tok = tree.lastToken(last_param) + 1; | 1861 | 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) { |
| 1863 | ais.pushIndent(); | 1863 | ais.pushIndent(); |
| 1864 | try renderToken(ais, tree, lparen, Space.Newline); // ( | 1864 | try renderToken(ais, tree, lparen, Space.Newline); // ( |
| 1865 | for (params) |param_node, i| { | 1865 | for (params) |param_node, i| { |
| ... | @@ -1868,7 +1868,7 @@ fn renderCall( | ... | @@ -1868,7 +1868,7 @@ fn renderCall( |
| 1868 | 1868 | ||
| 1869 | // Unindent the comma for multiline string literals | 1869 | // Unindent the comma for multiline string literals |
| 1870 | const is_multiline_string = node_tags[param_node] == .StringLiteral and | 1870 | 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; |
| 1872 | if (is_multiline_string) ais.popIndent(); | 1872 | if (is_multiline_string) ais.popIndent(); |
| 1873 | 1873 | ||
| 1874 | const comma = tree.lastToken(param_node) + 1; | 1874 | const comma = tree.lastToken(param_node) + 1; |
| ... | @@ -1900,7 +1900,7 @@ fn renderCall( | ... | @@ -1900,7 +1900,7 @@ fn renderCall( |
| 1900 | fn renderExpressionComma(ais: *Ais, tree: ast.Tree, node: ast.Node.Index, space: Space) Error!void { | 1900 | fn renderExpressionComma(ais: *Ais, tree: ast.Tree, node: ast.Node.Index, space: Space) Error!void { |
| 1901 | const token_tags = tree.tokens.items(.tag); | 1901 | const token_tags = tree.tokens.items(.tag); |
| 1902 | const maybe_comma = tree.lastToken(node) + 1; | 1902 | const maybe_comma = tree.lastToken(node) + 1; |
| 1903 | if (token_tags[maybe_comma] == .Comma) { | 1903 | if (token_tags[maybe_comma] == .comma) { |
| 1904 | try renderExpression(ais, tree, node, .None); | 1904 | try renderExpression(ais, tree, node, .None); |
| 1905 | return renderToken(ais, tree, maybe_comma, space); | 1905 | return renderToken(ais, tree, maybe_comma, space); |
| 1906 | } else { | 1906 | } else { |
| ... | @@ -1911,7 +1911,7 @@ fn renderExpressionComma(ais: *Ais, tree: ast.Tree, node: ast.Node.Index, space: | ... | @@ -1911,7 +1911,7 @@ fn renderExpressionComma(ais: *Ais, tree: ast.Tree, node: ast.Node.Index, space: |
| 1911 | fn renderTokenComma(ais: *Ais, tree: ast.Tree, token: ast.TokenIndex, space: Space) Error!void { | 1911 | fn renderTokenComma(ais: *Ais, tree: ast.Tree, token: ast.TokenIndex, space: Space) Error!void { |
| 1912 | const token_tags = tree.tokens.items(.tag); | 1912 | const token_tags = tree.tokens.items(.tag); |
| 1913 | const maybe_comma = token + 1; | 1913 | const maybe_comma = token + 1; |
| 1914 | if (token_tags[maybe_comma] == .Comma) { | 1914 | if (token_tags[maybe_comma] == .comma) { |
| 1915 | try renderToken(ais, tree, token, .None); | 1915 | try renderToken(ais, tree, token, .None); |
| 1916 | return renderToken(ais, tree, maybe_comma, space); | 1916 | return renderToken(ais, tree, maybe_comma, space); |
| 1917 | } else { | 1917 | } else { |
| ... | @@ -1962,7 +1962,7 @@ fn renderToken(ais: *Ais, tree: ast.Tree, token_index: ast.TokenIndex, space: Sp | ... | @@ -1962,7 +1962,7 @@ fn renderToken(ais: *Ais, tree: ast.Tree, token_index: ast.TokenIndex, space: Sp |
| 1962 | .None => _ = try renderCommentsAndNewlines(ais, tree, token_start + lexeme.len, token_starts[token_index + 1]), | 1962 | .None => _ = try renderCommentsAndNewlines(ais, tree, token_start + lexeme.len, token_starts[token_index + 1]), |
| 1963 | .Comma => { | 1963 | .Comma => { |
| 1964 | const comment = try renderCommentsAndNewlines(ais, tree, token_start + lexeme.len, token_starts[token_index + 1]); | 1964 | 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) { |
| 1966 | return renderToken(ais, tree, token_index + 1, .Newline); | 1966 | return renderToken(ais, tree, token_index + 1, .Newline); |
| 1967 | } else if (!comment) { | 1967 | } else if (!comment) { |
| 1968 | return ais.insertNewline(); | 1968 | return ais.insertNewline(); |
| ... | @@ -1970,7 +1970,7 @@ fn renderToken(ais: *Ais, tree: ast.Tree, token_index: ast.TokenIndex, space: Sp | ... | @@ -1970,7 +1970,7 @@ fn renderToken(ais: *Ais, tree: ast.Tree, token_index: ast.TokenIndex, space: Sp |
| 1970 | }, | 1970 | }, |
| 1971 | .CommaSpace => { | 1971 | .CommaSpace => { |
| 1972 | const comment = try renderCommentsAndNewlines(ais, tree, token_start + lexeme.len, token_starts[token_index + 1]); | 1972 | 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) { |
| 1974 | return renderToken(ais, tree, token_index + 1, .Space); | 1974 | return renderToken(ais, tree, token_index + 1, .Space); |
| 1975 | } else if (!comment) { | 1975 | } else if (!comment) { |
| 1976 | return ais.writer().writeByte(' '); | 1976 | return ais.writer().writeByte(' '); |
| ... | @@ -1978,7 +1978,7 @@ fn renderToken(ais: *Ais, tree: ast.Tree, token_index: ast.TokenIndex, space: Sp | ... | @@ -1978,7 +1978,7 @@ fn renderToken(ais: *Ais, tree: ast.Tree, token_index: ast.TokenIndex, space: Sp |
| 1978 | }, | 1978 | }, |
| 1979 | .Semicolon => { | 1979 | .Semicolon => { |
| 1980 | const comment = try renderCommentsAndNewlines(ais, tree, token_start + lexeme.len, token_starts[token_index + 1]); | 1980 | 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) { |
| 1982 | return renderToken(ais, tree, token_index + 1, .Newline); | 1982 | return renderToken(ais, tree, token_index + 1, .Newline); |
| 1983 | } else if (!comment) { | 1983 | } else if (!comment) { |
| 1984 | return ais.insertNewline(); | 1984 | return ais.insertNewline(); |
| ... | @@ -2005,7 +2005,7 @@ fn renderDocComments(ais: *Ais, tree: ast.Tree, end_token: ast.TokenIndex) Error | ... | @@ -2005,7 +2005,7 @@ fn renderDocComments(ais: *Ais, tree: ast.Tree, end_token: ast.TokenIndex) Error |
| 2005 | const token_tags = tree.tokens.items(.tag); | 2005 | const token_tags = tree.tokens.items(.tag); |
| 2006 | if (end_token == 0) return; | 2006 | if (end_token == 0) return; |
| 2007 | var tok = end_token - 1; | 2007 | var tok = end_token - 1; |
| 2008 | while (token_tags[tok] == .DocComment) { | 2008 | while (token_tags[tok] == .doc_comment) { |
| 2009 | if (tok == 0) break; | 2009 | if (tok == 0) break; |
| 2010 | tok -= 1; | 2010 | tok -= 1; |
| 2011 | } else { | 2011 | } else { |
| ... | @@ -2016,7 +2016,7 @@ fn renderDocComments(ais: *Ais, tree: ast.Tree, end_token: ast.TokenIndex) Error | ... | @@ -2016,7 +2016,7 @@ fn renderDocComments(ais: *Ais, tree: ast.Tree, end_token: ast.TokenIndex) Error |
| 2016 | 2016 | ||
| 2017 | while (true) : (tok += 1) { | 2017 | while (true) : (tok += 1) { |
| 2018 | switch (token_tags[tok]) { | 2018 | switch (token_tags[tok]) { |
| 2019 | .DocComment => { | 2019 | .doc_comment => { |
| 2020 | if (first_tok < end_token) { | 2020 | if (first_tok < end_token) { |
| 2021 | try renderToken(ais, tree, tok, .Newline); | 2021 | try renderToken(ais, tree, tok, .Newline); |
| 2022 | } else { | 2022 | } else { |
lib/std/zig/tokenizer.zig+786-786| ... | @@ -16,58 +16,58 @@ pub const Token = struct { | ... | @@ -16,58 +16,58 @@ pub const Token = struct { |
| 16 | }; | 16 | }; |
| 17 | 17 | ||
| 18 | pub const keywords = std.ComptimeStringMap(Tag, .{ | 18 | pub const keywords = std.ComptimeStringMap(Tag, .{ |
| 19 | .{ "align", .Keyword_align }, | 19 | .{ "align", .keyword_align }, |
| 20 | .{ "allowzero", .Keyword_allowzero }, | 20 | .{ "allowzero", .keyword_allowzero }, |
| 21 | .{ "and", .Keyword_and }, | 21 | .{ "and", .keyword_and }, |
| 22 | .{ "anyframe", .Keyword_anyframe }, | 22 | .{ "anyframe", .keyword_anyframe }, |
| 23 | .{ "anytype", .Keyword_anytype }, | 23 | .{ "anytype", .keyword_anytype }, |
| 24 | .{ "asm", .Keyword_asm }, | 24 | .{ "asm", .keyword_asm }, |
| 25 | .{ "async", .Keyword_async }, | 25 | .{ "async", .keyword_async }, |
| 26 | .{ "await", .Keyword_await }, | 26 | .{ "await", .keyword_await }, |
| 27 | .{ "break", .Keyword_break }, | 27 | .{ "break", .keyword_break }, |
| 28 | .{ "callconv", .Keyword_callconv }, | 28 | .{ "callconv", .keyword_callconv }, |
| 29 | .{ "catch", .Keyword_catch }, | 29 | .{ "catch", .keyword_catch }, |
| 30 | .{ "comptime", .Keyword_comptime }, | 30 | .{ "comptime", .keyword_comptime }, |
| 31 | .{ "const", .Keyword_const }, | 31 | .{ "const", .keyword_const }, |
| 32 | .{ "continue", .Keyword_continue }, | 32 | .{ "continue", .keyword_continue }, |
| 33 | .{ "defer", .Keyword_defer }, | 33 | .{ "defer", .keyword_defer }, |
| 34 | .{ "else", .Keyword_else }, | 34 | .{ "else", .keyword_else }, |
| 35 | .{ "enum", .Keyword_enum }, | 35 | .{ "enum", .keyword_enum }, |
| 36 | .{ "errdefer", .Keyword_errdefer }, | 36 | .{ "errdefer", .keyword_errdefer }, |
| 37 | .{ "error", .Keyword_error }, | 37 | .{ "error", .keyword_error }, |
| 38 | .{ "export", .Keyword_export }, | 38 | .{ "export", .keyword_export }, |
| 39 | .{ "extern", .Keyword_extern }, | 39 | .{ "extern", .keyword_extern }, |
| 40 | .{ "false", .Keyword_false }, | 40 | .{ "false", .keyword_false }, |
| 41 | .{ "fn", .Keyword_fn }, | 41 | .{ "fn", .keyword_fn }, |
| 42 | .{ "for", .Keyword_for }, | 42 | .{ "for", .keyword_for }, |
| 43 | .{ "if", .Keyword_if }, | 43 | .{ "if", .keyword_if }, |
| 44 | .{ "inline", .Keyword_inline }, | 44 | .{ "inline", .keyword_inline }, |
| 45 | .{ "noalias", .Keyword_noalias }, | 45 | .{ "noalias", .keyword_noalias }, |
| 46 | .{ "noinline", .Keyword_noinline }, | 46 | .{ "noinline", .keyword_noinline }, |
| 47 | .{ "nosuspend", .Keyword_nosuspend }, | 47 | .{ "nosuspend", .keyword_nosuspend }, |
| 48 | .{ "null", .Keyword_null }, | 48 | .{ "null", .keyword_null }, |
| 49 | .{ "opaque", .Keyword_opaque }, | 49 | .{ "opaque", .keyword_opaque }, |
| 50 | .{ "or", .Keyword_or }, | 50 | .{ "or", .keyword_or }, |
| 51 | .{ "orelse", .Keyword_orelse }, | 51 | .{ "orelse", .keyword_orelse }, |
| 52 | .{ "packed", .Keyword_packed }, | 52 | .{ "packed", .keyword_packed }, |
| 53 | .{ "pub", .Keyword_pub }, | 53 | .{ "pub", .keyword_pub }, |
| 54 | .{ "resume", .Keyword_resume }, | 54 | .{ "resume", .keyword_resume }, |
| 55 | .{ "return", .Keyword_return }, | 55 | .{ "return", .keyword_return }, |
| 56 | .{ "linksection", .Keyword_linksection }, | 56 | .{ "linksection", .keyword_linksection }, |
| 57 | .{ "struct", .Keyword_struct }, | 57 | .{ "struct", .keyword_struct }, |
| 58 | .{ "suspend", .Keyword_suspend }, | 58 | .{ "suspend", .keyword_suspend }, |
| 59 | .{ "switch", .Keyword_switch }, | 59 | .{ "switch", .keyword_switch }, |
| 60 | .{ "test", .Keyword_test }, | 60 | .{ "test", .keyword_test }, |
| 61 | .{ "threadlocal", .Keyword_threadlocal }, | 61 | .{ "threadlocal", .keyword_threadlocal }, |
| 62 | .{ "true", .Keyword_true }, | 62 | .{ "true", .keyword_true }, |
| 63 | .{ "try", .Keyword_try }, | 63 | .{ "try", .keyword_try }, |
| 64 | .{ "undefined", .Keyword_undefined }, | 64 | .{ "undefined", .keyword_undefined }, |
| 65 | .{ "union", .Keyword_union }, | 65 | .{ "union", .keyword_union }, |
| 66 | .{ "unreachable", .Keyword_unreachable }, | 66 | .{ "unreachable", .keyword_unreachable }, |
| 67 | .{ "usingnamespace", .Keyword_usingnamespace }, | 67 | .{ "usingnamespace", .keyword_usingnamespace }, |
| 68 | .{ "var", .Keyword_var }, | 68 | .{ "var", .keyword_var }, |
| 69 | .{ "volatile", .Keyword_volatile }, | 69 | .{ "volatile", .keyword_volatile }, |
| 70 | .{ "while", .Keyword_while }, | 70 | .{ "while", .keyword_while }, |
| 71 | }); | 71 | }); |
| 72 | 72 | ||
| 73 | pub fn getKeyword(bytes: []const u8) ?Tag { | 73 | pub fn getKeyword(bytes: []const u8) ?Tag { |
| ... | @@ -75,249 +75,249 @@ pub const Token = struct { | ... | @@ -75,249 +75,249 @@ pub const Token = struct { |
| 75 | } | 75 | } |
| 76 | 76 | ||
| 77 | pub const Tag = enum { | 77 | pub const Tag = enum { |
| 78 | Invalid, | 78 | invalid, |
| 79 | Invalid_ampersands, | 79 | invalid_ampersands, |
| 80 | Invalid_periodasterisks, | 80 | invalid_periodasterisks, |
| 81 | Identifier, | 81 | identifier, |
| 82 | StringLiteral, | 82 | string_literal, |
| 83 | MultilineStringLiteralLine, | 83 | multiline_string_literal_line, |
| 84 | CharLiteral, | 84 | char_literal, |
| 85 | Eof, | 85 | eof, |
| 86 | Builtin, | 86 | builtin, |
| 87 | Bang, | 87 | bang, |
| 88 | Pipe, | 88 | pipe, |
| 89 | PipePipe, | 89 | pipe_pipe, |
| 90 | PipeEqual, | 90 | pipe_equal, |
| 91 | Equal, | 91 | equal, |
| 92 | EqualEqual, | 92 | equal_equal, |
| 93 | EqualAngleBracketRight, | 93 | equal_angle_bracket_right, |
| 94 | BangEqual, | 94 | bang_equal, |
| 95 | LParen, | 95 | l_paren, |
| 96 | RParen, | 96 | r_paren, |
| 97 | Semicolon, | 97 | semicolon, |
| 98 | Percent, | 98 | percent, |
| 99 | PercentEqual, | 99 | percent_equal, |
| 100 | LBrace, | 100 | l_brace, |
| 101 | RBrace, | 101 | r_brace, |
| 102 | LBracket, | 102 | l_bracket, |
| 103 | RBracket, | 103 | r_bracket, |
| 104 | Period, | 104 | period, |
| 105 | PeriodAsterisk, | 105 | period_asterisk, |
| 106 | Ellipsis2, | 106 | ellipsis2, |
| 107 | Ellipsis3, | 107 | ellipsis3, |
| 108 | Caret, | 108 | caret, |
| 109 | CaretEqual, | 109 | caret_equal, |
| 110 | Plus, | 110 | plus, |
| 111 | PlusPlus, | 111 | plus_plus, |
| 112 | PlusEqual, | 112 | plus_equal, |
| 113 | PlusPercent, | 113 | plus_percent, |
| 114 | PlusPercentEqual, | 114 | plus_percent_equal, |
| 115 | Minus, | 115 | minus, |
| 116 | MinusEqual, | 116 | minus_equal, |
| 117 | MinusPercent, | 117 | minus_percent, |
| 118 | MinusPercentEqual, | 118 | minus_percent_equal, |
| 119 | Asterisk, | 119 | asterisk, |
| 120 | AsteriskEqual, | 120 | asterisk_equal, |
| 121 | AsteriskAsterisk, | 121 | asterisk_asterisk, |
| 122 | AsteriskPercent, | 122 | asterisk_percent, |
| 123 | AsteriskPercentEqual, | 123 | asterisk_percent_equal, |
| 124 | Arrow, | 124 | arrow, |
| 125 | Colon, | 125 | colon, |
| 126 | Slash, | 126 | slash, |
| 127 | SlashEqual, | 127 | slash_equal, |
| 128 | Comma, | 128 | comma, |
| 129 | Ampersand, | 129 | ampersand, |
| 130 | AmpersandEqual, | 130 | ampersand_equal, |
| 131 | QuestionMark, | 131 | question_mark, |
| 132 | AngleBracketLeft, | 132 | angle_bracket_left, |
| 133 | AngleBracketLeftEqual, | 133 | angle_bracket_left_equal, |
| 134 | AngleBracketAngleBracketLeft, | 134 | angle_bracket_angle_bracket_left, |
| 135 | AngleBracketAngleBracketLeftEqual, | 135 | angle_bracket_angle_bracket_left_equal, |
| 136 | AngleBracketRight, | 136 | angle_bracket_right, |
| 137 | AngleBracketRightEqual, | 137 | angle_bracket_right_equal, |
| 138 | AngleBracketAngleBracketRight, | 138 | angle_bracket_angle_bracket_right, |
| 139 | AngleBracketAngleBracketRightEqual, | 139 | angle_bracket_angle_bracket_right_equal, |
| 140 | Tilde, | 140 | tilde, |
| 141 | IntegerLiteral, | 141 | integer_literal, |
| 142 | FloatLiteral, | 142 | float_literal, |
| 143 | DocComment, | 143 | doc_comment, |
| 144 | ContainerDocComment, | 144 | container_doc_comment, |
| 145 | Keyword_align, | 145 | keyword_align, |
| 146 | Keyword_allowzero, | 146 | keyword_allowzero, |
| 147 | Keyword_and, | 147 | keyword_and, |
| 148 | Keyword_anyframe, | 148 | keyword_anyframe, |
| 149 | Keyword_anytype, | 149 | keyword_anytype, |
| 150 | Keyword_asm, | 150 | keyword_asm, |
| 151 | Keyword_async, | 151 | keyword_async, |
| 152 | Keyword_await, | 152 | keyword_await, |
| 153 | Keyword_break, | 153 | keyword_break, |
| 154 | Keyword_callconv, | 154 | keyword_callconv, |
| 155 | Keyword_catch, | 155 | keyword_catch, |
| 156 | Keyword_comptime, | 156 | keyword_comptime, |
| 157 | Keyword_const, | 157 | keyword_const, |
| 158 | Keyword_continue, | 158 | keyword_continue, |
| 159 | Keyword_defer, | 159 | keyword_defer, |
| 160 | Keyword_else, | 160 | keyword_else, |
| 161 | Keyword_enum, | 161 | keyword_enum, |
| 162 | Keyword_errdefer, | 162 | keyword_errdefer, |
| 163 | Keyword_error, | 163 | keyword_error, |
| 164 | Keyword_export, | 164 | keyword_export, |
| 165 | Keyword_extern, | 165 | keyword_extern, |
| 166 | Keyword_false, | 166 | keyword_false, |
| 167 | Keyword_fn, | 167 | keyword_fn, |
| 168 | Keyword_for, | 168 | keyword_for, |
| 169 | Keyword_if, | 169 | keyword_if, |
| 170 | Keyword_inline, | 170 | keyword_inline, |
| 171 | Keyword_noalias, | 171 | keyword_noalias, |
| 172 | Keyword_noinline, | 172 | keyword_noinline, |
| 173 | Keyword_nosuspend, | 173 | keyword_nosuspend, |
| 174 | Keyword_null, | 174 | keyword_null, |
| 175 | Keyword_opaque, | 175 | keyword_opaque, |
| 176 | Keyword_or, | 176 | keyword_or, |
| 177 | Keyword_orelse, | 177 | keyword_orelse, |
| 178 | Keyword_packed, | 178 | keyword_packed, |
| 179 | Keyword_pub, | 179 | keyword_pub, |
| 180 | Keyword_resume, | 180 | keyword_resume, |
| 181 | Keyword_return, | 181 | keyword_return, |
| 182 | Keyword_linksection, | 182 | keyword_linksection, |
| 183 | Keyword_struct, | 183 | keyword_struct, |
| 184 | Keyword_suspend, | 184 | keyword_suspend, |
| 185 | Keyword_switch, | 185 | keyword_switch, |
| 186 | Keyword_test, | 186 | keyword_test, |
| 187 | Keyword_threadlocal, | 187 | keyword_threadlocal, |
| 188 | Keyword_true, | 188 | keyword_true, |
| 189 | Keyword_try, | 189 | keyword_try, |
| 190 | Keyword_undefined, | 190 | keyword_undefined, |
| 191 | Keyword_union, | 191 | keyword_union, |
| 192 | Keyword_unreachable, | 192 | keyword_unreachable, |
| 193 | Keyword_usingnamespace, | 193 | keyword_usingnamespace, |
| 194 | Keyword_var, | 194 | keyword_var, |
| 195 | Keyword_volatile, | 195 | keyword_volatile, |
| 196 | Keyword_while, | 196 | keyword_while, |
| 197 | 197 | ||
| 198 | pub fn lexeme(tag: Tag) ?[]const u8 { | 198 | pub fn lexeme(tag: Tag) ?[]const u8 { |
| 199 | return switch (tag) { | 199 | return switch (tag) { |
| 200 | .Invalid, | 200 | .invalid, |
| 201 | .Identifier, | 201 | .identifier, |
| 202 | .StringLiteral, | 202 | .string_literal, |
| 203 | .MultilineStringLiteralLine, | 203 | .multiline_string_literal_line, |
| 204 | .CharLiteral, | 204 | .char_literal, |
| 205 | .Eof, | 205 | .eof, |
| 206 | .Builtin, | 206 | .builtin, |
| 207 | .IntegerLiteral, | 207 | .integer_literal, |
| 208 | .FloatLiteral, | 208 | .float_literal, |
| 209 | .DocComment, | 209 | .doc_comment, |
| 210 | .ContainerDocComment, | 210 | .container_doc_comment, |
| 211 | => null, | 211 | => null, |
| 212 | 212 | ||
| 213 | .Invalid_ampersands => "&&", | 213 | .invalid_ampersands => "&&", |
| 214 | .Invalid_periodasterisks => ".**", | 214 | .invalid_periodasterisks => ".**", |
| 215 | .Bang => "!", | 215 | .bang => "!", |
| 216 | .Pipe => "|", | 216 | .pipe => "|", |
| 217 | .PipePipe => "||", | 217 | .pipe_pipe => "||", |
| 218 | .PipeEqual => "|=", | 218 | .pipe_equal => "|=", |
| 219 | .Equal => "=", | 219 | .equal => "=", |
| 220 | .EqualEqual => "==", | 220 | .equal_equal => "==", |
| 221 | .EqualAngleBracketRight => "=>", | 221 | .equal_angle_bracket_right => "=>", |
| 222 | .BangEqual => "!=", | 222 | .bang_equal => "!=", |
| 223 | .LParen => "(", | 223 | .l_paren => "(", |
| 224 | .RParen => ")", | 224 | .r_paren => ")", |
| 225 | .Semicolon => ";", | 225 | .semicolon => ";", |
| 226 | .Percent => "%", | 226 | .percent => "%", |
| 227 | .PercentEqual => "%=", | 227 | .percent_equal => "%=", |
| 228 | .LBrace => "{", | 228 | .l_brace => "{", |
| 229 | .RBrace => "}", | 229 | .r_brace => "}", |
| 230 | .LBracket => "[", | 230 | .l_bracket => "[", |
| 231 | .RBracket => "]", | 231 | .r_bracket => "]", |
| 232 | .Period => ".", | 232 | .period => ".", |
| 233 | .PeriodAsterisk => ".*", | 233 | .period_asterisk => ".*", |
| 234 | .Ellipsis2 => "..", | 234 | .ellipsis2 => "..", |
| 235 | .Ellipsis3 => "...", | 235 | .ellipsis3 => "...", |
| 236 | .Caret => "^", | 236 | .caret => "^", |
| 237 | .CaretEqual => "^=", | 237 | .caret_equal => "^=", |
| 238 | .Plus => "+", | 238 | .plus => "+", |
| 239 | .PlusPlus => "++", | 239 | .plus_plus => "++", |
| 240 | .PlusEqual => "+=", | 240 | .plus_equal => "+=", |
| 241 | .PlusPercent => "+%", | 241 | .plus_percent => "+%", |
| 242 | .PlusPercentEqual => "+%=", | 242 | .plus_percent_equal => "+%=", |
| 243 | .Minus => "-", | 243 | .minus => "-", |
| 244 | .MinusEqual => "-=", | 244 | .minus_equal => "-=", |
| 245 | .MinusPercent => "-%", | 245 | .minus_percent => "-%", |
| 246 | .MinusPercentEqual => "-%=", | 246 | .minus_percent_equal => "-%=", |
| 247 | .Asterisk => "*", | 247 | .asterisk => "*", |
| 248 | .AsteriskEqual => "*=", | 248 | .asterisk_equal => "*=", |
| 249 | .AsteriskAsterisk => "**", | 249 | .asterisk_asterisk => "**", |
| 250 | .AsteriskPercent => "*%", | 250 | .asterisk_percent => "*%", |
| 251 | .AsteriskPercentEqual => "*%=", | 251 | .asterisk_percent_equal => "*%=", |
| 252 | .Arrow => "->", | 252 | .arrow => "->", |
| 253 | .Colon => ":", | 253 | .colon => ":", |
| 254 | .Slash => "/", | 254 | .slash => "/", |
| 255 | .SlashEqual => "/=", | 255 | .slash_equal => "/=", |
| 256 | .Comma => ",", | 256 | .comma => ",", |
| 257 | .Ampersand => "&", | 257 | .ampersand => "&", |
| 258 | .AmpersandEqual => "&=", | 258 | .ampersand_equal => "&=", |
| 259 | .QuestionMark => "?", | 259 | .question_mark => "?", |
| 260 | .AngleBracketLeft => "<", | 260 | .angle_bracket_left => "<", |
| 261 | .AngleBracketLeftEqual => "<=", | 261 | .angle_bracket_left_equal => "<=", |
| 262 | .AngleBracketAngleBracketLeft => "<<", | 262 | .angle_bracket_angle_bracket_left => "<<", |
| 263 | .AngleBracketAngleBracketLeftEqual => "<<=", | 263 | .angle_bracket_angle_bracket_left_equal => "<<=", |
| 264 | .AngleBracketRight => ">", | 264 | .angle_bracket_right => ">", |
| 265 | .AngleBracketRightEqual => ">=", | 265 | .angle_bracket_right_equal => ">=", |
| 266 | .AngleBracketAngleBracketRight => ">>", | 266 | .angle_bracket_angle_bracket_right => ">>", |
| 267 | .AngleBracketAngleBracketRightEqual => ">>=", | 267 | .angle_bracket_angle_bracket_right_equal => ">>=", |
| 268 | .Tilde => "~", | 268 | .tilde => "~", |
| 269 | .Keyword_align => "align", | 269 | .keyword_align => "align", |
| 270 | .Keyword_allowzero => "allowzero", | 270 | .keyword_allowzero => "allowzero", |
| 271 | .Keyword_and => "and", | 271 | .keyword_and => "and", |
| 272 | .Keyword_anyframe => "anyframe", | 272 | .keyword_anyframe => "anyframe", |
| 273 | .Keyword_anytype => "anytype", | 273 | .keyword_anytype => "anytype", |
| 274 | .Keyword_asm => "asm", | 274 | .keyword_asm => "asm", |
| 275 | .Keyword_async => "async", | 275 | .keyword_async => "async", |
| 276 | .Keyword_await => "await", | 276 | .keyword_await => "await", |
| 277 | .Keyword_break => "break", | 277 | .keyword_break => "break", |
| 278 | .Keyword_callconv => "callconv", | 278 | .keyword_callconv => "callconv", |
| 279 | .Keyword_catch => "catch", | 279 | .keyword_catch => "catch", |
| 280 | .Keyword_comptime => "comptime", | 280 | .keyword_comptime => "comptime", |
| 281 | .Keyword_const => "const", | 281 | .keyword_const => "const", |
| 282 | .Keyword_continue => "continue", | 282 | .keyword_continue => "continue", |
| 283 | .Keyword_defer => "defer", | 283 | .keyword_defer => "defer", |
| 284 | .Keyword_else => "else", | 284 | .keyword_else => "else", |
| 285 | .Keyword_enum => "enum", | 285 | .keyword_enum => "enum", |
| 286 | .Keyword_errdefer => "errdefer", | 286 | .keyword_errdefer => "errdefer", |
| 287 | .Keyword_error => "error", | 287 | .keyword_error => "error", |
| 288 | .Keyword_export => "export", | 288 | .keyword_export => "export", |
| 289 | .Keyword_extern => "extern", | 289 | .keyword_extern => "extern", |
| 290 | .Keyword_false => "false", | 290 | .keyword_false => "false", |
| 291 | .Keyword_fn => "fn", | 291 | .keyword_fn => "fn", |
| 292 | .Keyword_for => "for", | 292 | .keyword_for => "for", |
| 293 | .Keyword_if => "if", | 293 | .keyword_if => "if", |
| 294 | .Keyword_inline => "inline", | 294 | .keyword_inline => "inline", |
| 295 | .Keyword_noalias => "noalias", | 295 | .keyword_noalias => "noalias", |
| 296 | .Keyword_noinline => "noinline", | 296 | .keyword_noinline => "noinline", |
| 297 | .Keyword_nosuspend => "nosuspend", | 297 | .keyword_nosuspend => "nosuspend", |
| 298 | .Keyword_null => "null", | 298 | .keyword_null => "null", |
| 299 | .Keyword_opaque => "opaque", | 299 | .keyword_opaque => "opaque", |
| 300 | .Keyword_or => "or", | 300 | .keyword_or => "or", |
| 301 | .Keyword_orelse => "orelse", | 301 | .keyword_orelse => "orelse", |
| 302 | .Keyword_packed => "packed", | 302 | .keyword_packed => "packed", |
| 303 | .Keyword_pub => "pub", | 303 | .keyword_pub => "pub", |
| 304 | .Keyword_resume => "resume", | 304 | .keyword_resume => "resume", |
| 305 | .Keyword_return => "return", | 305 | .keyword_return => "return", |
| 306 | .Keyword_linksection => "linksection", | 306 | .keyword_linksection => "linksection", |
| 307 | .Keyword_struct => "struct", | 307 | .keyword_struct => "struct", |
| 308 | .Keyword_suspend => "suspend", | 308 | .keyword_suspend => "suspend", |
| 309 | .Keyword_switch => "switch", | 309 | .keyword_switch => "switch", |
| 310 | .Keyword_test => "test", | 310 | .keyword_test => "test", |
| 311 | .Keyword_threadlocal => "threadlocal", | 311 | .keyword_threadlocal => "threadlocal", |
| 312 | .Keyword_true => "true", | 312 | .keyword_true => "true", |
| 313 | .Keyword_try => "try", | 313 | .keyword_try => "try", |
| 314 | .Keyword_undefined => "undefined", | 314 | .keyword_undefined => "undefined", |
| 315 | .Keyword_union => "union", | 315 | .keyword_union => "union", |
| 316 | .Keyword_unreachable => "unreachable", | 316 | .keyword_unreachable => "unreachable", |
| 317 | .Keyword_usingnamespace => "usingnamespace", | 317 | .keyword_usingnamespace => "usingnamespace", |
| 318 | .Keyword_var => "var", | 318 | .keyword_var => "var", |
| 319 | .Keyword_volatile => "volatile", | 319 | .keyword_volatile => "volatile", |
| 320 | .Keyword_while => "while", | 320 | .keyword_while => "while", |
| 321 | }; | 321 | }; |
| 322 | } | 322 | } |
| 323 | 323 | ||
| ... | @@ -421,7 +421,7 @@ pub const Tokenizer = struct { | ... | @@ -421,7 +421,7 @@ pub const Tokenizer = struct { |
| 421 | const start_index = self.index; | 421 | const start_index = self.index; |
| 422 | var state: State = .start; | 422 | var state: State = .start; |
| 423 | var result = Token{ | 423 | var result = Token{ |
| 424 | .tag = .Eof, | 424 | .tag = .eof, |
| 425 | .loc = .{ | 425 | .loc = .{ |
| 426 | .start = self.index, | 426 | .start = self.index, |
| 427 | .end = undefined, | 427 | .end = undefined, |
| ... | @@ -438,14 +438,14 @@ pub const Tokenizer = struct { | ... | @@ -438,14 +438,14 @@ pub const Tokenizer = struct { |
| 438 | }, | 438 | }, |
| 439 | '"' => { | 439 | '"' => { |
| 440 | state = .string_literal; | 440 | state = .string_literal; |
| 441 | result.tag = .StringLiteral; | 441 | result.tag = .string_literal; |
| 442 | }, | 442 | }, |
| 443 | '\'' => { | 443 | '\'' => { |
| 444 | state = .char_literal; | 444 | state = .char_literal; |
| 445 | }, | 445 | }, |
| 446 | 'a'...'z', 'A'...'Z', '_' => { | 446 | 'a'...'z', 'A'...'Z', '_' => { |
| 447 | state = .identifier; | 447 | state = .identifier; |
| 448 | result.tag = .Identifier; | 448 | result.tag = .identifier; |
| 449 | }, | 449 | }, |
| 450 | '@' => { | 450 | '@' => { |
| 451 | state = .saw_at_sign; | 451 | state = .saw_at_sign; |
| ... | @@ -460,42 +460,42 @@ pub const Tokenizer = struct { | ... | @@ -460,42 +460,42 @@ pub const Tokenizer = struct { |
| 460 | state = .pipe; | 460 | state = .pipe; |
| 461 | }, | 461 | }, |
| 462 | '(' => { | 462 | '(' => { |
| 463 | result.tag = .LParen; | 463 | result.tag = .l_paren; |
| 464 | self.index += 1; | 464 | self.index += 1; |
| 465 | break; | 465 | break; |
| 466 | }, | 466 | }, |
| 467 | ')' => { | 467 | ')' => { |
| 468 | result.tag = .RParen; | 468 | result.tag = .r_paren; |
| 469 | self.index += 1; | 469 | self.index += 1; |
| 470 | break; | 470 | break; |
| 471 | }, | 471 | }, |
| 472 | '[' => { | 472 | '[' => { |
| 473 | result.tag = .LBracket; | 473 | result.tag = .l_bracket; |
| 474 | self.index += 1; | 474 | self.index += 1; |
| 475 | break; | 475 | break; |
| 476 | }, | 476 | }, |
| 477 | ']' => { | 477 | ']' => { |
| 478 | result.tag = .RBracket; | 478 | result.tag = .r_bracket; |
| 479 | self.index += 1; | 479 | self.index += 1; |
| 480 | break; | 480 | break; |
| 481 | }, | 481 | }, |
| 482 | ';' => { | 482 | ';' => { |
| 483 | result.tag = .Semicolon; | 483 | result.tag = .semicolon; |
| 484 | self.index += 1; | 484 | self.index += 1; |
| 485 | break; | 485 | break; |
| 486 | }, | 486 | }, |
| 487 | ',' => { | 487 | ',' => { |
| 488 | result.tag = .Comma; | 488 | result.tag = .comma; |
| 489 | self.index += 1; | 489 | self.index += 1; |
| 490 | break; | 490 | break; |
| 491 | }, | 491 | }, |
| 492 | '?' => { | 492 | '?' => { |
| 493 | result.tag = .QuestionMark; | 493 | result.tag = .question_mark; |
| 494 | self.index += 1; | 494 | self.index += 1; |
| 495 | break; | 495 | break; |
| 496 | }, | 496 | }, |
| 497 | ':' => { | 497 | ':' => { |
| 498 | result.tag = .Colon; | 498 | result.tag = .colon; |
| 499 | self.index += 1; | 499 | self.index += 1; |
| 500 | break; | 500 | break; |
| 501 | }, | 501 | }, |
| ... | @@ -519,20 +519,20 @@ pub const Tokenizer = struct { | ... | @@ -519,20 +519,20 @@ pub const Tokenizer = struct { |
| 519 | }, | 519 | }, |
| 520 | '\\' => { | 520 | '\\' => { |
| 521 | state = .backslash; | 521 | state = .backslash; |
| 522 | result.tag = .MultilineStringLiteralLine; | 522 | result.tag = .multiline_string_literal_line; |
| 523 | }, | 523 | }, |
| 524 | '{' => { | 524 | '{' => { |
| 525 | result.tag = .LBrace; | 525 | result.tag = .l_brace; |
| 526 | self.index += 1; | 526 | self.index += 1; |
| 527 | break; | 527 | break; |
| 528 | }, | 528 | }, |
| 529 | '}' => { | 529 | '}' => { |
| 530 | result.tag = .RBrace; | 530 | result.tag = .r_brace; |
| 531 | self.index += 1; | 531 | self.index += 1; |
| 532 | break; | 532 | break; |
| 533 | }, | 533 | }, |
| 534 | '~' => { | 534 | '~' => { |
| 535 | result.tag = .Tilde; | 535 | result.tag = .tilde; |
| 536 | self.index += 1; | 536 | self.index += 1; |
| 537 | break; | 537 | break; |
| 538 | }, | 538 | }, |
| ... | @@ -550,14 +550,14 @@ pub const Tokenizer = struct { | ... | @@ -550,14 +550,14 @@ pub const Tokenizer = struct { |
| 550 | }, | 550 | }, |
| 551 | '0' => { | 551 | '0' => { |
| 552 | state = .zero; | 552 | state = .zero; |
| 553 | result.tag = .IntegerLiteral; | 553 | result.tag = .integer_literal; |
| 554 | }, | 554 | }, |
| 555 | '1'...'9' => { | 555 | '1'...'9' => { |
| 556 | state = .int_literal_dec; | 556 | state = .int_literal_dec; |
| 557 | result.tag = .IntegerLiteral; | 557 | result.tag = .integer_literal; |
| 558 | }, | 558 | }, |
| 559 | else => { | 559 | else => { |
| 560 | result.tag = .Invalid; | 560 | result.tag = .invalid; |
| 561 | self.index += 1; | 561 | self.index += 1; |
| 562 | break; | 562 | break; |
| 563 | }, | 563 | }, |
| ... | @@ -565,42 +565,42 @@ pub const Tokenizer = struct { | ... | @@ -565,42 +565,42 @@ pub const Tokenizer = struct { |
| 565 | 565 | ||
| 566 | .saw_at_sign => switch (c) { | 566 | .saw_at_sign => switch (c) { |
| 567 | '"' => { | 567 | '"' => { |
| 568 | result.tag = .Identifier; | 568 | result.tag = .identifier; |
| 569 | state = .string_literal; | 569 | state = .string_literal; |
| 570 | }, | 570 | }, |
| 571 | else => { | 571 | else => { |
| 572 | // reinterpret as a builtin | 572 | // reinterpret as a builtin |
| 573 | self.index -= 1; | 573 | self.index -= 1; |
| 574 | state = .builtin; | 574 | state = .builtin; |
| 575 | result.tag = .Builtin; | 575 | result.tag = .builtin; |
| 576 | }, | 576 | }, |
| 577 | }, | 577 | }, |
| 578 | 578 | ||
| 579 | .ampersand => switch (c) { | 579 | .ampersand => switch (c) { |
| 580 | '&' => { | 580 | '&' => { |
| 581 | result.tag = .Invalid_ampersands; | 581 | result.tag = .invalid_ampersands; |
| 582 | self.index += 1; | 582 | self.index += 1; |
| 583 | break; | 583 | break; |
| 584 | }, | 584 | }, |
| 585 | '=' => { | 585 | '=' => { |
| 586 | result.tag = .AmpersandEqual; | 586 | result.tag = .ampersand_equal; |
| 587 | self.index += 1; | 587 | self.index += 1; |
| 588 | break; | 588 | break; |
| 589 | }, | 589 | }, |
| 590 | else => { | 590 | else => { |
| 591 | result.tag = .Ampersand; | 591 | result.tag = .ampersand; |
| 592 | break; | 592 | break; |
| 593 | }, | 593 | }, |
| 594 | }, | 594 | }, |
| 595 | 595 | ||
| 596 | .asterisk => switch (c) { | 596 | .asterisk => switch (c) { |
| 597 | '=' => { | 597 | '=' => { |
| 598 | result.tag = .AsteriskEqual; | 598 | result.tag = .asterisk_equal; |
| 599 | self.index += 1; | 599 | self.index += 1; |
| 600 | break; | 600 | break; |
| 601 | }, | 601 | }, |
| 602 | '*' => { | 602 | '*' => { |
| 603 | result.tag = .AsteriskAsterisk; | 603 | result.tag = .asterisk_asterisk; |
| 604 | self.index += 1; | 604 | self.index += 1; |
| 605 | break; | 605 | break; |
| 606 | }, | 606 | }, |
| ... | @@ -608,43 +608,43 @@ pub const Tokenizer = struct { | ... | @@ -608,43 +608,43 @@ pub const Tokenizer = struct { |
| 608 | state = .asterisk_percent; | 608 | state = .asterisk_percent; |
| 609 | }, | 609 | }, |
| 610 | else => { | 610 | else => { |
| 611 | result.tag = .Asterisk; | 611 | result.tag = .asterisk; |
| 612 | break; | 612 | break; |
| 613 | }, | 613 | }, |
| 614 | }, | 614 | }, |
| 615 | 615 | ||
| 616 | .asterisk_percent => switch (c) { | 616 | .asterisk_percent => switch (c) { |
| 617 | '=' => { | 617 | '=' => { |
| 618 | result.tag = .AsteriskPercentEqual; | 618 | result.tag = .asterisk_percent_equal; |
| 619 | self.index += 1; | 619 | self.index += 1; |
| 620 | break; | 620 | break; |
| 621 | }, | 621 | }, |
| 622 | else => { | 622 | else => { |
| 623 | result.tag = .AsteriskPercent; | 623 | result.tag = .asterisk_percent; |
| 624 | break; | 624 | break; |
| 625 | }, | 625 | }, |
| 626 | }, | 626 | }, |
| 627 | 627 | ||
| 628 | .percent => switch (c) { | 628 | .percent => switch (c) { |
| 629 | '=' => { | 629 | '=' => { |
| 630 | result.tag = .PercentEqual; | 630 | result.tag = .percent_equal; |
| 631 | self.index += 1; | 631 | self.index += 1; |
| 632 | break; | 632 | break; |
| 633 | }, | 633 | }, |
| 634 | else => { | 634 | else => { |
| 635 | result.tag = .Percent; | 635 | result.tag = .percent; |
| 636 | break; | 636 | break; |
| 637 | }, | 637 | }, |
| 638 | }, | 638 | }, |
| 639 | 639 | ||
| 640 | .plus => switch (c) { | 640 | .plus => switch (c) { |
| 641 | '=' => { | 641 | '=' => { |
| 642 | result.tag = .PlusEqual; | 642 | result.tag = .plus_equal; |
| 643 | self.index += 1; | 643 | self.index += 1; |
| 644 | break; | 644 | break; |
| 645 | }, | 645 | }, |
| 646 | '+' => { | 646 | '+' => { |
| 647 | result.tag = .PlusPlus; | 647 | result.tag = .plus_plus; |
| 648 | self.index += 1; | 648 | self.index += 1; |
| 649 | break; | 649 | break; |
| 650 | }, | 650 | }, |
| ... | @@ -652,31 +652,31 @@ pub const Tokenizer = struct { | ... | @@ -652,31 +652,31 @@ pub const Tokenizer = struct { |
| 652 | state = .plus_percent; | 652 | state = .plus_percent; |
| 653 | }, | 653 | }, |
| 654 | else => { | 654 | else => { |
| 655 | result.tag = .Plus; | 655 | result.tag = .plus; |
| 656 | break; | 656 | break; |
| 657 | }, | 657 | }, |
| 658 | }, | 658 | }, |
| 659 | 659 | ||
| 660 | .plus_percent => switch (c) { | 660 | .plus_percent => switch (c) { |
| 661 | '=' => { | 661 | '=' => { |
| 662 | result.tag = .PlusPercentEqual; | 662 | result.tag = .plus_percent_equal; |
| 663 | self.index += 1; | 663 | self.index += 1; |
| 664 | break; | 664 | break; |
| 665 | }, | 665 | }, |
| 666 | else => { | 666 | else => { |
| 667 | result.tag = .PlusPercent; | 667 | result.tag = .plus_percent; |
| 668 | break; | 668 | break; |
| 669 | }, | 669 | }, |
| 670 | }, | 670 | }, |
| 671 | 671 | ||
| 672 | .caret => switch (c) { | 672 | .caret => switch (c) { |
| 673 | '=' => { | 673 | '=' => { |
| 674 | result.tag = .CaretEqual; | 674 | result.tag = .caret_equal; |
| 675 | self.index += 1; | 675 | self.index += 1; |
| 676 | break; | 676 | break; |
| 677 | }, | 677 | }, |
| 678 | else => { | 678 | else => { |
| 679 | result.tag = .Caret; | 679 | result.tag = .caret; |
| 680 | break; | 680 | break; |
| 681 | }, | 681 | }, |
| 682 | }, | 682 | }, |
| ... | @@ -724,7 +724,7 @@ pub const Tokenizer = struct { | ... | @@ -724,7 +724,7 @@ pub const Tokenizer = struct { |
| 724 | state = .char_literal_backslash; | 724 | state = .char_literal_backslash; |
| 725 | }, | 725 | }, |
| 726 | '\'', 0x80...0xbf, 0xf8...0xff => { | 726 | '\'', 0x80...0xbf, 0xf8...0xff => { |
| 727 | result.tag = .Invalid; | 727 | result.tag = .invalid; |
| 728 | break; | 728 | break; |
| 729 | }, | 729 | }, |
| 730 | 0xc0...0xdf => { // 110xxxxx | 730 | 0xc0...0xdf => { // 110xxxxx |
| ... | @@ -746,7 +746,7 @@ pub const Tokenizer = struct { | ... | @@ -746,7 +746,7 @@ pub const Tokenizer = struct { |
| 746 | 746 | ||
| 747 | .char_literal_backslash => switch (c) { | 747 | .char_literal_backslash => switch (c) { |
| 748 | '\n' => { | 748 | '\n' => { |
| 749 | result.tag = .Invalid; | 749 | result.tag = .invalid; |
| 750 | break; | 750 | break; |
| 751 | }, | 751 | }, |
| 752 | 'x' => { | 752 | 'x' => { |
| ... | @@ -769,7 +769,7 @@ pub const Tokenizer = struct { | ... | @@ -769,7 +769,7 @@ pub const Tokenizer = struct { |
| 769 | } | 769 | } |
| 770 | }, | 770 | }, |
| 771 | else => { | 771 | else => { |
| 772 | result.tag = .Invalid; | 772 | result.tag = .invalid; |
| 773 | break; | 773 | break; |
| 774 | }, | 774 | }, |
| 775 | }, | 775 | }, |
| ... | @@ -780,7 +780,7 @@ pub const Tokenizer = struct { | ... | @@ -780,7 +780,7 @@ pub const Tokenizer = struct { |
| 780 | seen_escape_digits = 0; | 780 | seen_escape_digits = 0; |
| 781 | }, | 781 | }, |
| 782 | else => { | 782 | else => { |
| 783 | result.tag = .Invalid; | 783 | result.tag = .invalid; |
| 784 | state = .char_literal_unicode_invalid; | 784 | state = .char_literal_unicode_invalid; |
| 785 | }, | 785 | }, |
| 786 | }, | 786 | }, |
| ... | @@ -791,14 +791,14 @@ pub const Tokenizer = struct { | ... | @@ -791,14 +791,14 @@ pub const Tokenizer = struct { |
| 791 | }, | 791 | }, |
| 792 | '}' => { | 792 | '}' => { |
| 793 | if (seen_escape_digits == 0) { | 793 | if (seen_escape_digits == 0) { |
| 794 | result.tag = .Invalid; | 794 | result.tag = .invalid; |
| 795 | state = .char_literal_unicode_invalid; | 795 | state = .char_literal_unicode_invalid; |
| 796 | } else { | 796 | } else { |
| 797 | state = .char_literal_end; | 797 | state = .char_literal_end; |
| 798 | } | 798 | } |
| 799 | }, | 799 | }, |
| 800 | else => { | 800 | else => { |
| 801 | result.tag = .Invalid; | 801 | result.tag = .invalid; |
| 802 | state = .char_literal_unicode_invalid; | 802 | state = .char_literal_unicode_invalid; |
| 803 | }, | 803 | }, |
| 804 | }, | 804 | }, |
| ... | @@ -813,12 +813,12 @@ pub const Tokenizer = struct { | ... | @@ -813,12 +813,12 @@ pub const Tokenizer = struct { |
| 813 | 813 | ||
| 814 | .char_literal_end => switch (c) { | 814 | .char_literal_end => switch (c) { |
| 815 | '\'' => { | 815 | '\'' => { |
| 816 | result.tag = .CharLiteral; | 816 | result.tag = .char_literal; |
| 817 | self.index += 1; | 817 | self.index += 1; |
| 818 | break; | 818 | break; |
| 819 | }, | 819 | }, |
| 820 | else => { | 820 | else => { |
| 821 | result.tag = .Invalid; | 821 | result.tag = .invalid; |
| 822 | break; | 822 | break; |
| 823 | }, | 823 | }, |
| 824 | }, | 824 | }, |
| ... | @@ -831,7 +831,7 @@ pub const Tokenizer = struct { | ... | @@ -831,7 +831,7 @@ pub const Tokenizer = struct { |
| 831 | } | 831 | } |
| 832 | }, | 832 | }, |
| 833 | else => { | 833 | else => { |
| 834 | result.tag = .Invalid; | 834 | result.tag = .invalid; |
| 835 | break; | 835 | break; |
| 836 | }, | 836 | }, |
| 837 | }, | 837 | }, |
| ... | @@ -847,58 +847,58 @@ pub const Tokenizer = struct { | ... | @@ -847,58 +847,58 @@ pub const Tokenizer = struct { |
| 847 | 847 | ||
| 848 | .bang => switch (c) { | 848 | .bang => switch (c) { |
| 849 | '=' => { | 849 | '=' => { |
| 850 | result.tag = .BangEqual; | 850 | result.tag = .bang_equal; |
| 851 | self.index += 1; | 851 | self.index += 1; |
| 852 | break; | 852 | break; |
| 853 | }, | 853 | }, |
| 854 | else => { | 854 | else => { |
| 855 | result.tag = .Bang; | 855 | result.tag = .bang; |
| 856 | break; | 856 | break; |
| 857 | }, | 857 | }, |
| 858 | }, | 858 | }, |
| 859 | 859 | ||
| 860 | .pipe => switch (c) { | 860 | .pipe => switch (c) { |
| 861 | '=' => { | 861 | '=' => { |
| 862 | result.tag = .PipeEqual; | 862 | result.tag = .pipe_equal; |
| 863 | self.index += 1; | 863 | self.index += 1; |
| 864 | break; | 864 | break; |
| 865 | }, | 865 | }, |
| 866 | '|' => { | 866 | '|' => { |
| 867 | result.tag = .PipePipe; | 867 | result.tag = .pipe_pipe; |
| 868 | self.index += 1; | 868 | self.index += 1; |
| 869 | break; | 869 | break; |
| 870 | }, | 870 | }, |
| 871 | else => { | 871 | else => { |
| 872 | result.tag = .Pipe; | 872 | result.tag = .pipe; |
| 873 | break; | 873 | break; |
| 874 | }, | 874 | }, |
| 875 | }, | 875 | }, |
| 876 | 876 | ||
| 877 | .equal => switch (c) { | 877 | .equal => switch (c) { |
| 878 | '=' => { | 878 | '=' => { |
| 879 | result.tag = .EqualEqual; | 879 | result.tag = .equal_equal; |
| 880 | self.index += 1; | 880 | self.index += 1; |
| 881 | break; | 881 | break; |
| 882 | }, | 882 | }, |
| 883 | '>' => { | 883 | '>' => { |
| 884 | result.tag = .EqualAngleBracketRight; | 884 | result.tag = .equal_angle_bracket_right; |
| 885 | self.index += 1; | 885 | self.index += 1; |
| 886 | break; | 886 | break; |
| 887 | }, | 887 | }, |
| 888 | else => { | 888 | else => { |
| 889 | result.tag = .Equal; | 889 | result.tag = .equal; |
| 890 | break; | 890 | break; |
| 891 | }, | 891 | }, |
| 892 | }, | 892 | }, |
| 893 | 893 | ||
| 894 | .minus => switch (c) { | 894 | .minus => switch (c) { |
| 895 | '>' => { | 895 | '>' => { |
| 896 | result.tag = .Arrow; | 896 | result.tag = .arrow; |
| 897 | self.index += 1; | 897 | self.index += 1; |
| 898 | break; | 898 | break; |
| 899 | }, | 899 | }, |
| 900 | '=' => { | 900 | '=' => { |
| 901 | result.tag = .MinusEqual; | 901 | result.tag = .minus_equal; |
| 902 | self.index += 1; | 902 | self.index += 1; |
| 903 | break; | 903 | break; |
| 904 | }, | 904 | }, |
| ... | @@ -906,19 +906,19 @@ pub const Tokenizer = struct { | ... | @@ -906,19 +906,19 @@ pub const Tokenizer = struct { |
| 906 | state = .minus_percent; | 906 | state = .minus_percent; |
| 907 | }, | 907 | }, |
| 908 | else => { | 908 | else => { |
| 909 | result.tag = .Minus; | 909 | result.tag = .minus; |
| 910 | break; | 910 | break; |
| 911 | }, | 911 | }, |
| 912 | }, | 912 | }, |
| 913 | 913 | ||
| 914 | .minus_percent => switch (c) { | 914 | .minus_percent => switch (c) { |
| 915 | '=' => { | 915 | '=' => { |
| 916 | result.tag = .MinusPercentEqual; | 916 | result.tag = .minus_percent_equal; |
| 917 | self.index += 1; | 917 | self.index += 1; |
| 918 | break; | 918 | break; |
| 919 | }, | 919 | }, |
| 920 | else => { | 920 | else => { |
| 921 | result.tag = .MinusPercent; | 921 | result.tag = .minus_percent; |
| 922 | break; | 922 | break; |
| 923 | }, | 923 | }, |
| 924 | }, | 924 | }, |
| ... | @@ -928,24 +928,24 @@ pub const Tokenizer = struct { | ... | @@ -928,24 +928,24 @@ pub const Tokenizer = struct { |
| 928 | state = .angle_bracket_angle_bracket_left; | 928 | state = .angle_bracket_angle_bracket_left; |
| 929 | }, | 929 | }, |
| 930 | '=' => { | 930 | '=' => { |
| 931 | result.tag = .AngleBracketLeftEqual; | 931 | result.tag = .angle_bracket_left_equal; |
| 932 | self.index += 1; | 932 | self.index += 1; |
| 933 | break; | 933 | break; |
| 934 | }, | 934 | }, |
| 935 | else => { | 935 | else => { |
| 936 | result.tag = .AngleBracketLeft; | 936 | result.tag = .angle_bracket_left; |
| 937 | break; | 937 | break; |
| 938 | }, | 938 | }, |
| 939 | }, | 939 | }, |
| 940 | 940 | ||
| 941 | .angle_bracket_angle_bracket_left => switch (c) { | 941 | .angle_bracket_angle_bracket_left => switch (c) { |
| 942 | '=' => { | 942 | '=' => { |
| 943 | result.tag = .AngleBracketAngleBracketLeftEqual; | 943 | result.tag = .angle_bracket_angle_bracket_left_equal; |
| 944 | self.index += 1; | 944 | self.index += 1; |
| 945 | break; | 945 | break; |
| 946 | }, | 946 | }, |
| 947 | else => { | 947 | else => { |
| 948 | result.tag = .AngleBracketAngleBracketLeft; | 948 | result.tag = .angle_bracket_angle_bracket_left; |
| 949 | break; | 949 | break; |
| 950 | }, | 950 | }, |
| 951 | }, | 951 | }, |
| ... | @@ -955,24 +955,24 @@ pub const Tokenizer = struct { | ... | @@ -955,24 +955,24 @@ pub const Tokenizer = struct { |
| 955 | state = .angle_bracket_angle_bracket_right; | 955 | state = .angle_bracket_angle_bracket_right; |
| 956 | }, | 956 | }, |
| 957 | '=' => { | 957 | '=' => { |
| 958 | result.tag = .AngleBracketRightEqual; | 958 | result.tag = .angle_bracket_right_equal; |
| 959 | self.index += 1; | 959 | self.index += 1; |
| 960 | break; | 960 | break; |
| 961 | }, | 961 | }, |
| 962 | else => { | 962 | else => { |
| 963 | result.tag = .AngleBracketRight; | 963 | result.tag = .angle_bracket_right; |
| 964 | break; | 964 | break; |
| 965 | }, | 965 | }, |
| 966 | }, | 966 | }, |
| 967 | 967 | ||
| 968 | .angle_bracket_angle_bracket_right => switch (c) { | 968 | .angle_bracket_angle_bracket_right => switch (c) { |
| 969 | '=' => { | 969 | '=' => { |
| 970 | result.tag = .AngleBracketAngleBracketRightEqual; | 970 | result.tag = .angle_bracket_angle_bracket_right_equal; |
| 971 | self.index += 1; | 971 | self.index += 1; |
| 972 | break; | 972 | break; |
| 973 | }, | 973 | }, |
| 974 | else => { | 974 | else => { |
| 975 | result.tag = .AngleBracketAngleBracketRight; | 975 | result.tag = .angle_bracket_angle_bracket_right; |
| 976 | break; | 976 | break; |
| 977 | }, | 977 | }, |
| 978 | }, | 978 | }, |
| ... | @@ -985,30 +985,30 @@ pub const Tokenizer = struct { | ... | @@ -985,30 +985,30 @@ pub const Tokenizer = struct { |
| 985 | state = .period_asterisk; | 985 | state = .period_asterisk; |
| 986 | }, | 986 | }, |
| 987 | else => { | 987 | else => { |
| 988 | result.tag = .Period; | 988 | result.tag = .period; |
| 989 | break; | 989 | break; |
| 990 | }, | 990 | }, |
| 991 | }, | 991 | }, |
| 992 | 992 | ||
| 993 | .period_2 => switch (c) { | 993 | .period_2 => switch (c) { |
| 994 | '.' => { | 994 | '.' => { |
| 995 | result.tag = .Ellipsis3; | 995 | result.tag = .ellipsis3; |
| 996 | self.index += 1; | 996 | self.index += 1; |
| 997 | break; | 997 | break; |
| 998 | }, | 998 | }, |
| 999 | else => { | 999 | else => { |
| 1000 | result.tag = .Ellipsis2; | 1000 | result.tag = .ellipsis2; |
| 1001 | break; | 1001 | break; |
| 1002 | }, | 1002 | }, |
| 1003 | }, | 1003 | }, |
| 1004 | 1004 | ||
| 1005 | .period_asterisk => switch (c) { | 1005 | .period_asterisk => switch (c) { |
| 1006 | '*' => { | 1006 | '*' => { |
| 1007 | result.tag = .Invalid_periodasterisks; | 1007 | result.tag = .invalid_periodasterisks; |
| 1008 | break; | 1008 | break; |
| 1009 | }, | 1009 | }, |
| 1010 | else => { | 1010 | else => { |
| 1011 | result.tag = .PeriodAsterisk; | 1011 | result.tag = .period_asterisk; |
| 1012 | break; | 1012 | break; |
| 1013 | }, | 1013 | }, |
| 1014 | }, | 1014 | }, |
| ... | @@ -1018,12 +1018,12 @@ pub const Tokenizer = struct { | ... | @@ -1018,12 +1018,12 @@ pub const Tokenizer = struct { |
| 1018 | state = .line_comment_start; | 1018 | state = .line_comment_start; |
| 1019 | }, | 1019 | }, |
| 1020 | '=' => { | 1020 | '=' => { |
| 1021 | result.tag = .SlashEqual; | 1021 | result.tag = .slash_equal; |
| 1022 | self.index += 1; | 1022 | self.index += 1; |
| 1023 | break; | 1023 | break; |
| 1024 | }, | 1024 | }, |
| 1025 | else => { | 1025 | else => { |
| 1026 | result.tag = .Slash; | 1026 | result.tag = .slash; |
| 1027 | break; | 1027 | break; |
| 1028 | }, | 1028 | }, |
| 1029 | }, | 1029 | }, |
| ... | @@ -1032,7 +1032,7 @@ pub const Tokenizer = struct { | ... | @@ -1032,7 +1032,7 @@ pub const Tokenizer = struct { |
| 1032 | state = .doc_comment_start; | 1032 | state = .doc_comment_start; |
| 1033 | }, | 1033 | }, |
| 1034 | '!' => { | 1034 | '!' => { |
| 1035 | result.tag = .ContainerDocComment; | 1035 | result.tag = .container_doc_comment; |
| 1036 | state = .container_doc_comment; | 1036 | state = .container_doc_comment; |
| 1037 | }, | 1037 | }, |
| 1038 | '\n' => { | 1038 | '\n' => { |
| ... | @@ -1050,16 +1050,16 @@ pub const Tokenizer = struct { | ... | @@ -1050,16 +1050,16 @@ pub const Tokenizer = struct { |
| 1050 | state = .line_comment; | 1050 | state = .line_comment; |
| 1051 | }, | 1051 | }, |
| 1052 | '\n' => { | 1052 | '\n' => { |
| 1053 | result.tag = .DocComment; | 1053 | result.tag = .doc_comment; |
| 1054 | break; | 1054 | break; |
| 1055 | }, | 1055 | }, |
| 1056 | '\t', '\r' => { | 1056 | '\t', '\r' => { |
| 1057 | state = .doc_comment; | 1057 | state = .doc_comment; |
| 1058 | result.tag = .DocComment; | 1058 | result.tag = .doc_comment; |
| 1059 | }, | 1059 | }, |
| 1060 | else => { | 1060 | else => { |
| 1061 | state = .doc_comment; | 1061 | state = .doc_comment; |
| 1062 | result.tag = .DocComment; | 1062 | result.tag = .doc_comment; |
| 1063 | self.checkLiteralCharacter(); | 1063 | self.checkLiteralCharacter(); |
| 1064 | }, | 1064 | }, |
| 1065 | }, | 1065 | }, |
| ... | @@ -1093,7 +1093,7 @@ pub const Tokenizer = struct { | ... | @@ -1093,7 +1093,7 @@ pub const Tokenizer = struct { |
| 1093 | }, | 1093 | }, |
| 1094 | else => { | 1094 | else => { |
| 1095 | if (isIdentifierChar(c)) { | 1095 | if (isIdentifierChar(c)) { |
| 1096 | result.tag = .Invalid; | 1096 | result.tag = .invalid; |
| 1097 | } | 1097 | } |
| 1098 | break; | 1098 | break; |
| 1099 | }, | 1099 | }, |
| ... | @@ -1103,7 +1103,7 @@ pub const Tokenizer = struct { | ... | @@ -1103,7 +1103,7 @@ pub const Tokenizer = struct { |
| 1103 | state = .int_literal_bin; | 1103 | state = .int_literal_bin; |
| 1104 | }, | 1104 | }, |
| 1105 | else => { | 1105 | else => { |
| 1106 | result.tag = .Invalid; | 1106 | result.tag = .invalid; |
| 1107 | break; | 1107 | break; |
| 1108 | }, | 1108 | }, |
| 1109 | }, | 1109 | }, |
| ... | @@ -1114,7 +1114,7 @@ pub const Tokenizer = struct { | ... | @@ -1114,7 +1114,7 @@ pub const Tokenizer = struct { |
| 1114 | '0'...'1' => {}, | 1114 | '0'...'1' => {}, |
| 1115 | else => { | 1115 | else => { |
| 1116 | if (isIdentifierChar(c)) { | 1116 | if (isIdentifierChar(c)) { |
| 1117 | result.tag = .Invalid; | 1117 | result.tag = .invalid; |
| 1118 | } | 1118 | } |
| 1119 | break; | 1119 | break; |
| 1120 | }, | 1120 | }, |
| ... | @@ -1124,7 +1124,7 @@ pub const Tokenizer = struct { | ... | @@ -1124,7 +1124,7 @@ pub const Tokenizer = struct { |
| 1124 | state = .int_literal_oct; | 1124 | state = .int_literal_oct; |
| 1125 | }, | 1125 | }, |
| 1126 | else => { | 1126 | else => { |
| 1127 | result.tag = .Invalid; | 1127 | result.tag = .invalid; |
| 1128 | break; | 1128 | break; |
| 1129 | }, | 1129 | }, |
| 1130 | }, | 1130 | }, |
| ... | @@ -1135,7 +1135,7 @@ pub const Tokenizer = struct { | ... | @@ -1135,7 +1135,7 @@ pub const Tokenizer = struct { |
| 1135 | '0'...'7' => {}, | 1135 | '0'...'7' => {}, |
| 1136 | else => { | 1136 | else => { |
| 1137 | if (isIdentifierChar(c)) { | 1137 | if (isIdentifierChar(c)) { |
| 1138 | result.tag = .Invalid; | 1138 | result.tag = .invalid; |
| 1139 | } | 1139 | } |
| 1140 | break; | 1140 | break; |
| 1141 | }, | 1141 | }, |
| ... | @@ -1145,7 +1145,7 @@ pub const Tokenizer = struct { | ... | @@ -1145,7 +1145,7 @@ pub const Tokenizer = struct { |
| 1145 | state = .int_literal_dec; | 1145 | state = .int_literal_dec; |
| 1146 | }, | 1146 | }, |
| 1147 | else => { | 1147 | else => { |
| 1148 | result.tag = .Invalid; | 1148 | result.tag = .invalid; |
| 1149 | break; | 1149 | break; |
| 1150 | }, | 1150 | }, |
| 1151 | }, | 1151 | }, |
| ... | @@ -1155,16 +1155,16 @@ pub const Tokenizer = struct { | ... | @@ -1155,16 +1155,16 @@ pub const Tokenizer = struct { |
| 1155 | }, | 1155 | }, |
| 1156 | '.' => { | 1156 | '.' => { |
| 1157 | state = .num_dot_dec; | 1157 | state = .num_dot_dec; |
| 1158 | result.tag = .FloatLiteral; | 1158 | result.tag = .float_literal; |
| 1159 | }, | 1159 | }, |
| 1160 | 'e', 'E' => { | 1160 | 'e', 'E' => { |
| 1161 | state = .float_exponent_unsigned; | 1161 | state = .float_exponent_unsigned; |
| 1162 | result.tag = .FloatLiteral; | 1162 | result.tag = .float_literal; |
| 1163 | }, | 1163 | }, |
| 1164 | '0'...'9' => {}, | 1164 | '0'...'9' => {}, |
| 1165 | else => { | 1165 | else => { |
| 1166 | if (isIdentifierChar(c)) { | 1166 | if (isIdentifierChar(c)) { |
| 1167 | result.tag = .Invalid; | 1167 | result.tag = .invalid; |
| 1168 | } | 1168 | } |
| 1169 | break; | 1169 | break; |
| 1170 | }, | 1170 | }, |
| ... | @@ -1174,7 +1174,7 @@ pub const Tokenizer = struct { | ... | @@ -1174,7 +1174,7 @@ pub const Tokenizer = struct { |
| 1174 | state = .int_literal_hex; | 1174 | state = .int_literal_hex; |
| 1175 | }, | 1175 | }, |
| 1176 | else => { | 1176 | else => { |
| 1177 | result.tag = .Invalid; | 1177 | result.tag = .invalid; |
| 1178 | break; | 1178 | break; |
| 1179 | }, | 1179 | }, |
| 1180 | }, | 1180 | }, |
| ... | @@ -1184,23 +1184,23 @@ pub const Tokenizer = struct { | ... | @@ -1184,23 +1184,23 @@ pub const Tokenizer = struct { |
| 1184 | }, | 1184 | }, |
| 1185 | '.' => { | 1185 | '.' => { |
| 1186 | state = .num_dot_hex; | 1186 | state = .num_dot_hex; |
| 1187 | result.tag = .FloatLiteral; | 1187 | result.tag = .float_literal; |
| 1188 | }, | 1188 | }, |
| 1189 | 'p', 'P' => { | 1189 | 'p', 'P' => { |
| 1190 | state = .float_exponent_unsigned; | 1190 | state = .float_exponent_unsigned; |
| 1191 | result.tag = .FloatLiteral; | 1191 | result.tag = .float_literal; |
| 1192 | }, | 1192 | }, |
| 1193 | '0'...'9', 'a'...'f', 'A'...'F' => {}, | 1193 | '0'...'9', 'a'...'f', 'A'...'F' => {}, |
| 1194 | else => { | 1194 | else => { |
| 1195 | if (isIdentifierChar(c)) { | 1195 | if (isIdentifierChar(c)) { |
| 1196 | result.tag = .Invalid; | 1196 | result.tag = .invalid; |
| 1197 | } | 1197 | } |
| 1198 | break; | 1198 | break; |
| 1199 | }, | 1199 | }, |
| 1200 | }, | 1200 | }, |
| 1201 | .num_dot_dec => switch (c) { | 1201 | .num_dot_dec => switch (c) { |
| 1202 | '.' => { | 1202 | '.' => { |
| 1203 | result.tag = .IntegerLiteral; | 1203 | result.tag = .integer_literal; |
| 1204 | self.index -= 1; | 1204 | self.index -= 1; |
| 1205 | state = .start; | 1205 | state = .start; |
| 1206 | break; | 1206 | break; |
| ... | @@ -1213,14 +1213,14 @@ pub const Tokenizer = struct { | ... | @@ -1213,14 +1213,14 @@ pub const Tokenizer = struct { |
| 1213 | }, | 1213 | }, |
| 1214 | else => { | 1214 | else => { |
| 1215 | if (isIdentifierChar(c)) { | 1215 | if (isIdentifierChar(c)) { |
| 1216 | result.tag = .Invalid; | 1216 | result.tag = .invalid; |
| 1217 | } | 1217 | } |
| 1218 | break; | 1218 | break; |
| 1219 | }, | 1219 | }, |
| 1220 | }, | 1220 | }, |
| 1221 | .num_dot_hex => switch (c) { | 1221 | .num_dot_hex => switch (c) { |
| 1222 | '.' => { | 1222 | '.' => { |
| 1223 | result.tag = .IntegerLiteral; | 1223 | result.tag = .integer_literal; |
| 1224 | self.index -= 1; | 1224 | self.index -= 1; |
| 1225 | state = .start; | 1225 | state = .start; |
| 1226 | break; | 1226 | break; |
| ... | @@ -1229,12 +1229,12 @@ pub const Tokenizer = struct { | ... | @@ -1229,12 +1229,12 @@ pub const Tokenizer = struct { |
| 1229 | state = .float_exponent_unsigned; | 1229 | state = .float_exponent_unsigned; |
| 1230 | }, | 1230 | }, |
| 1231 | '0'...'9', 'a'...'f', 'A'...'F' => { | 1231 | '0'...'9', 'a'...'f', 'A'...'F' => { |
| 1232 | result.tag = .FloatLiteral; | 1232 | result.tag = .float_literal; |
| 1233 | state = .float_fraction_hex; | 1233 | state = .float_fraction_hex; |
| 1234 | }, | 1234 | }, |
| 1235 | else => { | 1235 | else => { |
| 1236 | if (isIdentifierChar(c)) { | 1236 | if (isIdentifierChar(c)) { |
| 1237 | result.tag = .Invalid; | 1237 | result.tag = .invalid; |
| 1238 | } | 1238 | } |
| 1239 | break; | 1239 | break; |
| 1240 | }, | 1240 | }, |
| ... | @@ -1244,7 +1244,7 @@ pub const Tokenizer = struct { | ... | @@ -1244,7 +1244,7 @@ pub const Tokenizer = struct { |
| 1244 | state = .float_fraction_dec; | 1244 | state = .float_fraction_dec; |
| 1245 | }, | 1245 | }, |
| 1246 | else => { | 1246 | else => { |
| 1247 | result.tag = .Invalid; | 1247 | result.tag = .invalid; |
| 1248 | break; | 1248 | break; |
| 1249 | }, | 1249 | }, |
| 1250 | }, | 1250 | }, |
| ... | @@ -1258,7 +1258,7 @@ pub const Tokenizer = struct { | ... | @@ -1258,7 +1258,7 @@ pub const Tokenizer = struct { |
| 1258 | '0'...'9' => {}, | 1258 | '0'...'9' => {}, |
| 1259 | else => { | 1259 | else => { |
| 1260 | if (isIdentifierChar(c)) { | 1260 | if (isIdentifierChar(c)) { |
| 1261 | result.tag = .Invalid; | 1261 | result.tag = .invalid; |
| 1262 | } | 1262 | } |
| 1263 | break; | 1263 | break; |
| 1264 | }, | 1264 | }, |
| ... | @@ -1268,7 +1268,7 @@ pub const Tokenizer = struct { | ... | @@ -1268,7 +1268,7 @@ pub const Tokenizer = struct { |
| 1268 | state = .float_fraction_hex; | 1268 | state = .float_fraction_hex; |
| 1269 | }, | 1269 | }, |
| 1270 | else => { | 1270 | else => { |
| 1271 | result.tag = .Invalid; | 1271 | result.tag = .invalid; |
| 1272 | break; | 1272 | break; |
| 1273 | }, | 1273 | }, |
| 1274 | }, | 1274 | }, |
| ... | @@ -1282,7 +1282,7 @@ pub const Tokenizer = struct { | ... | @@ -1282,7 +1282,7 @@ pub const Tokenizer = struct { |
| 1282 | '0'...'9', 'a'...'f', 'A'...'F' => {}, | 1282 | '0'...'9', 'a'...'f', 'A'...'F' => {}, |
| 1283 | else => { | 1283 | else => { |
| 1284 | if (isIdentifierChar(c)) { | 1284 | if (isIdentifierChar(c)) { |
| 1285 | result.tag = .Invalid; | 1285 | result.tag = .invalid; |
| 1286 | } | 1286 | } |
| 1287 | break; | 1287 | break; |
| 1288 | }, | 1288 | }, |
| ... | @@ -1302,7 +1302,7 @@ pub const Tokenizer = struct { | ... | @@ -1302,7 +1302,7 @@ pub const Tokenizer = struct { |
| 1302 | state = .float_exponent_num; | 1302 | state = .float_exponent_num; |
| 1303 | }, | 1303 | }, |
| 1304 | else => { | 1304 | else => { |
| 1305 | result.tag = .Invalid; | 1305 | result.tag = .invalid; |
| 1306 | break; | 1306 | break; |
| 1307 | }, | 1307 | }, |
| 1308 | }, | 1308 | }, |
| ... | @@ -1313,7 +1313,7 @@ pub const Tokenizer = struct { | ... | @@ -1313,7 +1313,7 @@ pub const Tokenizer = struct { |
| 1313 | '0'...'9' => {}, | 1313 | '0'...'9' => {}, |
| 1314 | else => { | 1314 | else => { |
| 1315 | if (isIdentifierChar(c)) { | 1315 | if (isIdentifierChar(c)) { |
| 1316 | result.tag = .Invalid; | 1316 | result.tag = .invalid; |
| 1317 | } | 1317 | } |
| 1318 | break; | 1318 | break; |
| 1319 | }, | 1319 | }, |
| ... | @@ -1344,10 +1344,10 @@ pub const Tokenizer = struct { | ... | @@ -1344,10 +1344,10 @@ pub const Tokenizer = struct { |
| 1344 | } | 1344 | } |
| 1345 | }, | 1345 | }, |
| 1346 | .doc_comment, .doc_comment_start => { | 1346 | .doc_comment, .doc_comment_start => { |
| 1347 | result.tag = .DocComment; | 1347 | result.tag = .doc_comment; |
| 1348 | }, | 1348 | }, |
| 1349 | .container_doc_comment => { | 1349 | .container_doc_comment => { |
| 1350 | result.tag = .ContainerDocComment; | 1350 | result.tag = .container_doc_comment; |
| 1351 | }, | 1351 | }, |
| 1352 | 1352 | ||
| 1353 | .int_literal_dec_no_underscore, | 1353 | .int_literal_dec_no_underscore, |
| ... | @@ -1370,76 +1370,76 @@ pub const Tokenizer = struct { | ... | @@ -1370,76 +1370,76 @@ pub const Tokenizer = struct { |
| 1370 | .char_literal_unicode, | 1370 | .char_literal_unicode, |
| 1371 | .string_literal_backslash, | 1371 | .string_literal_backslash, |
| 1372 | => { | 1372 | => { |
| 1373 | result.tag = .Invalid; | 1373 | result.tag = .invalid; |
| 1374 | }, | 1374 | }, |
| 1375 | 1375 | ||
| 1376 | .equal => { | 1376 | .equal => { |
| 1377 | result.tag = .Equal; | 1377 | result.tag = .equal; |
| 1378 | }, | 1378 | }, |
| 1379 | .bang => { | 1379 | .bang => { |
| 1380 | result.tag = .Bang; | 1380 | result.tag = .bang; |
| 1381 | }, | 1381 | }, |
| 1382 | .minus => { | 1382 | .minus => { |
| 1383 | result.tag = .Minus; | 1383 | result.tag = .minus; |
| 1384 | }, | 1384 | }, |
| 1385 | .slash => { | 1385 | .slash => { |
| 1386 | result.tag = .Slash; | 1386 | result.tag = .slash; |
| 1387 | }, | 1387 | }, |
| 1388 | .zero => { | 1388 | .zero => { |
| 1389 | result.tag = .IntegerLiteral; | 1389 | result.tag = .integer_literal; |
| 1390 | }, | 1390 | }, |
| 1391 | .ampersand => { | 1391 | .ampersand => { |
| 1392 | result.tag = .Ampersand; | 1392 | result.tag = .ampersand; |
| 1393 | }, | 1393 | }, |
| 1394 | .period => { | 1394 | .period => { |
| 1395 | result.tag = .Period; | 1395 | result.tag = .period; |
| 1396 | }, | 1396 | }, |
| 1397 | .period_2 => { | 1397 | .period_2 => { |
| 1398 | result.tag = .Ellipsis2; | 1398 | result.tag = .ellipsis2; |
| 1399 | }, | 1399 | }, |
| 1400 | .period_asterisk => { | 1400 | .period_asterisk => { |
| 1401 | result.tag = .PeriodAsterisk; | 1401 | result.tag = .period_asterisk; |
| 1402 | }, | 1402 | }, |
| 1403 | .pipe => { | 1403 | .pipe => { |
| 1404 | result.tag = .Pipe; | 1404 | result.tag = .pipe; |
| 1405 | }, | 1405 | }, |
| 1406 | .angle_bracket_angle_bracket_right => { | 1406 | .angle_bracket_angle_bracket_right => { |
| 1407 | result.tag = .AngleBracketAngleBracketRight; | 1407 | result.tag = .angle_bracket_angle_bracket_right; |
| 1408 | }, | 1408 | }, |
| 1409 | .angle_bracket_right => { | 1409 | .angle_bracket_right => { |
| 1410 | result.tag = .AngleBracketRight; | 1410 | result.tag = .angle_bracket_right; |
| 1411 | }, | 1411 | }, |
| 1412 | .angle_bracket_angle_bracket_left => { | 1412 | .angle_bracket_angle_bracket_left => { |
| 1413 | result.tag = .AngleBracketAngleBracketLeft; | 1413 | result.tag = .angle_bracket_angle_bracket_left; |
| 1414 | }, | 1414 | }, |
| 1415 | .angle_bracket_left => { | 1415 | .angle_bracket_left => { |
| 1416 | result.tag = .AngleBracketLeft; | 1416 | result.tag = .angle_bracket_left; |
| 1417 | }, | 1417 | }, |
| 1418 | .plus_percent => { | 1418 | .plus_percent => { |
| 1419 | result.tag = .PlusPercent; | 1419 | result.tag = .plus_percent; |
| 1420 | }, | 1420 | }, |
| 1421 | .plus => { | 1421 | .plus => { |
| 1422 | result.tag = .Plus; | 1422 | result.tag = .plus; |
| 1423 | }, | 1423 | }, |
| 1424 | .percent => { | 1424 | .percent => { |
| 1425 | result.tag = .Percent; | 1425 | result.tag = .percent; |
| 1426 | }, | 1426 | }, |
| 1427 | .caret => { | 1427 | .caret => { |
| 1428 | result.tag = .Caret; | 1428 | result.tag = .caret; |
| 1429 | }, | 1429 | }, |
| 1430 | .asterisk_percent => { | 1430 | .asterisk_percent => { |
| 1431 | result.tag = .AsteriskPercent; | 1431 | result.tag = .asterisk_percent; |
| 1432 | }, | 1432 | }, |
| 1433 | .asterisk => { | 1433 | .asterisk => { |
| 1434 | result.tag = .Asterisk; | 1434 | result.tag = .asterisk; |
| 1435 | }, | 1435 | }, |
| 1436 | .minus_percent => { | 1436 | .minus_percent => { |
| 1437 | result.tag = .MinusPercent; | 1437 | result.tag = .minus_percent; |
| 1438 | }, | 1438 | }, |
| 1439 | } | 1439 | } |
| 1440 | } | 1440 | } |
| 1441 | 1441 | ||
| 1442 | if (result.tag == .Eof) { | 1442 | if (result.tag == .eof) { |
| 1443 | if (self.pending_invalid_token) |token| { | 1443 | if (self.pending_invalid_token) |token| { |
| 1444 | self.pending_invalid_token = null; | 1444 | self.pending_invalid_token = null; |
| 1445 | return token; | 1445 | return token; |
| ... | @@ -1455,7 +1455,7 @@ pub const Tokenizer = struct { | ... | @@ -1455,7 +1455,7 @@ pub const Tokenizer = struct { |
| 1455 | const invalid_length = self.getInvalidCharacterLength(); | 1455 | const invalid_length = self.getInvalidCharacterLength(); |
| 1456 | if (invalid_length == 0) return; | 1456 | if (invalid_length == 0) return; |
| 1457 | self.pending_invalid_token = .{ | 1457 | self.pending_invalid_token = .{ |
| 1458 | .tag = .Invalid, | 1458 | .tag = .invalid, |
| 1459 | .loc = .{ | 1459 | .loc = .{ |
| 1460 | .start = self.index, | 1460 | .start = self.index, |
| 1461 | .end = self.index + invalid_length, | 1461 | .end = self.index + invalid_length, |
| ... | @@ -1502,7 +1502,7 @@ pub const Tokenizer = struct { | ... | @@ -1502,7 +1502,7 @@ pub const Tokenizer = struct { |
| 1502 | }; | 1502 | }; |
| 1503 | 1503 | ||
| 1504 | test "tokenizer" { | 1504 | test "tokenizer" { |
| 1505 | testTokenize("test", &[_]Token.Tag{.Keyword_test}); | 1505 | testTokenize("test", &.{.keyword_test}); |
| 1506 | } | 1506 | } |
| 1507 | 1507 | ||
| 1508 | test "line comment followed by top-level comptime" { | 1508 | test "line comment followed by top-level comptime" { |
| ... | @@ -1510,10 +1510,10 @@ test "line comment followed by top-level comptime" { | ... | @@ -1510,10 +1510,10 @@ test "line comment followed by top-level comptime" { |
| 1510 | \\// line comment | 1510 | \\// line comment |
| 1511 | \\comptime {} | 1511 | \\comptime {} |
| 1512 | \\ | 1512 | \\ |
| 1513 | , &[_]Token.Tag{ | 1513 | , &.{ |
| 1514 | .Keyword_comptime, | 1514 | .keyword_comptime, |
| 1515 | .LBrace, | 1515 | .l_brace, |
| 1516 | .RBrace, | 1516 | .r_brace, |
| 1517 | }); | 1517 | }); |
| 1518 | } | 1518 | } |
| 1519 | 1519 | ||
| ... | @@ -1521,199 +1521,199 @@ test "tokenizer - unknown length pointer and then c pointer" { | ... | @@ -1521,199 +1521,199 @@ test "tokenizer - unknown length pointer and then c pointer" { |
| 1521 | testTokenize( | 1521 | testTokenize( |
| 1522 | \\[*]u8 | 1522 | \\[*]u8 |
| 1523 | \\[*c]u8 | 1523 | \\[*c]u8 |
| 1524 | , &[_]Token.Tag{ | 1524 | , &.{ |
| 1525 | .LBracket, | 1525 | .l_bracket, |
| 1526 | .Asterisk, | 1526 | .asterisk, |
| 1527 | .RBracket, | 1527 | .r_bracket, |
| 1528 | .Identifier, | 1528 | .identifier, |
| 1529 | .LBracket, | 1529 | .l_bracket, |
| 1530 | .Asterisk, | 1530 | .asterisk, |
| 1531 | .Identifier, | 1531 | .identifier, |
| 1532 | .RBracket, | 1532 | .r_bracket, |
| 1533 | .Identifier, | 1533 | .identifier, |
| 1534 | }); | 1534 | }); |
| 1535 | } | 1535 | } |
| 1536 | 1536 | ||
| 1537 | test "tokenizer - char literal with hex escape" { | 1537 | test "tokenizer - char literal with hex escape" { |
| 1538 | testTokenize( | 1538 | testTokenize( |
| 1539 | \\'\x1b' | 1539 | \\'\x1b' |
| 1540 | , &[_]Token.Tag{.CharLiteral}); | 1540 | , &.{.char_literal}); |
| 1541 | testTokenize( | 1541 | testTokenize( |
| 1542 | \\'\x1' | 1542 | \\'\x1' |
| 1543 | , &[_]Token.Tag{ .Invalid, .Invalid }); | 1543 | , &.{ .invalid, .invalid }); |
| 1544 | } | 1544 | } |
| 1545 | 1545 | ||
| 1546 | test "tokenizer - char literal with unicode escapes" { | 1546 | test "tokenizer - char literal with unicode escapes" { |
| 1547 | // Valid unicode escapes | 1547 | // Valid unicode escapes |
| 1548 | testTokenize( | 1548 | testTokenize( |
| 1549 | \\'\u{3}' | 1549 | \\'\u{3}' |
| 1550 | , &[_]Token.Tag{.CharLiteral}); | 1550 | , &.{.char_literal}); |
| 1551 | testTokenize( | 1551 | testTokenize( |
| 1552 | \\'\u{01}' | 1552 | \\'\u{01}' |
| 1553 | , &[_]Token.Tag{.CharLiteral}); | 1553 | , &.{.char_literal}); |
| 1554 | testTokenize( | 1554 | testTokenize( |
| 1555 | \\'\u{2a}' | 1555 | \\'\u{2a}' |
| 1556 | , &[_]Token.Tag{.CharLiteral}); | 1556 | , &.{.char_literal}); |
| 1557 | testTokenize( | 1557 | testTokenize( |
| 1558 | \\'\u{3f9}' | 1558 | \\'\u{3f9}' |
| 1559 | , &[_]Token.Tag{.CharLiteral}); | 1559 | , &.{.char_literal}); |
| 1560 | testTokenize( | 1560 | testTokenize( |
| 1561 | \\'\u{6E09aBc1523}' | 1561 | \\'\u{6E09aBc1523}' |
| 1562 | , &[_]Token.Tag{.CharLiteral}); | 1562 | , &.{.char_literal}); |
| 1563 | testTokenize( | 1563 | testTokenize( |
| 1564 | \\"\u{440}" | 1564 | \\"\u{440}" |
| 1565 | , &[_]Token.Tag{.StringLiteral}); | 1565 | , &.{.string_literal}); |
| 1566 | 1566 | ||
| 1567 | // Invalid unicode escapes | 1567 | // Invalid unicode escapes |
| 1568 | testTokenize( | 1568 | testTokenize( |
| 1569 | \\'\u' | 1569 | \\'\u' |
| 1570 | , &[_]Token.Tag{.Invalid}); | 1570 | , &.{.invalid}); |
| 1571 | testTokenize( | 1571 | testTokenize( |
| 1572 | \\'\u{{' | 1572 | \\'\u{{' |
| 1573 | , &[_]Token.Tag{ .Invalid, .Invalid }); | 1573 | , &.{ .invalid, .invalid }); |
| 1574 | testTokenize( | 1574 | testTokenize( |
| 1575 | \\'\u{}' | 1575 | \\'\u{}' |
| 1576 | , &[_]Token.Tag{ .Invalid, .Invalid }); | 1576 | , &.{ .invalid, .invalid }); |
| 1577 | testTokenize( | 1577 | testTokenize( |
| 1578 | \\'\u{s}' | 1578 | \\'\u{s}' |
| 1579 | , &[_]Token.Tag{ .Invalid, .Invalid }); | 1579 | , &.{ .invalid, .invalid }); |
| 1580 | testTokenize( | 1580 | testTokenize( |
| 1581 | \\'\u{2z}' | 1581 | \\'\u{2z}' |
| 1582 | , &[_]Token.Tag{ .Invalid, .Invalid }); | 1582 | , &.{ .invalid, .invalid }); |
| 1583 | testTokenize( | 1583 | testTokenize( |
| 1584 | \\'\u{4a' | 1584 | \\'\u{4a' |
| 1585 | , &[_]Token.Tag{.Invalid}); | 1585 | , &.{.invalid}); |
| 1586 | 1586 | ||
| 1587 | // Test old-style unicode literals | 1587 | // Test old-style unicode literals |
| 1588 | testTokenize( | 1588 | testTokenize( |
| 1589 | \\'\u0333' | 1589 | \\'\u0333' |
| 1590 | , &[_]Token.Tag{ .Invalid, .Invalid }); | 1590 | , &.{ .invalid, .invalid }); |
| 1591 | testTokenize( | 1591 | testTokenize( |
| 1592 | \\'\U0333' | 1592 | \\'\U0333' |
| 1593 | , &[_]Token.Tag{ .Invalid, .IntegerLiteral, .Invalid }); | 1593 | , &.{ .invalid, .integer_literal, .invalid }); |
| 1594 | } | 1594 | } |
| 1595 | 1595 | ||
| 1596 | test "tokenizer - char literal with unicode code point" { | 1596 | test "tokenizer - char literal with unicode code point" { |
| 1597 | testTokenize( | 1597 | testTokenize( |
| 1598 | \\'💩' | 1598 | \\'💩' |
| 1599 | , &[_]Token.Tag{.CharLiteral}); | 1599 | , &.{.char_literal}); |
| 1600 | } | 1600 | } |
| 1601 | 1601 | ||
| 1602 | test "tokenizer - float literal e exponent" { | 1602 | test "tokenizer - float literal e exponent" { |
| 1603 | testTokenize("a = 4.94065645841246544177e-324;\n", &[_]Token.Tag{ | 1603 | testTokenize("a = 4.94065645841246544177e-324;\n", &.{ |
| 1604 | .Identifier, | 1604 | .identifier, |
| 1605 | .Equal, | 1605 | .equal, |
| 1606 | .FloatLiteral, | 1606 | .float_literal, |
| 1607 | .Semicolon, | 1607 | .semicolon, |
| 1608 | }); | 1608 | }); |
| 1609 | } | 1609 | } |
| 1610 | 1610 | ||
| 1611 | test "tokenizer - float literal p exponent" { | 1611 | test "tokenizer - float literal p exponent" { |
| 1612 | testTokenize("a = 0x1.a827999fcef32p+1022;\n", &[_]Token.Tag{ | 1612 | testTokenize("a = 0x1.a827999fcef32p+1022;\n", &.{ |
| 1613 | .Identifier, | 1613 | .identifier, |
| 1614 | .Equal, | 1614 | .equal, |
| 1615 | .FloatLiteral, | 1615 | .float_literal, |
| 1616 | .Semicolon, | 1616 | .semicolon, |
| 1617 | }); | 1617 | }); |
| 1618 | } | 1618 | } |
| 1619 | 1619 | ||
| 1620 | test "tokenizer - chars" { | 1620 | test "tokenizer - chars" { |
| 1621 | testTokenize("'c'", &[_]Token.Tag{.CharLiteral}); | 1621 | testTokenize("'c'", &.{.char_literal}); |
| 1622 | } | 1622 | } |
| 1623 | 1623 | ||
| 1624 | test "tokenizer - invalid token characters" { | 1624 | test "tokenizer - invalid token characters" { |
| 1625 | testTokenize("#", &[_]Token.Tag{.Invalid}); | 1625 | testTokenize("#", &.{.invalid}); |
| 1626 | testTokenize("`", &[_]Token.Tag{.Invalid}); | 1626 | testTokenize("`", &.{.invalid}); |
| 1627 | testTokenize("'c", &[_]Token.Tag{.Invalid}); | 1627 | testTokenize("'c", &.{.invalid}); |
| 1628 | testTokenize("'", &[_]Token.Tag{.Invalid}); | 1628 | testTokenize("'", &.{.invalid}); |
| 1629 | testTokenize("''", &[_]Token.Tag{ .Invalid, .Invalid }); | 1629 | testTokenize("''", &.{ .invalid, .invalid }); |
| 1630 | } | 1630 | } |
| 1631 | 1631 | ||
| 1632 | test "tokenizer - invalid literal/comment characters" { | 1632 | test "tokenizer - invalid literal/comment characters" { |
| 1633 | testTokenize("\"\x00\"", &[_]Token.Tag{ | 1633 | testTokenize("\"\x00\"", &.{ |
| 1634 | .StringLiteral, | 1634 | .string_literal, |
| 1635 | .Invalid, | 1635 | .invalid, |
| 1636 | }); | 1636 | }); |
| 1637 | testTokenize("//\x00", &[_]Token.Tag{ | 1637 | testTokenize("//\x00", &.{ |
| 1638 | .Invalid, | 1638 | .invalid, |
| 1639 | }); | 1639 | }); |
| 1640 | testTokenize("//\x1f", &[_]Token.Tag{ | 1640 | testTokenize("//\x1f", &.{ |
| 1641 | .Invalid, | 1641 | .invalid, |
| 1642 | }); | 1642 | }); |
| 1643 | testTokenize("//\x7f", &[_]Token.Tag{ | 1643 | testTokenize("//\x7f", &.{ |
| 1644 | .Invalid, | 1644 | .invalid, |
| 1645 | }); | 1645 | }); |
| 1646 | } | 1646 | } |
| 1647 | 1647 | ||
| 1648 | test "tokenizer - utf8" { | 1648 | test "tokenizer - utf8" { |
| 1649 | testTokenize("//\xc2\x80", &[_]Token.Tag{}); | 1649 | testTokenize("//\xc2\x80", &.{}); |
| 1650 | testTokenize("//\xf4\x8f\xbf\xbf", &[_]Token.Tag{}); | 1650 | testTokenize("//\xf4\x8f\xbf\xbf", &.{}); |
| 1651 | } | 1651 | } |
| 1652 | 1652 | ||
| 1653 | test "tokenizer - invalid utf8" { | 1653 | test "tokenizer - invalid utf8" { |
| 1654 | testTokenize("//\x80", &[_]Token.Tag{ | 1654 | testTokenize("//\x80", &.{ |
| 1655 | .Invalid, | 1655 | .invalid, |
| 1656 | }); | 1656 | }); |
| 1657 | testTokenize("//\xbf", &[_]Token.Tag{ | 1657 | testTokenize("//\xbf", &.{ |
| 1658 | .Invalid, | 1658 | .invalid, |
| 1659 | }); | 1659 | }); |
| 1660 | testTokenize("//\xf8", &[_]Token.Tag{ | 1660 | testTokenize("//\xf8", &.{ |
| 1661 | .Invalid, | 1661 | .invalid, |
| 1662 | }); | 1662 | }); |
| 1663 | testTokenize("//\xff", &[_]Token.Tag{ | 1663 | testTokenize("//\xff", &.{ |
| 1664 | .Invalid, | 1664 | .invalid, |
| 1665 | }); | 1665 | }); |
| 1666 | testTokenize("//\xc2\xc0", &[_]Token.Tag{ | 1666 | testTokenize("//\xc2\xc0", &.{ |
| 1667 | .Invalid, | 1667 | .invalid, |
| 1668 | }); | 1668 | }); |
| 1669 | testTokenize("//\xe0", &[_]Token.Tag{ | 1669 | testTokenize("//\xe0", &.{ |
| 1670 | .Invalid, | 1670 | .invalid, |
| 1671 | }); | 1671 | }); |
| 1672 | testTokenize("//\xf0", &[_]Token.Tag{ | 1672 | testTokenize("//\xf0", &.{ |
| 1673 | .Invalid, | 1673 | .invalid, |
| 1674 | }); | 1674 | }); |
| 1675 | testTokenize("//\xf0\x90\x80\xc0", &[_]Token.Tag{ | 1675 | testTokenize("//\xf0\x90\x80\xc0", &.{ |
| 1676 | .Invalid, | 1676 | .invalid, |
| 1677 | }); | 1677 | }); |
| 1678 | } | 1678 | } |
| 1679 | 1679 | ||
| 1680 | test "tokenizer - illegal unicode codepoints" { | 1680 | test "tokenizer - illegal unicode codepoints" { |
| 1681 | // unicode newline characters.U+0085, U+2028, U+2029 | 1681 | // unicode newline characters.U+0085, U+2028, U+2029 |
| 1682 | testTokenize("//\xc2\x84", &[_]Token.Tag{}); | 1682 | testTokenize("//\xc2\x84", &.{}); |
| 1683 | testTokenize("//\xc2\x85", &[_]Token.Tag{ | 1683 | testTokenize("//\xc2\x85", &.{ |
| 1684 | .Invalid, | 1684 | .invalid, |
| 1685 | }); | 1685 | }); |
| 1686 | testTokenize("//\xc2\x86", &[_]Token.Tag{}); | 1686 | testTokenize("//\xc2\x86", &.{}); |
| 1687 | testTokenize("//\xe2\x80\xa7", &[_]Token.Tag{}); | 1687 | testTokenize("//\xe2\x80\xa7", &.{}); |
| 1688 | testTokenize("//\xe2\x80\xa8", &[_]Token.Tag{ | 1688 | testTokenize("//\xe2\x80\xa8", &.{ |
| 1689 | .Invalid, | 1689 | .invalid, |
| 1690 | }); | 1690 | }); |
| 1691 | testTokenize("//\xe2\x80\xa9", &[_]Token.Tag{ | 1691 | testTokenize("//\xe2\x80\xa9", &.{ |
| 1692 | .Invalid, | 1692 | .invalid, |
| 1693 | }); | 1693 | }); |
| 1694 | testTokenize("//\xe2\x80\xaa", &[_]Token.Tag{}); | 1694 | testTokenize("//\xe2\x80\xaa", &.{}); |
| 1695 | } | 1695 | } |
| 1696 | 1696 | ||
| 1697 | test "tokenizer - string identifier and builtin fns" { | 1697 | test "tokenizer - string identifier and builtin fns" { |
| 1698 | testTokenize( | 1698 | testTokenize( |
| 1699 | \\const @"if" = @import("std"); | 1699 | \\const @"if" = @import("std"); |
| 1700 | , &[_]Token.Tag{ | 1700 | , &.{ |
| 1701 | .Keyword_const, | 1701 | .keyword_const, |
| 1702 | .Identifier, | 1702 | .identifier, |
| 1703 | .Equal, | 1703 | .equal, |
| 1704 | .Builtin, | 1704 | .builtin, |
| 1705 | .LParen, | 1705 | .l_paren, |
| 1706 | .StringLiteral, | 1706 | .string_literal, |
| 1707 | .RParen, | 1707 | .r_paren, |
| 1708 | .Semicolon, | 1708 | .semicolon, |
| 1709 | }); | 1709 | }); |
| 1710 | } | 1710 | } |
| 1711 | 1711 | ||
| 1712 | test "tokenizer - multiline string literal with literal tab" { | 1712 | test "tokenizer - multiline string literal with literal tab" { |
| 1713 | testTokenize( | 1713 | testTokenize( |
| 1714 | \\\\foo	bar | 1714 | \\\\foo	bar |
| 1715 | , &[_]Token.Tag{ | 1715 | , &.{ |
| 1716 | .MultilineStringLiteralLine, | 1716 | .multiline_string_literal_line, |
| 1717 | }); | 1717 | }); |
| 1718 | } | 1718 | } |
| 1719 | 1719 | ||
| ... | @@ -1725,30 +1725,30 @@ test "tokenizer - comments with literal tab" { | ... | @@ -1725,30 +1725,30 @@ test "tokenizer - comments with literal tab" { |
| 1725 | \\//	foo | 1725 | \\//	foo |
| 1726 | \\///	foo | 1726 | \\///	foo |
| 1727 | \\///	/foo | 1727 | \\///	/foo |
| 1728 | , &[_]Token.Tag{ | 1728 | , &.{ |
| 1729 | .ContainerDocComment, | 1729 | .container_doc_comment, |
| 1730 | .DocComment, | 1730 | .doc_comment, |
| 1731 | .DocComment, | 1731 | .doc_comment, |
| 1732 | .DocComment, | 1732 | .doc_comment, |
| 1733 | }); | 1733 | }); |
| 1734 | } | 1734 | } |
| 1735 | 1735 | ||
| 1736 | test "tokenizer - pipe and then invalid" { | 1736 | test "tokenizer - pipe and then invalid" { |
| 1737 | testTokenize("||=", &[_]Token.Tag{ | 1737 | testTokenize("||=", &.{ |
| 1738 | .PipePipe, | 1738 | .pipe_pipe, |
| 1739 | .Equal, | 1739 | .equal, |
| 1740 | }); | 1740 | }); |
| 1741 | } | 1741 | } |
| 1742 | 1742 | ||
| 1743 | test "tokenizer - line comment and doc comment" { | 1743 | test "tokenizer - line comment and doc comment" { |
| 1744 | testTokenize("//", &[_]Token.Tag{}); | 1744 | testTokenize("//", &.{}); |
| 1745 | testTokenize("// a / b", &[_]Token.Tag{}); | 1745 | testTokenize("// a / b", &.{}); |
| 1746 | testTokenize("// /", &[_]Token.Tag{}); | 1746 | testTokenize("// /", &.{}); |
| 1747 | testTokenize("/// a", &[_]Token.Tag{.DocComment}); | 1747 | testTokenize("/// a", &.{.doc_comment}); |
| 1748 | testTokenize("///", &[_]Token.Tag{.DocComment}); | 1748 | testTokenize("///", &.{.doc_comment}); |
| 1749 | testTokenize("////", &[_]Token.Tag{}); | 1749 | testTokenize("////", &.{}); |
| 1750 | testTokenize("//!", &[_]Token.Tag{.ContainerDocComment}); | 1750 | testTokenize("//!", &.{.container_doc_comment}); |
| 1751 | testTokenize("//!!", &[_]Token.Tag{.ContainerDocComment}); | 1751 | testTokenize("//!!", &.{.container_doc_comment}); |
| 1752 | } | 1752 | } |
| 1753 | 1753 | ||
| 1754 | test "tokenizer - line comment followed by identifier" { | 1754 | test "tokenizer - line comment followed by identifier" { |
| ... | @@ -1756,293 +1756,293 @@ test "tokenizer - line comment followed by identifier" { | ... | @@ -1756,293 +1756,293 @@ test "tokenizer - line comment followed by identifier" { |
| 1756 | \\ Unexpected, | 1756 | \\ Unexpected, |
| 1757 | \\ // another | 1757 | \\ // another |
| 1758 | \\ Another, | 1758 | \\ Another, |
| 1759 | , &[_]Token.Tag{ | 1759 | , &.{ |
| 1760 | .Identifier, | 1760 | .identifier, |
| 1761 | .Comma, | 1761 | .comma, |
| 1762 | .Identifier, | 1762 | .identifier, |
| 1763 | .Comma, | 1763 | .comma, |
| 1764 | }); | 1764 | }); |
| 1765 | } | 1765 | } |
| 1766 | 1766 | ||
| 1767 | test "tokenizer - UTF-8 BOM is recognized and skipped" { | 1767 | test "tokenizer - UTF-8 BOM is recognized and skipped" { |
| 1768 | testTokenize("\xEF\xBB\xBFa;\n", &[_]Token.Tag{ | 1768 | testTokenize("\xEF\xBB\xBFa;\n", &.{ |
| 1769 | .Identifier, | 1769 | .identifier, |
| 1770 | .Semicolon, | 1770 | .semicolon, |
| 1771 | }); | 1771 | }); |
| 1772 | } | 1772 | } |
| 1773 | 1773 | ||
| 1774 | test "correctly parse pointer assignment" { | 1774 | test "correctly parse pointer assignment" { |
| 1775 | testTokenize("b.*=3;\n", &[_]Token.Tag{ | 1775 | testTokenize("b.*=3;\n", &.{ |
| 1776 | .Identifier, | 1776 | .identifier, |
| 1777 | .PeriodAsterisk, | 1777 | .period_asterisk, |
| 1778 | .Equal, | 1778 | .equal, |
| 1779 | .IntegerLiteral, | 1779 | .integer_literal, |
| 1780 | .Semicolon, | 1780 | .semicolon, |
| 1781 | }); | 1781 | }); |
| 1782 | } | 1782 | } |
| 1783 | 1783 | ||
| 1784 | test "correctly parse pointer dereference followed by asterisk" { | 1784 | test "correctly parse pointer dereference followed by asterisk" { |
| 1785 | testTokenize("\"b\".* ** 10", &[_]Token.Tag{ | 1785 | testTokenize("\"b\".* ** 10", &.{ |
| 1786 | .StringLiteral, | 1786 | .string_literal, |
| 1787 | .PeriodAsterisk, | 1787 | .period_asterisk, |
| 1788 | .AsteriskAsterisk, | 1788 | .asterisk_asterisk, |
| 1789 | .IntegerLiteral, | 1789 | .integer_literal, |
| 1790 | }); | 1790 | }); |
| 1791 | 1791 | ||
| 1792 | testTokenize("(\"b\".*)** 10", &[_]Token.Tag{ | 1792 | testTokenize("(\"b\".*)** 10", &.{ |
| 1793 | .LParen, | 1793 | .l_paren, |
| 1794 | .StringLiteral, | 1794 | .string_literal, |
| 1795 | .PeriodAsterisk, | 1795 | .period_asterisk, |
| 1796 | .RParen, | 1796 | .r_paren, |
| 1797 | .AsteriskAsterisk, | 1797 | .asterisk_asterisk, |
| 1798 | .IntegerLiteral, | 1798 | .integer_literal, |
| 1799 | }); | 1799 | }); |
| 1800 | 1800 | ||
| 1801 | testTokenize("\"b\".*** 10", &[_]Token.Tag{ | 1801 | testTokenize("\"b\".*** 10", &.{ |
| 1802 | .StringLiteral, | 1802 | .string_literal, |
| 1803 | .Invalid_periodasterisks, | 1803 | .invalid_periodasterisks, |
| 1804 | .AsteriskAsterisk, | 1804 | .asterisk_asterisk, |
| 1805 | .IntegerLiteral, | 1805 | .integer_literal, |
| 1806 | }); | 1806 | }); |
| 1807 | } | 1807 | } |
| 1808 | 1808 | ||
| 1809 | test "tokenizer - range literals" { | 1809 | test "tokenizer - range literals" { |
| 1810 | testTokenize("0...9", &[_]Token.Tag{ .IntegerLiteral, .Ellipsis3, .IntegerLiteral }); | 1810 | testTokenize("0...9", &.{ .integer_literal, .ellipsis3, .integer_literal }); |
| 1811 | testTokenize("'0'...'9'", &[_]Token.Tag{ .CharLiteral, .Ellipsis3, .CharLiteral }); | 1811 | testTokenize("'0'...'9'", &.{ .char_literal, .ellipsis3, .char_literal }); |
| 1812 | testTokenize("0x00...0x09", &[_]Token.Tag{ .IntegerLiteral, .Ellipsis3, .IntegerLiteral }); | 1812 | testTokenize("0x00...0x09", &.{ .integer_literal, .ellipsis3, .integer_literal }); |
| 1813 | testTokenize("0b00...0b11", &[_]Token.Tag{ .IntegerLiteral, .Ellipsis3, .IntegerLiteral }); | 1813 | testTokenize("0b00...0b11", &.{ .integer_literal, .ellipsis3, .integer_literal }); |
| 1814 | testTokenize("0o00...0o11", &[_]Token.Tag{ .IntegerLiteral, .Ellipsis3, .IntegerLiteral }); | 1814 | testTokenize("0o00...0o11", &.{ .integer_literal, .ellipsis3, .integer_literal }); |
| 1815 | } | 1815 | } |
| 1816 | 1816 | ||
| 1817 | test "tokenizer - number literals decimal" { | 1817 | test "tokenizer - number literals decimal" { |
| 1818 | testTokenize("0", &[_]Token.Tag{.IntegerLiteral}); | 1818 | testTokenize("0", &.{.integer_literal}); |
| 1819 | testTokenize("1", &[_]Token.Tag{.IntegerLiteral}); | 1819 | testTokenize("1", &.{.integer_literal}); |
| 1820 | testTokenize("2", &[_]Token.Tag{.IntegerLiteral}); | 1820 | testTokenize("2", &.{.integer_literal}); |
| 1821 | testTokenize("3", &[_]Token.Tag{.IntegerLiteral}); | 1821 | testTokenize("3", &.{.integer_literal}); |
| 1822 | testTokenize("4", &[_]Token.Tag{.IntegerLiteral}); | 1822 | testTokenize("4", &.{.integer_literal}); |
| 1823 | testTokenize("5", &[_]Token.Tag{.IntegerLiteral}); | 1823 | testTokenize("5", &.{.integer_literal}); |
| 1824 | testTokenize("6", &[_]Token.Tag{.IntegerLiteral}); | 1824 | testTokenize("6", &.{.integer_literal}); |
| 1825 | testTokenize("7", &[_]Token.Tag{.IntegerLiteral}); | 1825 | testTokenize("7", &.{.integer_literal}); |
| 1826 | testTokenize("8", &[_]Token.Tag{.IntegerLiteral}); | 1826 | testTokenize("8", &.{.integer_literal}); |
| 1827 | testTokenize("9", &[_]Token.Tag{.IntegerLiteral}); | 1827 | testTokenize("9", &.{.integer_literal}); |
| 1828 | testTokenize("1..", &[_]Token.Tag{ .IntegerLiteral, .Ellipsis2 }); | 1828 | testTokenize("1..", &.{ .integer_literal, .ellipsis2 }); |
| 1829 | testTokenize("0a", &[_]Token.Tag{ .Invalid, .Identifier }); | 1829 | testTokenize("0a", &.{ .invalid, .identifier }); |
| 1830 | testTokenize("9b", &[_]Token.Tag{ .Invalid, .Identifier }); | 1830 | testTokenize("9b", &.{ .invalid, .identifier }); |
| 1831 | testTokenize("1z", &[_]Token.Tag{ .Invalid, .Identifier }); | 1831 | testTokenize("1z", &.{ .invalid, .identifier }); |
| 1832 | testTokenize("1z_1", &[_]Token.Tag{ .Invalid, .Identifier }); | 1832 | testTokenize("1z_1", &.{ .invalid, .identifier }); |
| 1833 | testTokenize("9z3", &[_]Token.Tag{ .Invalid, .Identifier }); | 1833 | testTokenize("9z3", &.{ .invalid, .identifier }); |
| 1834 | 1834 | ||
| 1835 | testTokenize("0_0", &[_]Token.Tag{.IntegerLiteral}); | 1835 | testTokenize("0_0", &.{.integer_literal}); |
| 1836 | testTokenize("0001", &[_]Token.Tag{.IntegerLiteral}); | 1836 | testTokenize("0001", &.{.integer_literal}); |
| 1837 | testTokenize("01234567890", &[_]Token.Tag{.IntegerLiteral}); | 1837 | testTokenize("01234567890", &.{.integer_literal}); |
| 1838 | testTokenize("012_345_6789_0", &[_]Token.Tag{.IntegerLiteral}); | 1838 | testTokenize("012_345_6789_0", &.{.integer_literal}); |
| 1839 | testTokenize("0_1_2_3_4_5_6_7_8_9_0", &[_]Token.Tag{.IntegerLiteral}); | 1839 | testTokenize("0_1_2_3_4_5_6_7_8_9_0", &.{.integer_literal}); |
| 1840 | 1840 | ||
| 1841 | testTokenize("00_", &[_]Token.Tag{.Invalid}); | 1841 | testTokenize("00_", &.{.invalid}); |
| 1842 | testTokenize("0_0_", &[_]Token.Tag{.Invalid}); | 1842 | testTokenize("0_0_", &.{.invalid}); |
| 1843 | testTokenize("0__0", &[_]Token.Tag{ .Invalid, .Identifier }); | 1843 | testTokenize("0__0", &.{ .invalid, .identifier }); |
| 1844 | testTokenize("0_0f", &[_]Token.Tag{ .Invalid, .Identifier }); | 1844 | testTokenize("0_0f", &.{ .invalid, .identifier }); |
| 1845 | testTokenize("0_0_f", &[_]Token.Tag{ .Invalid, .Identifier }); | 1845 | testTokenize("0_0_f", &.{ .invalid, .identifier }); |
| 1846 | testTokenize("0_0_f_00", &[_]Token.Tag{ .Invalid, .Identifier }); | 1846 | testTokenize("0_0_f_00", &.{ .invalid, .identifier }); |
| 1847 | testTokenize("1_,", &[_]Token.Tag{ .Invalid, .Comma }); | 1847 | testTokenize("1_,", &.{ .invalid, .comma }); |
| 1848 | 1848 | ||
| 1849 | testTokenize("1.", &[_]Token.Tag{.FloatLiteral}); | 1849 | testTokenize("1.", &.{.float_literal}); |
| 1850 | testTokenize("0.0", &[_]Token.Tag{.FloatLiteral}); | 1850 | testTokenize("0.0", &.{.float_literal}); |
| 1851 | testTokenize("1.0", &[_]Token.Tag{.FloatLiteral}); | 1851 | testTokenize("1.0", &.{.float_literal}); |
| 1852 | testTokenize("10.0", &[_]Token.Tag{.FloatLiteral}); | 1852 | testTokenize("10.0", &.{.float_literal}); |
| 1853 | testTokenize("0e0", &[_]Token.Tag{.FloatLiteral}); | 1853 | testTokenize("0e0", &.{.float_literal}); |
| 1854 | testTokenize("1e0", &[_]Token.Tag{.FloatLiteral}); | 1854 | testTokenize("1e0", &.{.float_literal}); |
| 1855 | testTokenize("1e100", &[_]Token.Tag{.FloatLiteral}); | 1855 | testTokenize("1e100", &.{.float_literal}); |
| 1856 | testTokenize("1.e100", &[_]Token.Tag{.FloatLiteral}); | 1856 | testTokenize("1.e100", &.{.float_literal}); |
| 1857 | testTokenize("1.0e100", &[_]Token.Tag{.FloatLiteral}); | 1857 | testTokenize("1.0e100", &.{.float_literal}); |
| 1858 | testTokenize("1.0e+100", &[_]Token.Tag{.FloatLiteral}); | 1858 | testTokenize("1.0e+100", &.{.float_literal}); |
| 1859 | testTokenize("1.0e-100", &[_]Token.Tag{.FloatLiteral}); | 1859 | testTokenize("1.0e-100", &.{.float_literal}); |
| 1860 | testTokenize("1_0_0_0.0_0_0_0_0_1e1_0_0_0", &[_]Token.Tag{.FloatLiteral}); | 1860 | testTokenize("1_0_0_0.0_0_0_0_0_1e1_0_0_0", &.{.float_literal}); |
| 1861 | testTokenize("1.+", &[_]Token.Tag{ .FloatLiteral, .Plus }); | 1861 | testTokenize("1.+", &.{ .float_literal, .plus }); |
| 1862 | 1862 | ||
| 1863 | testTokenize("1e", &[_]Token.Tag{.Invalid}); | 1863 | testTokenize("1e", &.{.invalid}); |
| 1864 | testTokenize("1.0e1f0", &[_]Token.Tag{ .Invalid, .Identifier }); | 1864 | testTokenize("1.0e1f0", &.{ .invalid, .identifier }); |
| 1865 | testTokenize("1.0p100", &[_]Token.Tag{ .Invalid, .Identifier }); | 1865 | testTokenize("1.0p100", &.{ .invalid, .identifier }); |
| 1866 | testTokenize("1.0p-100", &[_]Token.Tag{ .Invalid, .Identifier, .Minus, .IntegerLiteral }); | 1866 | testTokenize("1.0p-100", &.{ .invalid, .identifier, .minus, .integer_literal }); |
| 1867 | testTokenize("1.0p1f0", &[_]Token.Tag{ .Invalid, .Identifier }); | 1867 | testTokenize("1.0p1f0", &.{ .invalid, .identifier }); |
| 1868 | testTokenize("1.0_,", &[_]Token.Tag{ .Invalid, .Comma }); | 1868 | testTokenize("1.0_,", &.{ .invalid, .comma }); |
| 1869 | testTokenize("1_.0", &[_]Token.Tag{ .Invalid, .Period, .IntegerLiteral }); | 1869 | testTokenize("1_.0", &.{ .invalid, .period, .integer_literal }); |
| 1870 | testTokenize("1._", &[_]Token.Tag{ .Invalid, .Identifier }); | 1870 | testTokenize("1._", &.{ .invalid, .identifier }); |
| 1871 | testTokenize("1.a", &[_]Token.Tag{ .Invalid, .Identifier }); | 1871 | testTokenize("1.a", &.{ .invalid, .identifier }); |
| 1872 | testTokenize("1.z", &[_]Token.Tag{ .Invalid, .Identifier }); | 1872 | testTokenize("1.z", &.{ .invalid, .identifier }); |
| 1873 | testTokenize("1._0", &[_]Token.Tag{ .Invalid, .Identifier }); | 1873 | testTokenize("1._0", &.{ .invalid, .identifier }); |
| 1874 | testTokenize("1._+", &[_]Token.Tag{ .Invalid, .Identifier, .Plus }); | 1874 | testTokenize("1._+", &.{ .invalid, .identifier, .plus }); |
| 1875 | testTokenize("1._e", &[_]Token.Tag{ .Invalid, .Identifier }); | 1875 | testTokenize("1._e", &.{ .invalid, .identifier }); |
| 1876 | testTokenize("1.0e", &[_]Token.Tag{.Invalid}); | 1876 | testTokenize("1.0e", &.{.invalid}); |
| 1877 | testTokenize("1.0e,", &[_]Token.Tag{ .Invalid, .Comma }); | 1877 | testTokenize("1.0e,", &.{ .invalid, .comma }); |
| 1878 | testTokenize("1.0e_", &[_]Token.Tag{ .Invalid, .Identifier }); | 1878 | testTokenize("1.0e_", &.{ .invalid, .identifier }); |
| 1879 | testTokenize("1.0e+_", &[_]Token.Tag{ .Invalid, .Identifier }); | 1879 | testTokenize("1.0e+_", &.{ .invalid, .identifier }); |
| 1880 | testTokenize("1.0e-_", &[_]Token.Tag{ .Invalid, .Identifier }); | 1880 | testTokenize("1.0e-_", &.{ .invalid, .identifier }); |
| 1881 | testTokenize("1.0e0_+", &[_]Token.Tag{ .Invalid, .Plus }); | 1881 | testTokenize("1.0e0_+", &.{ .invalid, .plus }); |
| 1882 | } | 1882 | } |
| 1883 | 1883 | ||
| 1884 | test "tokenizer - number literals binary" { | 1884 | test "tokenizer - number literals binary" { |
| 1885 | testTokenize("0b0", &[_]Token.Tag{.IntegerLiteral}); | 1885 | testTokenize("0b0", &.{.integer_literal}); |
| 1886 | testTokenize("0b1", &[_]Token.Tag{.IntegerLiteral}); | 1886 | testTokenize("0b1", &.{.integer_literal}); |
| 1887 | testTokenize("0b2", &[_]Token.Tag{ .Invalid, .IntegerLiteral }); | 1887 | testTokenize("0b2", &.{ .invalid, .integer_literal }); |
| 1888 | testTokenize("0b3", &[_]Token.Tag{ .Invalid, .IntegerLiteral }); | 1888 | testTokenize("0b3", &.{ .invalid, .integer_literal }); |
| 1889 | testTokenize("0b4", &[_]Token.Tag{ .Invalid, .IntegerLiteral }); | 1889 | testTokenize("0b4", &.{ .invalid, .integer_literal }); |
| 1890 | testTokenize("0b5", &[_]Token.Tag{ .Invalid, .IntegerLiteral }); | 1890 | testTokenize("0b5", &.{ .invalid, .integer_literal }); |
| 1891 | testTokenize("0b6", &[_]Token.Tag{ .Invalid, .IntegerLiteral }); | 1891 | testTokenize("0b6", &.{ .invalid, .integer_literal }); |
| 1892 | testTokenize("0b7", &[_]Token.Tag{ .Invalid, .IntegerLiteral }); | 1892 | testTokenize("0b7", &.{ .invalid, .integer_literal }); |
| 1893 | testTokenize("0b8", &[_]Token.Tag{ .Invalid, .IntegerLiteral }); | 1893 | testTokenize("0b8", &.{ .invalid, .integer_literal }); |
| 1894 | testTokenize("0b9", &[_]Token.Tag{ .Invalid, .IntegerLiteral }); | 1894 | testTokenize("0b9", &.{ .invalid, .integer_literal }); |
| 1895 | testTokenize("0ba", &[_]Token.Tag{ .Invalid, .Identifier }); | 1895 | testTokenize("0ba", &.{ .invalid, .identifier }); |
| 1896 | testTokenize("0bb", &[_]Token.Tag{ .Invalid, .Identifier }); | 1896 | testTokenize("0bb", &.{ .invalid, .identifier }); |
| 1897 | testTokenize("0bc", &[_]Token.Tag{ .Invalid, .Identifier }); | 1897 | testTokenize("0bc", &.{ .invalid, .identifier }); |
| 1898 | testTokenize("0bd", &[_]Token.Tag{ .Invalid, .Identifier }); | 1898 | testTokenize("0bd", &.{ .invalid, .identifier }); |
| 1899 | testTokenize("0be", &[_]Token.Tag{ .Invalid, .Identifier }); | 1899 | testTokenize("0be", &.{ .invalid, .identifier }); |
| 1900 | testTokenize("0bf", &[_]Token.Tag{ .Invalid, .Identifier }); | 1900 | testTokenize("0bf", &.{ .invalid, .identifier }); |
| 1901 | testTokenize("0bz", &[_]Token.Tag{ .Invalid, .Identifier }); | 1901 | testTokenize("0bz", &.{ .invalid, .identifier }); |
| 1902 | 1902 | ||
| 1903 | testTokenize("0b0000_0000", &[_]Token.Tag{.IntegerLiteral}); | 1903 | testTokenize("0b0000_0000", &.{.integer_literal}); |
| 1904 | testTokenize("0b1111_1111", &[_]Token.Tag{.IntegerLiteral}); | 1904 | testTokenize("0b1111_1111", &.{.integer_literal}); |
| 1905 | testTokenize("0b10_10_10_10", &[_]Token.Tag{.IntegerLiteral}); | 1905 | testTokenize("0b10_10_10_10", &.{.integer_literal}); |
| 1906 | testTokenize("0b0_1_0_1_0_1_0_1", &[_]Token.Tag{.IntegerLiteral}); | 1906 | testTokenize("0b0_1_0_1_0_1_0_1", &.{.integer_literal}); |
| 1907 | testTokenize("0b1.", &[_]Token.Tag{ .IntegerLiteral, .Period }); | 1907 | testTokenize("0b1.", &.{ .integer_literal, .period }); |
| 1908 | testTokenize("0b1.0", &[_]Token.Tag{ .IntegerLiteral, .Period, .IntegerLiteral }); | 1908 | testTokenize("0b1.0", &.{ .integer_literal, .period, .integer_literal }); |
| 1909 | 1909 | ||
| 1910 | testTokenize("0B0", &[_]Token.Tag{ .Invalid, .Identifier }); | 1910 | testTokenize("0B0", &.{ .invalid, .identifier }); |
| 1911 | testTokenize("0b_", &[_]Token.Tag{ .Invalid, .Identifier }); | 1911 | testTokenize("0b_", &.{ .invalid, .identifier }); |
| 1912 | testTokenize("0b_0", &[_]Token.Tag{ .Invalid, .Identifier }); | 1912 | testTokenize("0b_0", &.{ .invalid, .identifier }); |
| 1913 | testTokenize("0b1_", &[_]Token.Tag{.Invalid}); | 1913 | testTokenize("0b1_", &.{.invalid}); |
| 1914 | testTokenize("0b0__1", &[_]Token.Tag{ .Invalid, .Identifier }); | 1914 | testTokenize("0b0__1", &.{ .invalid, .identifier }); |
| 1915 | testTokenize("0b0_1_", &[_]Token.Tag{.Invalid}); | 1915 | testTokenize("0b0_1_", &.{.invalid}); |
| 1916 | testTokenize("0b1e", &[_]Token.Tag{ .Invalid, .Identifier }); | 1916 | testTokenize("0b1e", &.{ .invalid, .identifier }); |
| 1917 | testTokenize("0b1p", &[_]Token.Tag{ .Invalid, .Identifier }); | 1917 | testTokenize("0b1p", &.{ .invalid, .identifier }); |
| 1918 | testTokenize("0b1e0", &[_]Token.Tag{ .Invalid, .Identifier }); | 1918 | testTokenize("0b1e0", &.{ .invalid, .identifier }); |
| 1919 | testTokenize("0b1p0", &[_]Token.Tag{ .Invalid, .Identifier }); | 1919 | testTokenize("0b1p0", &.{ .invalid, .identifier }); |
| 1920 | testTokenize("0b1_,", &[_]Token.Tag{ .Invalid, .Comma }); | 1920 | testTokenize("0b1_,", &.{ .invalid, .comma }); |
| 1921 | } | 1921 | } |
| 1922 | 1922 | ||
| 1923 | test "tokenizer - number literals octal" { | 1923 | test "tokenizer - number literals octal" { |
| 1924 | testTokenize("0o0", &[_]Token.Tag{.IntegerLiteral}); | 1924 | testTokenize("0o0", &.{.integer_literal}); |
| 1925 | testTokenize("0o1", &[_]Token.Tag{.IntegerLiteral}); | 1925 | testTokenize("0o1", &.{.integer_literal}); |
| 1926 | testTokenize("0o2", &[_]Token.Tag{.IntegerLiteral}); | 1926 | testTokenize("0o2", &.{.integer_literal}); |
| 1927 | testTokenize("0o3", &[_]Token.Tag{.IntegerLiteral}); | 1927 | testTokenize("0o3", &.{.integer_literal}); |
| 1928 | testTokenize("0o4", &[_]Token.Tag{.IntegerLiteral}); | 1928 | testTokenize("0o4", &.{.integer_literal}); |
| 1929 | testTokenize("0o5", &[_]Token.Tag{.IntegerLiteral}); | 1929 | testTokenize("0o5", &.{.integer_literal}); |
| 1930 | testTokenize("0o6", &[_]Token.Tag{.IntegerLiteral}); | 1930 | testTokenize("0o6", &.{.integer_literal}); |
| 1931 | testTokenize("0o7", &[_]Token.Tag{.IntegerLiteral}); | 1931 | testTokenize("0o7", &.{.integer_literal}); |
| 1932 | testTokenize("0o8", &[_]Token.Tag{ .Invalid, .IntegerLiteral }); | 1932 | testTokenize("0o8", &.{ .invalid, .integer_literal }); |
| 1933 | testTokenize("0o9", &[_]Token.Tag{ .Invalid, .IntegerLiteral }); | 1933 | testTokenize("0o9", &.{ .invalid, .integer_literal }); |
| 1934 | testTokenize("0oa", &[_]Token.Tag{ .Invalid, .Identifier }); | 1934 | testTokenize("0oa", &.{ .invalid, .identifier }); |
| 1935 | testTokenize("0ob", &[_]Token.Tag{ .Invalid, .Identifier }); | 1935 | testTokenize("0ob", &.{ .invalid, .identifier }); |
| 1936 | testTokenize("0oc", &[_]Token.Tag{ .Invalid, .Identifier }); | 1936 | testTokenize("0oc", &.{ .invalid, .identifier }); |
| 1937 | testTokenize("0od", &[_]Token.Tag{ .Invalid, .Identifier }); | 1937 | testTokenize("0od", &.{ .invalid, .identifier }); |
| 1938 | testTokenize("0oe", &[_]Token.Tag{ .Invalid, .Identifier }); | 1938 | testTokenize("0oe", &.{ .invalid, .identifier }); |
| 1939 | testTokenize("0of", &[_]Token.Tag{ .Invalid, .Identifier }); | 1939 | testTokenize("0of", &.{ .invalid, .identifier }); |
| 1940 | testTokenize("0oz", &[_]Token.Tag{ .Invalid, .Identifier }); | 1940 | testTokenize("0oz", &.{ .invalid, .identifier }); |
| 1941 | 1941 | ||
| 1942 | testTokenize("0o01234567", &[_]Token.Tag{.IntegerLiteral}); | 1942 | testTokenize("0o01234567", &.{.integer_literal}); |
| 1943 | testTokenize("0o0123_4567", &[_]Token.Tag{.IntegerLiteral}); | 1943 | testTokenize("0o0123_4567", &.{.integer_literal}); |
| 1944 | testTokenize("0o01_23_45_67", &[_]Token.Tag{.IntegerLiteral}); | 1944 | testTokenize("0o01_23_45_67", &.{.integer_literal}); |
| 1945 | testTokenize("0o0_1_2_3_4_5_6_7", &[_]Token.Tag{.IntegerLiteral}); | 1945 | testTokenize("0o0_1_2_3_4_5_6_7", &.{.integer_literal}); |
| 1946 | testTokenize("0o7.", &[_]Token.Tag{ .IntegerLiteral, .Period }); | 1946 | testTokenize("0o7.", &.{ .integer_literal, .period }); |
| 1947 | testTokenize("0o7.0", &[_]Token.Tag{ .IntegerLiteral, .Period, .IntegerLiteral }); | 1947 | testTokenize("0o7.0", &.{ .integer_literal, .period, .integer_literal }); |
| 1948 | 1948 | ||
| 1949 | testTokenize("0O0", &[_]Token.Tag{ .Invalid, .Identifier }); | 1949 | testTokenize("0O0", &.{ .invalid, .identifier }); |
| 1950 | testTokenize("0o_", &[_]Token.Tag{ .Invalid, .Identifier }); | 1950 | testTokenize("0o_", &.{ .invalid, .identifier }); |
| 1951 | testTokenize("0o_0", &[_]Token.Tag{ .Invalid, .Identifier }); | 1951 | testTokenize("0o_0", &.{ .invalid, .identifier }); |
| 1952 | testTokenize("0o1_", &[_]Token.Tag{.Invalid}); | 1952 | testTokenize("0o1_", &.{.invalid}); |
| 1953 | testTokenize("0o0__1", &[_]Token.Tag{ .Invalid, .Identifier }); | 1953 | testTokenize("0o0__1", &.{ .invalid, .identifier }); |
| 1954 | testTokenize("0o0_1_", &[_]Token.Tag{.Invalid}); | 1954 | testTokenize("0o0_1_", &.{.invalid}); |
| 1955 | testTokenize("0o1e", &[_]Token.Tag{ .Invalid, .Identifier }); | 1955 | testTokenize("0o1e", &.{ .invalid, .identifier }); |
| 1956 | testTokenize("0o1p", &[_]Token.Tag{ .Invalid, .Identifier }); | 1956 | testTokenize("0o1p", &.{ .invalid, .identifier }); |
| 1957 | testTokenize("0o1e0", &[_]Token.Tag{ .Invalid, .Identifier }); | 1957 | testTokenize("0o1e0", &.{ .invalid, .identifier }); |
| 1958 | testTokenize("0o1p0", &[_]Token.Tag{ .Invalid, .Identifier }); | 1958 | testTokenize("0o1p0", &.{ .invalid, .identifier }); |
| 1959 | testTokenize("0o_,", &[_]Token.Tag{ .Invalid, .Identifier, .Comma }); | 1959 | testTokenize("0o_,", &.{ .invalid, .identifier, .comma }); |
| 1960 | } | 1960 | } |
| 1961 | 1961 | ||
| 1962 | test "tokenizer - number literals hexadeciaml" { | 1962 | test "tokenizer - number literals hexadeciaml" { |
| 1963 | testTokenize("0x0", &[_]Token.Tag{.IntegerLiteral}); | 1963 | testTokenize("0x0", &.{.integer_literal}); |
| 1964 | testTokenize("0x1", &[_]Token.Tag{.IntegerLiteral}); | 1964 | testTokenize("0x1", &.{.integer_literal}); |
| 1965 | testTokenize("0x2", &[_]Token.Tag{.IntegerLiteral}); | 1965 | testTokenize("0x2", &.{.integer_literal}); |
| 1966 | testTokenize("0x3", &[_]Token.Tag{.IntegerLiteral}); | 1966 | testTokenize("0x3", &.{.integer_literal}); |
| 1967 | testTokenize("0x4", &[_]Token.Tag{.IntegerLiteral}); | 1967 | testTokenize("0x4", &.{.integer_literal}); |
| 1968 | testTokenize("0x5", &[_]Token.Tag{.IntegerLiteral}); | 1968 | testTokenize("0x5", &.{.integer_literal}); |
| 1969 | testTokenize("0x6", &[_]Token.Tag{.IntegerLiteral}); | 1969 | testTokenize("0x6", &.{.integer_literal}); |
| 1970 | testTokenize("0x7", &[_]Token.Tag{.IntegerLiteral}); | 1970 | testTokenize("0x7", &.{.integer_literal}); |
| 1971 | testTokenize("0x8", &[_]Token.Tag{.IntegerLiteral}); | 1971 | testTokenize("0x8", &.{.integer_literal}); |
| 1972 | testTokenize("0x9", &[_]Token.Tag{.IntegerLiteral}); | 1972 | testTokenize("0x9", &.{.integer_literal}); |
| 1973 | testTokenize("0xa", &[_]Token.Tag{.IntegerLiteral}); | 1973 | testTokenize("0xa", &.{.integer_literal}); |
| 1974 | testTokenize("0xb", &[_]Token.Tag{.IntegerLiteral}); | 1974 | testTokenize("0xb", &.{.integer_literal}); |
| 1975 | testTokenize("0xc", &[_]Token.Tag{.IntegerLiteral}); | 1975 | testTokenize("0xc", &.{.integer_literal}); |
| 1976 | testTokenize("0xd", &[_]Token.Tag{.IntegerLiteral}); | 1976 | testTokenize("0xd", &.{.integer_literal}); |
| 1977 | testTokenize("0xe", &[_]Token.Tag{.IntegerLiteral}); | 1977 | testTokenize("0xe", &.{.integer_literal}); |
| 1978 | testTokenize("0xf", &[_]Token.Tag{.IntegerLiteral}); | 1978 | testTokenize("0xf", &.{.integer_literal}); |
| 1979 | testTokenize("0xA", &[_]Token.Tag{.IntegerLiteral}); | 1979 | testTokenize("0xA", &.{.integer_literal}); |
| 1980 | testTokenize("0xB", &[_]Token.Tag{.IntegerLiteral}); | 1980 | testTokenize("0xB", &.{.integer_literal}); |
| 1981 | testTokenize("0xC", &[_]Token.Tag{.IntegerLiteral}); | 1981 | testTokenize("0xC", &.{.integer_literal}); |
| 1982 | testTokenize("0xD", &[_]Token.Tag{.IntegerLiteral}); | 1982 | testTokenize("0xD", &.{.integer_literal}); |
| 1983 | testTokenize("0xE", &[_]Token.Tag{.IntegerLiteral}); | 1983 | testTokenize("0xE", &.{.integer_literal}); |
| 1984 | testTokenize("0xF", &[_]Token.Tag{.IntegerLiteral}); | 1984 | testTokenize("0xF", &.{.integer_literal}); |
| 1985 | testTokenize("0x0z", &[_]Token.Tag{ .Invalid, .Identifier }); | 1985 | testTokenize("0x0z", &.{ .invalid, .identifier }); |
| 1986 | testTokenize("0xz", &[_]Token.Tag{ .Invalid, .Identifier }); | 1986 | testTokenize("0xz", &.{ .invalid, .identifier }); |
| 1987 | 1987 | ||
| 1988 | testTokenize("0x0123456789ABCDEF", &[_]Token.Tag{.IntegerLiteral}); | 1988 | testTokenize("0x0123456789ABCDEF", &.{.integer_literal}); |
| 1989 | testTokenize("0x0123_4567_89AB_CDEF", &[_]Token.Tag{.IntegerLiteral}); | 1989 | testTokenize("0x0123_4567_89AB_CDEF", &.{.integer_literal}); |
| 1990 | testTokenize("0x01_23_45_67_89AB_CDE_F", &[_]Token.Tag{.IntegerLiteral}); | 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", &[_]Token.Tag{.IntegerLiteral}); | 1991 | testTokenize("0x0_1_2_3_4_5_6_7_8_9_A_B_C_D_E_F", &.{.integer_literal}); |
| 1992 | 1992 | ||
| 1993 | testTokenize("0X0", &[_]Token.Tag{ .Invalid, .Identifier }); | 1993 | testTokenize("0X0", &.{ .invalid, .identifier }); |
| 1994 | testTokenize("0x_", &[_]Token.Tag{ .Invalid, .Identifier }); | 1994 | testTokenize("0x_", &.{ .invalid, .identifier }); |
| 1995 | testTokenize("0x_1", &[_]Token.Tag{ .Invalid, .Identifier }); | 1995 | testTokenize("0x_1", &.{ .invalid, .identifier }); |
| 1996 | testTokenize("0x1_", &[_]Token.Tag{.Invalid}); | 1996 | testTokenize("0x1_", &.{.invalid}); |
| 1997 | testTokenize("0x0__1", &[_]Token.Tag{ .Invalid, .Identifier }); | 1997 | testTokenize("0x0__1", &.{ .invalid, .identifier }); |
| 1998 | testTokenize("0x0_1_", &[_]Token.Tag{.Invalid}); | 1998 | testTokenize("0x0_1_", &.{.invalid}); |
| 1999 | testTokenize("0x_,", &[_]Token.Tag{ .Invalid, .Identifier, .Comma }); | 1999 | testTokenize("0x_,", &.{ .invalid, .identifier, .comma }); |
| 2000 | 2000 | ||
| 2001 | testTokenize("0x1.", &[_]Token.Tag{.FloatLiteral}); | 2001 | testTokenize("0x1.", &.{.float_literal}); |
| 2002 | testTokenize("0x1.0", &[_]Token.Tag{.FloatLiteral}); | 2002 | testTokenize("0x1.0", &.{.float_literal}); |
| 2003 | testTokenize("0xF.", &[_]Token.Tag{.FloatLiteral}); | 2003 | testTokenize("0xF.", &.{.float_literal}); |
| 2004 | testTokenize("0xF.0", &[_]Token.Tag{.FloatLiteral}); | 2004 | testTokenize("0xF.0", &.{.float_literal}); |
| 2005 | testTokenize("0xF.F", &[_]Token.Tag{.FloatLiteral}); | 2005 | testTokenize("0xF.F", &.{.float_literal}); |
| 2006 | testTokenize("0xF.Fp0", &[_]Token.Tag{.FloatLiteral}); | 2006 | testTokenize("0xF.Fp0", &.{.float_literal}); |
| 2007 | testTokenize("0xF.FP0", &[_]Token.Tag{.FloatLiteral}); | 2007 | testTokenize("0xF.FP0", &.{.float_literal}); |
| 2008 | testTokenize("0x1p0", &[_]Token.Tag{.FloatLiteral}); | 2008 | testTokenize("0x1p0", &.{.float_literal}); |
| 2009 | testTokenize("0xfp0", &[_]Token.Tag{.FloatLiteral}); | 2009 | testTokenize("0xfp0", &.{.float_literal}); |
| 2010 | testTokenize("0x1.+0xF.", &[_]Token.Tag{ .FloatLiteral, .Plus, .FloatLiteral }); | 2010 | testTokenize("0x1.+0xF.", &.{ .float_literal, .plus, .float_literal }); |
| 2011 | 2011 | ||
| 2012 | testTokenize("0x0123456.789ABCDEF", &[_]Token.Tag{.FloatLiteral}); | 2012 | testTokenize("0x0123456.789ABCDEF", &.{.float_literal}); |
| 2013 | testTokenize("0x0_123_456.789_ABC_DEF", &[_]Token.Tag{.FloatLiteral}); | 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", &[_]Token.Tag{.FloatLiteral}); | 2014 | testTokenize("0x0_1_2_3_4_5_6.7_8_9_A_B_C_D_E_F", &.{.float_literal}); |
| 2015 | testTokenize("0x0p0", &[_]Token.Tag{.FloatLiteral}); | 2015 | testTokenize("0x0p0", &.{.float_literal}); |
| 2016 | testTokenize("0x0.0p0", &[_]Token.Tag{.FloatLiteral}); | 2016 | testTokenize("0x0.0p0", &.{.float_literal}); |
| 2017 | testTokenize("0xff.ffp10", &[_]Token.Tag{.FloatLiteral}); | 2017 | testTokenize("0xff.ffp10", &.{.float_literal}); |
| 2018 | testTokenize("0xff.ffP10", &[_]Token.Tag{.FloatLiteral}); | 2018 | testTokenize("0xff.ffP10", &.{.float_literal}); |
| 2019 | testTokenize("0xff.p10", &[_]Token.Tag{.FloatLiteral}); | 2019 | testTokenize("0xff.p10", &.{.float_literal}); |
| 2020 | testTokenize("0xffp10", &[_]Token.Tag{.FloatLiteral}); | 2020 | testTokenize("0xffp10", &.{.float_literal}); |
| 2021 | testTokenize("0xff_ff.ff_ffp1_0_0_0", &[_]Token.Tag{.FloatLiteral}); | 2021 | testTokenize("0xff_ff.ff_ffp1_0_0_0", &.{.float_literal}); |
| 2022 | testTokenize("0xf_f_f_f.f_f_f_fp+1_000", &[_]Token.Tag{.FloatLiteral}); | 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", &[_]Token.Tag{.FloatLiteral}); | 2023 | testTokenize("0xf_f_f_f.f_f_f_fp-1_00_0", &.{.float_literal}); |
| 2024 | 2024 | ||
| 2025 | testTokenize("0x1e", &[_]Token.Tag{.IntegerLiteral}); | 2025 | testTokenize("0x1e", &.{.integer_literal}); |
| 2026 | testTokenize("0x1e0", &[_]Token.Tag{.IntegerLiteral}); | 2026 | testTokenize("0x1e0", &.{.integer_literal}); |
| 2027 | testTokenize("0x1p", &[_]Token.Tag{.Invalid}); | 2027 | testTokenize("0x1p", &.{.invalid}); |
| 2028 | testTokenize("0xfp0z1", &[_]Token.Tag{ .Invalid, .Identifier }); | 2028 | testTokenize("0xfp0z1", &.{ .invalid, .identifier }); |
| 2029 | testTokenize("0xff.ffpff", &[_]Token.Tag{ .Invalid, .Identifier }); | 2029 | testTokenize("0xff.ffpff", &.{ .invalid, .identifier }); |
| 2030 | testTokenize("0x0.p", &[_]Token.Tag{.Invalid}); | 2030 | testTokenize("0x0.p", &.{.invalid}); |
| 2031 | testTokenize("0x0.z", &[_]Token.Tag{ .Invalid, .Identifier }); | 2031 | testTokenize("0x0.z", &.{ .invalid, .identifier }); |
| 2032 | testTokenize("0x0._", &[_]Token.Tag{ .Invalid, .Identifier }); | 2032 | testTokenize("0x0._", &.{ .invalid, .identifier }); |
| 2033 | testTokenize("0x0_.0", &[_]Token.Tag{ .Invalid, .Period, .IntegerLiteral }); | 2033 | testTokenize("0x0_.0", &.{ .invalid, .period, .integer_literal }); |
| 2034 | testTokenize("0x0_.0.0", &[_]Token.Tag{ .Invalid, .Period, .FloatLiteral }); | 2034 | testTokenize("0x0_.0.0", &.{ .invalid, .period, .float_literal }); |
| 2035 | testTokenize("0x0._0", &[_]Token.Tag{ .Invalid, .Identifier }); | 2035 | testTokenize("0x0._0", &.{ .invalid, .identifier }); |
| 2036 | testTokenize("0x0.0_", &[_]Token.Tag{.Invalid}); | 2036 | testTokenize("0x0.0_", &.{.invalid}); |
| 2037 | testTokenize("0x0_p0", &[_]Token.Tag{ .Invalid, .Identifier }); | 2037 | testTokenize("0x0_p0", &.{ .invalid, .identifier }); |
| 2038 | testTokenize("0x0_.p0", &[_]Token.Tag{ .Invalid, .Period, .Identifier }); | 2038 | testTokenize("0x0_.p0", &.{ .invalid, .period, .identifier }); |
| 2039 | testTokenize("0x0._p0", &[_]Token.Tag{ .Invalid, .Identifier }); | 2039 | testTokenize("0x0._p0", &.{ .invalid, .identifier }); |
| 2040 | testTokenize("0x0.0_p0", &[_]Token.Tag{ .Invalid, .Identifier }); | 2040 | testTokenize("0x0.0_p0", &.{ .invalid, .identifier }); |
| 2041 | testTokenize("0x0._0p0", &[_]Token.Tag{ .Invalid, .Identifier }); | 2041 | testTokenize("0x0._0p0", &.{ .invalid, .identifier }); |
| 2042 | testTokenize("0x0.0p_0", &[_]Token.Tag{ .Invalid, .Identifier }); | 2042 | testTokenize("0x0.0p_0", &.{ .invalid, .identifier }); |
| 2043 | testTokenize("0x0.0p+_0", &[_]Token.Tag{ .Invalid, .Identifier }); | 2043 | testTokenize("0x0.0p+_0", &.{ .invalid, .identifier }); |
| 2044 | testTokenize("0x0.0p-_0", &[_]Token.Tag{ .Invalid, .Identifier }); | 2044 | testTokenize("0x0.0p-_0", &.{ .invalid, .identifier }); |
| 2045 | testTokenize("0x0.0p0_", &[_]Token.Tag{ .Invalid, .Eof }); | 2045 | testTokenize("0x0.0p0_", &.{ .invalid, .eof }); |
| 2046 | } | 2046 | } |
| 2047 | 2047 | ||
| 2048 | fn testTokenize(source: []const u8, expected_tokens: []const Token.Tag) void { | 2048 | fn 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 { | ... | @@ -2054,5 +2054,5 @@ fn testTokenize(source: []const u8, expected_tokens: []const Token.Tag) void { |
| 2054 | } | 2054 | } |
| 2055 | } | 2055 | } |
| 2056 | const last_token = tokenizer.next(); | 2056 | const last_token = tokenizer.next(); |
| 2057 | std.testing.expect(last_token.tag == .Eof); | 2057 | std.testing.expect(last_token.tag == .eof); |
| 2058 | } | 2058 | } |