@@ -57,11 +57,10 @@ impl Token {
57
57
/// Enum representing common lexeme types.
58
58
#[ derive( Clone , Copy , Debug , PartialEq , Eq ) ]
59
59
pub enum TokenKind {
60
- // Multi-char tokens:
61
- /// "// comment"
60
+ /// A line comment, e.g. `// comment`.
62
61
LineComment { doc_style : Option < DocStyle > } ,
63
62
64
- /// `/* block comment */`
63
+ /// A block comment, e.g. `/* block comment */`.
65
64
///
66
65
/// Block comments can be recursive, so a sequence like `/* /* */`
67
66
/// will not be considered terminated and will result in a parsing error.
@@ -70,18 +69,17 @@ pub enum TokenKind {
70
69
/// Any whitespace character sequence.
71
70
Whitespace ,
72
71
73
- /// "ident" or "continue"
74
- ///
75
- /// At this step, keywords are also considered identifiers.
72
+ /// An identifier or keyword, e.g. `ident` or `continue`.
76
73
Ident ,
77
74
78
- /// Like the above, but containing invalid unicode codepoints .
75
+ /// An identifier that is invalid because it contains emoji .
79
76
InvalidIdent ,
80
77
81
- /// "r#ident"
78
+ /// A raw identifier, e.g. "r#ident".
82
79
RawIdent ,
83
80
84
- /// An unknown prefix, like `foo#`, `foo'`, `foo"`.
81
+ /// An unknown literal prefix, like `foo#`, `foo'`, `foo"`. Excludes
82
+ /// literal prefixes that contain emoji, which are considered "invalid".
85
83
///
86
84
/// Note that only the
87
85
/// prefix (`foo`) is included in the token, not the separator (which is
@@ -93,11 +91,12 @@ pub enum TokenKind {
93
91
94
92
/// An unknown prefix in a lifetime, like `'foo#`.
95
93
///
96
- /// Note that like above , only the `'` and prefix are included in the token
94
+ /// Like `UnknownPrefix` , only the `'` and prefix are included in the token
97
95
/// and not the separator.
98
96
UnknownPrefixLifetime ,
99
97
100
- /// `'r#lt`, which in edition < 2021 is split into several tokens: `'r # lt`.
98
+ /// A raw lifetime, e.g. `'r#foo`. In edition < 2021 it will be split into
99
+ /// several tokens: `'r` and `#` and `foo`.
101
100
RawLifetime ,
102
101
103
102
/// Similar to the above, but *always* an error on every edition. This is used
@@ -110,70 +109,69 @@ pub enum TokenKind {
110
109
/// Split into the component tokens on older editions.
111
110
GuardedStrPrefix ,
112
111
113
- /// Examples: `12u8`, `1.0e-40`, `b"123"`. Note that `_` is an invalid
112
+ /// Literals, e.g. `12u8`, `1.0e-40`, `b"123"`. Note that `_` is an invalid
114
113
/// suffix, but may be present here on string and float literals. Users of
115
114
/// this type will need to check for and reject that case.
116
115
///
117
116
/// See [LiteralKind] for more details.
118
117
Literal { kind : LiteralKind , suffix_start : u32 } ,
119
118
120
- /// "'a"
119
+ /// A lifetime, e.g. `'a`.
121
120
Lifetime { starts_with_number : bool } ,
122
121
123
- // One-char tokens:
124
- /// ";"
122
+ /// `;`
125
123
Semi ,
126
- /// ","
124
+ /// `,`
127
125
Comma ,
128
- /// "."
126
+ /// `.`
129
127
Dot ,
130
- /// "("
128
+ /// `(`
131
129
OpenParen ,
132
- /// ")"
130
+ /// `)`
133
131
CloseParen ,
134
- /// "{"
132
+ /// `{`
135
133
OpenBrace ,
136
- /// "}"
134
+ /// `}`
137
135
CloseBrace ,
138
- /// "["
136
+ /// `[`
139
137
OpenBracket ,
140
- /// "]"
138
+ /// `]`
141
139
CloseBracket ,
142
- /// "@"
140
+ /// `@`
143
141
At ,
144
- /// "#"
142
+ /// `#`
145
143
Pound ,
146
- /// "~"
144
+ /// `~`
147
145
Tilde ,
148
- /// "?"
146
+ /// `?`
149
147
Question ,
150
- /// ":"
148
+ /// `:`
151
149
Colon ,
152
- /// "$"
150
+ /// `$`
153
151
Dollar ,
154
- /// "="
152
+ /// `=`
155
153
Eq ,
156
- /// "!"
154
+ /// `!`
157
155
Bang ,
158
- /// "<"
156
+ /// `<`
159
157
Lt ,
160
- /// ">"
158
+ /// `>`
161
159
Gt ,
162
- /// "-"
160
+ /// `-`
163
161
Minus ,
164
- /// "&"
162
+ /// `&`
165
163
And ,
166
- /// "|"
164
+ /// `|`
167
165
Or ,
168
- /// "+"
166
+ /// `+`
169
167
Plus ,
170
- /// "*"
168
+ /// `*`
171
169
Star ,
172
- /// "/"
170
+ /// `/`
173
171
Slash ,
174
- /// "^"
172
+ /// `^`
175
173
Caret ,
176
- /// "%"
174
+ /// `%`
177
175
Percent ,
178
176
179
177
/// Unknown token, not expected by the lexer, e.g. "№"
0 commit comments