@@ -150,10 +150,10 @@ fn is_whitespace(ch: char) -> bool {
150
150
ch. is_whitespace ( ) || ch == '\u{200e}' || ch == '\u{200f}'
151
151
}
152
152
153
- fn word_break ( input : Cursor ) -> PResult < ( ) > {
153
+ fn word_break ( input : Cursor ) -> Result < Cursor , LexError > {
154
154
match input. chars ( ) . next ( ) {
155
155
Some ( ch) if UnicodeXID :: is_xid_continue ( ch) => Err ( LexError ) ,
156
- Some ( _) | None => Ok ( ( input, ( ) ) ) ,
156
+ Some ( _) | None => Ok ( input) ,
157
157
}
158
158
}
159
159
@@ -276,15 +276,15 @@ fn symbol_not_raw(input: Cursor) -> PResult<&str> {
276
276
277
277
fn literal ( input : Cursor ) -> PResult < Literal > {
278
278
match literal_nocapture ( input) {
279
- Ok ( ( a , ( ) ) ) => {
279
+ Ok ( a ) => {
280
280
let end = input. len ( ) - a. len ( ) ;
281
281
Ok ( ( a, Literal :: _new ( input. rest [ ..end] . to_string ( ) ) ) )
282
282
}
283
283
Err ( LexError ) => Err ( LexError ) ,
284
284
}
285
285
}
286
286
287
- fn literal_nocapture ( input : Cursor ) -> PResult < ( ) > {
287
+ fn literal_nocapture ( input : Cursor ) -> Result < Cursor , LexError > {
288
288
if let Ok ( ok) = string ( input) {
289
289
Ok ( ok)
290
290
} else if let Ok ( ok) = byte_string ( input) {
@@ -302,13 +302,13 @@ fn literal_nocapture(input: Cursor) -> PResult<()> {
302
302
}
303
303
}
304
304
305
- fn string ( input : Cursor ) -> PResult < ( ) > {
305
+ fn string ( input : Cursor ) -> Result < Cursor , LexError > {
306
306
if let Ok ( input) = input. expect ( "\" " ) {
307
- let ( input, ( ) ) = cooked_string ( input) ?;
307
+ let input = cooked_string ( input) ?;
308
308
let input = input. expect ( "\" " ) ?;
309
309
match symbol_not_raw ( input) {
310
- Ok ( ( input, _) ) => Ok ( ( input, ( ) ) ) ,
311
- Err ( LexError ) => Ok ( ( input, ( ) ) ) ,
310
+ Ok ( ( input, _) ) => Ok ( input) ,
311
+ Err ( LexError ) => Ok ( input) ,
312
312
}
313
313
} else if let Ok ( input) = input. expect ( "r" ) {
314
314
raw_string ( input)
@@ -317,12 +317,12 @@ fn string(input: Cursor) -> PResult<()> {
317
317
}
318
318
}
319
319
320
- fn cooked_string ( input : Cursor ) -> PResult < ( ) > {
320
+ fn cooked_string ( input : Cursor ) -> Result < Cursor , LexError > {
321
321
let mut chars = input. char_indices ( ) . peekable ( ) ;
322
322
while let Some ( ( byte_offset, ch) ) = chars. next ( ) {
323
323
match ch {
324
324
'"' => {
325
- return Ok ( ( input. advance ( byte_offset) , ( ) ) ) ;
325
+ return Ok ( input. advance ( byte_offset) ) ;
326
326
}
327
327
'\r' => {
328
328
if let Some ( ( _, '\n' ) ) = chars. next ( ) {
@@ -361,25 +361,25 @@ fn cooked_string(input: Cursor) -> PResult<()> {
361
361
Err ( LexError )
362
362
}
363
363
364
- fn byte_string ( input : Cursor ) -> PResult < ( ) > {
364
+ fn byte_string ( input : Cursor ) -> Result < Cursor , LexError > {
365
365
if let Ok ( input) = input. expect ( "b\" " ) {
366
- let ( input, ( ) ) = cooked_byte_string ( input) ?;
366
+ let input = cooked_byte_string ( input) ?;
367
367
let input = input. expect ( "\" " ) ?;
368
- Ok ( ( input, ( ) ) )
368
+ Ok ( input)
369
369
} else if let Ok ( input) = input. expect ( "br" ) {
370
- let ( input, ( ) ) = raw_string ( input) ?;
371
- Ok ( ( input, ( ) ) )
370
+ let input = raw_string ( input) ?;
371
+ Ok ( input)
372
372
} else {
373
373
Err ( LexError )
374
374
}
375
375
}
376
376
377
- fn cooked_byte_string ( mut input : Cursor ) -> PResult < ( ) > {
377
+ fn cooked_byte_string ( mut input : Cursor ) -> Result < Cursor , LexError > {
378
378
let mut bytes = input. bytes ( ) . enumerate ( ) ;
379
379
' outer: while let Some ( ( offset, b) ) = bytes. next ( ) {
380
380
match b {
381
381
b'"' => {
382
- return Ok ( ( input. advance ( offset) , ( ) ) ) ;
382
+ return Ok ( input. advance ( offset) ) ;
383
383
}
384
384
b'\r' => {
385
385
if let Some ( ( _, b'\n' ) ) = bytes. next ( ) {
@@ -416,7 +416,7 @@ fn cooked_byte_string(mut input: Cursor) -> PResult<()> {
416
416
Err ( LexError )
417
417
}
418
418
419
- fn raw_string ( input : Cursor ) -> PResult < ( ) > {
419
+ fn raw_string ( input : Cursor ) -> Result < Cursor , LexError > {
420
420
let mut chars = input. char_indices ( ) ;
421
421
let mut n = 0 ;
422
422
while let Some ( ( byte_offset, ch) ) = chars. next ( ) {
@@ -433,7 +433,7 @@ fn raw_string(input: Cursor) -> PResult<()> {
433
433
match ch {
434
434
'"' if input. advance ( byte_offset + 1 ) . starts_with ( & input. rest [ ..n] ) => {
435
435
let rest = input. advance ( byte_offset + 1 + n) ;
436
- return Ok ( ( rest, ( ) ) ) ;
436
+ return Ok ( rest) ;
437
437
}
438
438
'\r' => { }
439
439
_ => { }
@@ -442,14 +442,14 @@ fn raw_string(input: Cursor) -> PResult<()> {
442
442
Err ( LexError )
443
443
}
444
444
445
- fn byte ( input : Cursor ) -> PResult < ( ) > {
445
+ fn byte ( input : Cursor ) -> Result < Cursor , LexError > {
446
446
let input = input. expect ( "b'" ) ?;
447
- let ( input, ( ) ) = cooked_byte ( input) ?;
447
+ let input = cooked_byte ( input) ?;
448
448
let input = input. expect ( "'" ) ?;
449
- Ok ( ( input, ( ) ) )
449
+ Ok ( input)
450
450
}
451
451
452
- fn cooked_byte ( input : Cursor ) -> PResult < ( ) > {
452
+ fn cooked_byte ( input : Cursor ) -> Result < Cursor , LexError > {
453
453
let mut bytes = input. bytes ( ) . enumerate ( ) ;
454
454
let ok = match bytes. next ( ) . map ( |( _, b) | b) {
455
455
Some ( b'\\' ) => match bytes. next ( ) . map ( |( _, b) | b) {
@@ -464,26 +464,26 @@ fn cooked_byte(input: Cursor) -> PResult<()> {
464
464
match bytes. next ( ) {
465
465
Some ( ( offset, _) ) => {
466
466
if input. chars ( ) . as_str ( ) . is_char_boundary ( offset) {
467
- Ok ( ( input. advance ( offset) , ( ) ) )
467
+ Ok ( input. advance ( offset) )
468
468
} else {
469
469
Err ( LexError )
470
470
}
471
471
}
472
- None => Ok ( ( input. advance ( input. len ( ) ) , ( ) ) ) ,
472
+ None => Ok ( input. advance ( input. len ( ) ) ) ,
473
473
}
474
474
} else {
475
475
Err ( LexError )
476
476
}
477
477
}
478
478
479
- fn character ( input : Cursor ) -> PResult < ( ) > {
479
+ fn character ( input : Cursor ) -> Result < Cursor , LexError > {
480
480
let input = input. expect ( "'" ) ?;
481
- let ( input, ( ) ) = cooked_char ( input) ?;
481
+ let input = cooked_char ( input) ?;
482
482
let input = input. expect ( "'" ) ?;
483
- Ok ( ( input, ( ) ) )
483
+ Ok ( input)
484
484
}
485
485
486
- fn cooked_char ( input : Cursor ) -> PResult < ( ) > {
486
+ fn cooked_char ( input : Cursor ) -> Result < Cursor , LexError > {
487
487
let mut chars = input. char_indices ( ) ;
488
488
let ok = match chars. next ( ) . map ( |( _, ch) | ch) {
489
489
Some ( '\\' ) => match chars. next ( ) . map ( |( _, ch) | ch) {
@@ -498,8 +498,8 @@ fn cooked_char(input: Cursor) -> PResult<()> {
498
498
} ;
499
499
if ok {
500
500
match chars. next ( ) {
501
- Some ( ( idx, _) ) => Ok ( ( input. advance ( idx) , ( ) ) ) ,
502
- None => Ok ( ( input. advance ( input. len ( ) ) , ( ) ) ) ,
501
+ Some ( ( idx, _) ) => Ok ( input. advance ( idx) ) ,
502
+ None => Ok ( input. advance ( input. len ( ) ) ) ,
503
503
}
504
504
} else {
505
505
Err ( LexError )
@@ -550,8 +550,8 @@ where
550
550
}
551
551
}
552
552
553
- fn float ( input : Cursor ) -> PResult < ( ) > {
554
- let ( mut rest, ( ) ) = float_digits ( input) ?;
553
+ fn float ( input : Cursor ) -> Result < Cursor , LexError > {
554
+ let mut rest = float_digits ( input) ?;
555
555
if let Some ( ch) = rest. chars ( ) . next ( ) {
556
556
if is_ident_start ( ch) {
557
557
rest = symbol_not_raw ( rest) ?. 0 ;
@@ -560,7 +560,7 @@ fn float(input: Cursor) -> PResult<()> {
560
560
word_break ( rest)
561
561
}
562
562
563
- fn float_digits ( input : Cursor ) -> PResult < ( ) > {
563
+ fn float_digits ( input : Cursor ) -> Result < Cursor , LexError > {
564
564
let mut chars = input. chars ( ) . peekable ( ) ;
565
565
match chars. next ( ) {
566
566
Some ( ch) if ch >= '0' && ch <= '9' => { }
@@ -634,11 +634,11 @@ fn float_digits(input: Cursor) -> PResult<()> {
634
634
}
635
635
}
636
636
637
- Ok ( ( input. advance ( len) , ( ) ) )
637
+ Ok ( input. advance ( len) )
638
638
}
639
639
640
- fn int ( input : Cursor ) -> PResult < ( ) > {
641
- let ( mut rest, ( ) ) = digits ( input) ?;
640
+ fn int ( input : Cursor ) -> Result < Cursor , LexError > {
641
+ let mut rest = digits ( input) ?;
642
642
if let Some ( ch) = rest. chars ( ) . next ( ) {
643
643
if is_ident_start ( ch) {
644
644
rest = symbol_not_raw ( rest) ?. 0 ;
@@ -647,7 +647,7 @@ fn int(input: Cursor) -> PResult<()> {
647
647
word_break ( rest)
648
648
}
649
649
650
- fn digits ( mut input : Cursor ) -> PResult < ( ) > {
650
+ fn digits ( mut input : Cursor ) -> Result < Cursor , LexError > {
651
651
let base = if input. starts_with ( "0x" ) {
652
652
input = input. advance ( 2 ) ;
653
653
16
@@ -686,7 +686,7 @@ fn digits(mut input: Cursor) -> PResult<()> {
686
686
if empty {
687
687
Err ( LexError )
688
688
} else {
689
- Ok ( ( input. advance ( len) , ( ) ) )
689
+ Ok ( input. advance ( len) )
690
690
}
691
691
}
692
692
0 commit comments