| ... | ... | @@ -11,57 +11,57 @@ pub const Token = struct { |
| 11 | 11 | }; |
| 12 | 12 | |
| 13 | 13 | pub const keywords = std.ComptimeStringMap(Id, .{ |
| 14 | | .{"align", .Keyword_align}, |
| 15 | | .{"allowzero", .Keyword_allowzero}, |
| 16 | | .{"and", .Keyword_and}, |
| 17 | | .{"anyframe", .Keyword_anyframe}, |
| 18 | | .{"asm", .Keyword_asm}, |
| 19 | | .{"async", .Keyword_async}, |
| 20 | | .{"await", .Keyword_await}, |
| 21 | | .{"break", .Keyword_break}, |
| 22 | | .{"callconv", .Keyword_callconv}, |
| 23 | | .{"catch", .Keyword_catch}, |
| 24 | | .{"comptime", .Keyword_comptime}, |
| 25 | | .{"const", .Keyword_const}, |
| 26 | | .{"continue", .Keyword_continue}, |
| 27 | | .{"defer", .Keyword_defer}, |
| 28 | | .{"else", .Keyword_else}, |
| 29 | | .{"enum", .Keyword_enum}, |
| 30 | | .{"errdefer", .Keyword_errdefer}, |
| 31 | | .{"error", .Keyword_error}, |
| 32 | | .{"export", .Keyword_export}, |
| 33 | | .{"extern", .Keyword_extern}, |
| 34 | | .{"false", .Keyword_false}, |
| 35 | | .{"fn", .Keyword_fn}, |
| 36 | | .{"for", .Keyword_for}, |
| 37 | | .{"if", .Keyword_if}, |
| 38 | | .{"inline", .Keyword_inline}, |
| 39 | | .{"noalias", .Keyword_noalias}, |
| 40 | | .{"noasync", .Keyword_nosuspend}, // TODO: remove this |
| 41 | | .{"noinline", .Keyword_noinline}, |
| 42 | | .{"nosuspend", .Keyword_nosuspend}, |
| 43 | | .{"null", .Keyword_null}, |
| 44 | | .{"or", .Keyword_or}, |
| 45 | | .{"orelse", .Keyword_orelse}, |
| 46 | | .{"packed", .Keyword_packed}, |
| 47 | | .{"pub", .Keyword_pub}, |
| 48 | | .{"resume", .Keyword_resume}, |
| 49 | | .{"return", .Keyword_return}, |
| 50 | | .{"linksection", .Keyword_linksection}, |
| 51 | | .{"struct", .Keyword_struct}, |
| 52 | | .{"suspend", .Keyword_suspend}, |
| 53 | | .{"switch", .Keyword_switch}, |
| 54 | | .{"test", .Keyword_test}, |
| 55 | | .{"threadlocal", .Keyword_threadlocal}, |
| 56 | | .{"true", .Keyword_true}, |
| 57 | | .{"try", .Keyword_try}, |
| 58 | | .{"undefined", .Keyword_undefined}, |
| 59 | | .{"union", .Keyword_union}, |
| 60 | | .{"unreachable", .Keyword_unreachable}, |
| 61 | | .{"usingnamespace", .Keyword_usingnamespace}, |
| 62 | | .{"var", .Keyword_var}, |
| 63 | | .{"volatile", .Keyword_volatile}, |
| 64 | | .{"while", .Keyword_while}, |
| 14 | .{ "align", .Keyword_align }, |
| 15 | .{ "allowzero", .Keyword_allowzero }, |
| 16 | .{ "and", .Keyword_and }, |
| 17 | .{ "anyframe", .Keyword_anyframe }, |
| 18 | .{ "asm", .Keyword_asm }, |
| 19 | .{ "async", .Keyword_async }, |
| 20 | .{ "await", .Keyword_await }, |
| 21 | .{ "break", .Keyword_break }, |
| 22 | .{ "callconv", .Keyword_callconv }, |
| 23 | .{ "catch", .Keyword_catch }, |
| 24 | .{ "comptime", .Keyword_comptime }, |
| 25 | .{ "const", .Keyword_const }, |
| 26 | .{ "continue", .Keyword_continue }, |
| 27 | .{ "defer", .Keyword_defer }, |
| 28 | .{ "else", .Keyword_else }, |
| 29 | .{ "enum", .Keyword_enum }, |
| 30 | .{ "errdefer", .Keyword_errdefer }, |
| 31 | .{ "error", .Keyword_error }, |
| 32 | .{ "export", .Keyword_export }, |
| 33 | .{ "extern", .Keyword_extern }, |
| 34 | .{ "false", .Keyword_false }, |
| 35 | .{ "fn", .Keyword_fn }, |
| 36 | .{ "for", .Keyword_for }, |
| 37 | .{ "if", .Keyword_if }, |
| 38 | .{ "inline", .Keyword_inline }, |
| 39 | .{ "noalias", .Keyword_noalias }, |
| 40 | .{ "noasync", .Keyword_nosuspend }, // TODO: remove this |
| 41 | .{ "noinline", .Keyword_noinline }, |
| 42 | .{ "nosuspend", .Keyword_nosuspend }, |
| 43 | .{ "null", .Keyword_null }, |
| 44 | .{ "or", .Keyword_or }, |
| 45 | .{ "orelse", .Keyword_orelse }, |
| 46 | .{ "packed", .Keyword_packed }, |
| 47 | .{ "pub", .Keyword_pub }, |
| 48 | .{ "resume", .Keyword_resume }, |
| 49 | .{ "return", .Keyword_return }, |
| 50 | .{ "linksection", .Keyword_linksection }, |
| 51 | .{ "struct", .Keyword_struct }, |
| 52 | .{ "suspend", .Keyword_suspend }, |
| 53 | .{ "switch", .Keyword_switch }, |
| 54 | .{ "test", .Keyword_test }, |
| 55 | .{ "threadlocal", .Keyword_threadlocal }, |
| 56 | .{ "true", .Keyword_true }, |
| 57 | .{ "try", .Keyword_try }, |
| 58 | .{ "undefined", .Keyword_undefined }, |
| 59 | .{ "union", .Keyword_union }, |
| 60 | .{ "unreachable", .Keyword_unreachable }, |
| 61 | .{ "usingnamespace", .Keyword_usingnamespace }, |
| 62 | .{ "var", .Keyword_var }, |
| 63 | .{ "volatile", .Keyword_volatile }, |
| 64 | .{ "while", .Keyword_while }, |
| 65 | 65 | }); |
| 66 | 66 | |
| 67 | 67 | pub fn getKeyword(bytes: []const u8) ?Id { |
| ... | ... | @@ -1014,6 +1014,7 @@ pub const Tokenizer = struct { |
| 1014 | 1014 | state = .container_doc_comment; |
| 1015 | 1015 | }, |
| 1016 | 1016 | '\n' => break, |
| 1017 | '\t' => state = .line_comment, |
| 1017 | 1018 | else => { |
| 1018 | 1019 | state = .line_comment; |
| 1019 | 1020 | self.checkLiteralCharacter(); |
| ... | ... | @@ -1027,6 +1028,10 @@ pub const Tokenizer = struct { |
| 1027 | 1028 | result.id = .DocComment; |
| 1028 | 1029 | break; |
| 1029 | 1030 | }, |
| 1031 | '\t' => { |
| 1032 | state = .doc_comment; |
| 1033 | result.id = .DocComment; |
| 1034 | }, |
| 1030 | 1035 | else => { |
| 1031 | 1036 | state = .doc_comment; |
| 1032 | 1037 | result.id = .DocComment; |
| ... | ... | @@ -1035,6 +1040,7 @@ pub const Tokenizer = struct { |
| 1035 | 1040 | }, |
| 1036 | 1041 | .line_comment, .doc_comment, .container_doc_comment => switch (c) { |
| 1037 | 1042 | '\n' => break, |
| 1043 | '\t' => {}, |
| 1038 | 1044 | else => self.checkLiteralCharacter(), |
| 1039 | 1045 | }, |
| 1040 | 1046 | .zero => switch (c) { |
| ... | ... | @@ -1677,6 +1683,24 @@ test "tokenizer - multiline string literal with literal tab" { |
| 1677 | 1683 | }); |
| 1678 | 1684 | } |
| 1679 | 1685 | |
| 1686 | test "tokenizer - comments with literal tab" { |
| 1687 | testTokenize( |
| 1688 | \\//foo	bar |
| 1689 | \\//!foo	bar |
| 1690 | \\///foo	bar |
| 1691 | \\//	foo |
| 1692 | \\///	foo |
| 1693 | \\///	/foo |
| 1694 | , &[_]Token.Id{ |
| 1695 | .LineComment, |
| 1696 | .ContainerDocComment, |
| 1697 | .DocComment, |
| 1698 | .LineComment, |
| 1699 | .DocComment, |
| 1700 | .DocComment, |
| 1701 | }); |
| 1702 | } |
| 1703 | |
| 1680 | 1704 | test "tokenizer - pipe and then invalid" { |
| 1681 | 1705 | testTokenize("||=", &[_]Token.Id{ |
| 1682 | 1706 | .PipePipe, |