| ... | ... | @@ -43,7 +43,6 @@ pub const Token = struct { |
| 43 | 43 | .{ "if", .Keyword_if }, |
| 44 | 44 | .{ "inline", .Keyword_inline }, |
| 45 | 45 | .{ "noalias", .Keyword_noalias }, |
| 46 | | .{ "noasync", .Keyword_nosuspend }, // TODO: remove this |
| 47 | 46 | .{ "noinline", .Keyword_noinline }, |
| 48 | 47 | .{ "nosuspend", .Keyword_nosuspend }, |
| 49 | 48 | .{ "null", .Keyword_null }, |
| ... | ... | @@ -141,10 +140,8 @@ pub const Token = struct { |
| 141 | 140 | Tilde, |
| 142 | 141 | IntegerLiteral, |
| 143 | 142 | FloatLiteral, |
| 144 | | LineComment, |
| 145 | 143 | DocComment, |
| 146 | 144 | ContainerDocComment, |
| 147 | | ShebangLine, |
| 148 | 145 | Keyword_align, |
| 149 | 146 | Keyword_allowzero, |
| 150 | 147 | Keyword_and, |
| ... | ... | @@ -211,10 +208,8 @@ pub const Token = struct { |
| 211 | 208 | .Builtin => "Builtin", |
| 212 | 209 | .IntegerLiteral => "IntegerLiteral", |
| 213 | 210 | .FloatLiteral => "FloatLiteral", |
| 214 | | .LineComment => "LineComment", |
| 215 | 211 | .DocComment => "DocComment", |
| 216 | 212 | .ContainerDocComment => "ContainerDocComment", |
| 217 | | .ShebangLine => "ShebangLine", |
| 218 | 213 | |
| 219 | 214 | .Bang => "!", |
| 220 | 215 | .Pipe => "|", |
| ... | ... | @@ -1016,7 +1011,6 @@ pub const Tokenizer = struct { |
| 1016 | 1011 | .slash => switch (c) { |
| 1017 | 1012 | '/' => { |
| 1018 | 1013 | state = .line_comment_start; |
| 1019 | | result.tag = .LineComment; |
| 1020 | 1014 | }, |
| 1021 | 1015 | '=' => { |
| 1022 | 1016 | result.tag = .SlashEqual; |
| ... | ... | @@ -1036,7 +1030,7 @@ pub const Tokenizer = struct { |
| 1036 | 1030 | result.tag = .ContainerDocComment; |
| 1037 | 1031 | state = .container_doc_comment; |
| 1038 | 1032 | }, |
| 1039 | | '\n' => break, |
| 1033 | '\n' => state = .start, |
| 1040 | 1034 | '\t', '\r' => state = .line_comment, |
| 1041 | 1035 | else => { |
| 1042 | 1036 | state = .line_comment; |
| ... | ... | @@ -1061,7 +1055,12 @@ pub const Tokenizer = struct { |
| 1061 | 1055 | self.checkLiteralCharacter(); |
| 1062 | 1056 | }, |
| 1063 | 1057 | }, |
| 1064 | | .line_comment, .doc_comment, .container_doc_comment => switch (c) { |
| 1058 | .line_comment => switch (c) { |
| 1059 | '\n' => state = .start, |
| 1060 | '\t', '\r' => {}, |
| 1061 | else => self.checkLiteralCharacter(), |
| 1062 | }, |
| 1063 | .doc_comment, .container_doc_comment => switch (c) { |
| 1065 | 1064 | '\n' => break, |
| 1066 | 1065 | '\t', '\r' => {}, |
| 1067 | 1066 | else => self.checkLiteralCharacter(), |
| ... | ... | @@ -1324,6 +1323,8 @@ pub const Tokenizer = struct { |
| 1324 | 1323 | .string_literal, // find this error later |
| 1325 | 1324 | .multiline_string_literal_line, |
| 1326 | 1325 | .builtin, |
| 1326 | .line_comment, |
| 1327 | .line_comment_start, |
| 1327 | 1328 | => {}, |
| 1328 | 1329 | |
| 1329 | 1330 | .identifier => { |
| ... | ... | @@ -1331,9 +1332,6 @@ pub const Tokenizer = struct { |
| 1331 | 1332 | result.tag = tag; |
| 1332 | 1333 | } |
| 1333 | 1334 | }, |
| 1334 | | .line_comment, .line_comment_start => { |
| 1335 | | result.tag = .LineComment; |
| 1336 | | }, |
| 1337 | 1335 | .doc_comment, .doc_comment_start => { |
| 1338 | 1336 | result.tag = .DocComment; |
| 1339 | 1337 | }, |
| ... | ... | @@ -1614,77 +1612,63 @@ test "tokenizer - invalid literal/comment characters" { |
| 1614 | 1612 | .Invalid, |
| 1615 | 1613 | }); |
| 1616 | 1614 | testTokenize("//\x00", &[_]Token.Tag{ |
| 1617 | | .LineComment, |
| 1618 | 1615 | .Invalid, |
| 1619 | 1616 | }); |
| 1620 | 1617 | testTokenize("//\x1f", &[_]Token.Tag{ |
| 1621 | | .LineComment, |
| 1622 | 1618 | .Invalid, |
| 1623 | 1619 | }); |
| 1624 | 1620 | testTokenize("//\x7f", &[_]Token.Tag{ |
| 1625 | | .LineComment, |
| 1626 | 1621 | .Invalid, |
| 1627 | 1622 | }); |
| 1628 | 1623 | } |
| 1629 | 1624 | |
| 1630 | 1625 | test "tokenizer - utf8" { |
| 1631 | | testTokenize("//\xc2\x80", &[_]Token.Tag{.LineComment}); |
| 1632 | | testTokenize("//\xf4\x8f\xbf\xbf", &[_]Token.Tag{.LineComment}); |
| 1626 | testTokenize("//\xc2\x80", &[_]Token.Tag{}); |
| 1627 | testTokenize("//\xf4\x8f\xbf\xbf", &[_]Token.Tag{}); |
| 1633 | 1628 | } |
| 1634 | 1629 | |
| 1635 | 1630 | test "tokenizer - invalid utf8" { |
| 1636 | 1631 | testTokenize("//\x80", &[_]Token.Tag{ |
| 1637 | | .LineComment, |
| 1638 | 1632 | .Invalid, |
| 1639 | 1633 | }); |
| 1640 | 1634 | testTokenize("//\xbf", &[_]Token.Tag{ |
| 1641 | | .LineComment, |
| 1642 | 1635 | .Invalid, |
| 1643 | 1636 | }); |
| 1644 | 1637 | testTokenize("//\xf8", &[_]Token.Tag{ |
| 1645 | | .LineComment, |
| 1646 | 1638 | .Invalid, |
| 1647 | 1639 | }); |
| 1648 | 1640 | testTokenize("//\xff", &[_]Token.Tag{ |
| 1649 | | .LineComment, |
| 1650 | 1641 | .Invalid, |
| 1651 | 1642 | }); |
| 1652 | 1643 | testTokenize("//\xc2\xc0", &[_]Token.Tag{ |
| 1653 | | .LineComment, |
| 1654 | 1644 | .Invalid, |
| 1655 | 1645 | }); |
| 1656 | 1646 | testTokenize("//\xe0", &[_]Token.Tag{ |
| 1657 | | .LineComment, |
| 1658 | 1647 | .Invalid, |
| 1659 | 1648 | }); |
| 1660 | 1649 | testTokenize("//\xf0", &[_]Token.Tag{ |
| 1661 | | .LineComment, |
| 1662 | 1650 | .Invalid, |
| 1663 | 1651 | }); |
| 1664 | 1652 | testTokenize("//\xf0\x90\x80\xc0", &[_]Token.Tag{ |
| 1665 | | .LineComment, |
| 1666 | 1653 | .Invalid, |
| 1667 | 1654 | }); |
| 1668 | 1655 | } |
| 1669 | 1656 | |
| 1670 | 1657 | test "tokenizer - illegal unicode codepoints" { |
| 1671 | 1658 | // unicode newline characters.U+0085, U+2028, U+2029 |
| 1672 | | testTokenize("//\xc2\x84", &[_]Token.Tag{.LineComment}); |
| 1659 | testTokenize("//\xc2\x84", &[_]Token.Tag{}); |
| 1673 | 1660 | testTokenize("//\xc2\x85", &[_]Token.Tag{ |
| 1674 | | .LineComment, |
| 1675 | 1661 | .Invalid, |
| 1676 | 1662 | }); |
| 1677 | | testTokenize("//\xc2\x86", &[_]Token.Tag{.LineComment}); |
| 1678 | | testTokenize("//\xe2\x80\xa7", &[_]Token.Tag{.LineComment}); |
| 1663 | testTokenize("//\xc2\x86", &[_]Token.Tag{}); |
| 1664 | testTokenize("//\xe2\x80\xa7", &[_]Token.Tag{}); |
| 1679 | 1665 | testTokenize("//\xe2\x80\xa8", &[_]Token.Tag{ |
| 1680 | | .LineComment, |
| 1681 | 1666 | .Invalid, |
| 1682 | 1667 | }); |
| 1683 | 1668 | testTokenize("//\xe2\x80\xa9", &[_]Token.Tag{ |
| 1684 | | .LineComment, |
| 1685 | 1669 | .Invalid, |
| 1686 | 1670 | }); |
| 1687 | | testTokenize("//\xe2\x80\xaa", &[_]Token.Tag{.LineComment}); |
| 1671 | testTokenize("//\xe2\x80\xaa", &[_]Token.Tag{}); |
| 1688 | 1672 | } |
| 1689 | 1673 | |
| 1690 | 1674 | test "tokenizer - string identifier and builtin fns" { |
| ... | ... | @@ -1719,10 +1703,8 @@ test "tokenizer - comments with literal tab" { |
| 1719 | 1703 | \\///	foo |
| 1720 | 1704 | \\///	/foo |
| 1721 | 1705 | , &[_]Token.Tag{ |
| 1722 | | .LineComment, |
| 1723 | 1706 | .ContainerDocComment, |
| 1724 | 1707 | .DocComment, |
| 1725 | | .LineComment, |
| 1726 | 1708 | .DocComment, |
| 1727 | 1709 | .DocComment, |
| 1728 | 1710 | }); |
| ... | ... | @@ -1736,12 +1718,12 @@ test "tokenizer - pipe and then invalid" { |
| 1736 | 1718 | } |
| 1737 | 1719 | |
| 1738 | 1720 | test "tokenizer - line comment and doc comment" { |
| 1739 | | testTokenize("//", &[_]Token.Tag{.LineComment}); |
| 1740 | | testTokenize("// a / b", &[_]Token.Tag{.LineComment}); |
| 1741 | | testTokenize("// /", &[_]Token.Tag{.LineComment}); |
| 1721 | testTokenize("//", &[_]Token.Tag{}); |
| 1722 | testTokenize("// a / b", &[_]Token.Tag{}); |
| 1723 | testTokenize("// /", &[_]Token.Tag{}); |
| 1742 | 1724 | testTokenize("/// a", &[_]Token.Tag{.DocComment}); |
| 1743 | 1725 | testTokenize("///", &[_]Token.Tag{.DocComment}); |
| 1744 | | testTokenize("////", &[_]Token.Tag{.LineComment}); |
| 1726 | testTokenize("////", &[_]Token.Tag{}); |
| 1745 | 1727 | testTokenize("//!", &[_]Token.Tag{.ContainerDocComment}); |
| 1746 | 1728 | testTokenize("//!!", &[_]Token.Tag{.ContainerDocComment}); |
| 1747 | 1729 | } |
| ... | ... | @@ -1754,7 +1736,6 @@ test "tokenizer - line comment followed by identifier" { |
| 1754 | 1736 | , &[_]Token.Tag{ |
| 1755 | 1737 | .Identifier, |
| 1756 | 1738 | .Comma, |
| 1757 | | .LineComment, |
| 1758 | 1739 | .Identifier, |
| 1759 | 1740 | .Comma, |
| 1760 | 1741 | }); |