@@ -142,17 +142,22 @@ impl<'a> TokenStream<'a> {
142
142
'(' | ')' | '[' | ']' | '{' | '}' => {
143
143
self . position . column += 1 ;
144
144
self . off += 1 ;
145
- return Ok ( ( Punctuator , 1 ) ) ;
145
+
146
+ Ok ( ( Punctuator , 1 ) )
146
147
}
147
148
'.' => {
148
149
if iter. as_str ( ) . starts_with ( ".." ) {
149
150
self . position . column += 3 ;
150
151
self . off += 3 ;
151
- return Ok ( ( Punctuator , 3 ) )
152
+
153
+ Ok ( ( Punctuator , 3 ) )
152
154
} else {
153
- return Err ( Error :: unexpected_message (
155
+ Err (
156
+ Error :: unexpected_message (
154
157
format_args ! ( "bare dot {:?} is not supported, \
155
- only \" ...\" ", cur_char) ) ) ;
158
+ only \" ...\" ", cur_char)
159
+ )
160
+ )
156
161
}
157
162
}
158
163
'_' | 'a' ...'z' | 'A' ...'Z' => {
@@ -169,7 +174,8 @@ impl<'a> TokenStream<'a> {
169
174
let len = self . buf . len ( ) - self . off ;
170
175
self . position . column += len;
171
176
self . off += len;
172
- return Ok ( ( Name , len) ) ;
177
+
178
+ Ok ( ( Name , len) )
173
179
}
174
180
'-' | '0' ...'9' => {
175
181
let mut exponent = None ;
@@ -190,6 +196,7 @@ impl<'a> TokenStream<'a> {
190
196
_ => { } ,
191
197
}
192
198
} ;
199
+
193
200
if exponent. is_some ( ) || real. is_some ( ) {
194
201
let value = & self . buf [ self . off ..] [ ..len] ;
195
202
if !check_float ( value, exponent, real) {
@@ -198,7 +205,8 @@ impl<'a> TokenStream<'a> {
198
205
}
199
206
self . position . column += len;
200
207
self . off += len;
201
- return Ok ( ( FloatValue , len) ) ;
208
+
209
+ Ok ( ( FloatValue , len) )
202
210
} else {
203
211
let value = & self . buf [ self . off ..] [ ..len] ;
204
212
if !check_int ( value) {
@@ -207,20 +215,25 @@ impl<'a> TokenStream<'a> {
207
215
}
208
216
self . position . column += len;
209
217
self . off += len;
210
- return Ok ( ( IntValue , len) ) ;
218
+
219
+ Ok ( ( IntValue , len) )
211
220
}
212
221
}
213
222
'"' => {
214
223
if iter. as_str ( ) . starts_with ( "\" \" " ) {
215
224
let tail = & iter. as_str ( ) [ 2 ..] ;
216
- for ( endidx , _) in tail. match_indices ( "\" \" \" " ) {
217
- if !tail[ ..endidx ] . ends_with ( '\\' ) {
218
- self . update_position ( endidx+ 6 ) ;
219
- return Ok ( ( BlockString , endidx+ 6 ) ) ;
225
+ for ( end_idx , _) in tail. match_indices ( "\" \" \" " ) {
226
+ if !tail[ ..end_idx ] . ends_with ( '\\' ) {
227
+ self . update_position ( end_idx + 6 ) ;
228
+ return Ok ( ( BlockString , end_idx + 6 ) ) ;
220
229
}
221
230
}
222
- return Err ( Error :: unexpected_message (
223
- "unterminated block string value" ) ) ;
231
+
232
+ Err (
233
+ Error :: unexpected_message (
234
+ "unterminated block string value"
235
+ )
236
+ )
224
237
} else {
225
238
let mut prev_char = cur_char;
226
239
let mut nchars = 1 ;
@@ -234,21 +247,30 @@ impl<'a> TokenStream<'a> {
234
247
return Ok ( ( StringValue , idx+1 ) ) ;
235
248
}
236
249
'\n' => {
237
- return Err ( Error :: unexpected_message (
238
- "unterminated string value" ) ) ;
250
+ return Err (
251
+ Error :: unexpected_message (
252
+ "unterminated string value"
253
+ )
254
+ ) ;
239
255
}
240
256
_ => {
241
257
242
258
}
243
259
}
244
260
prev_char = cur_char;
245
261
}
246
- return Err ( Error :: unexpected_message (
247
- "unterminated string value" ) ) ;
262
+ Err (
263
+ Error :: unexpected_message (
264
+ "unterminated string value"
265
+ )
266
+ )
248
267
}
249
268
}
250
- _ => return Err ( Error :: unexpected_message (
251
- format_args ! ( "unexpected character {:?}" , cur_char) ) ) ,
269
+ _ => Err (
270
+ Error :: unexpected_message (
271
+ format_args ! ( "unexpected character {:?}" , cur_char)
272
+ )
273
+ ) ,
252
274
}
253
275
}
254
276
0 commit comments