@@ -31,8 +31,8 @@ mod tests;
3131use self :: TokenKind :: * ;
3232use crate :: cursor:: Cursor ;
3333use crate :: literals:: {
34- double_quoted_string, lifetime_or_char, number, raw_double_quoted_string, single_quoted_string ,
35- LiteralKind ,
34+ double_quoted_string, eat_literal_suffix , lifetime_or_char, number, raw_double_quoted_string,
35+ single_quoted_string , LiteralKind ,
3636} ;
3737
3838/// Parsed token.
@@ -272,7 +272,7 @@ impl Cursor<'_> {
272272 let ( n_hashes, err) = raw_double_quoted_string ( self , 1 ) ;
273273 let suffix_start = self . len_consumed ( ) ;
274274 if err. is_none ( ) {
275- self . eat_literal_suffix ( ) ;
275+ eat_literal_suffix ( self ) ;
276276 }
277277 let kind = LiteralKind :: RawStr { n_hashes, err } ;
278278 Literal { kind, suffix_start }
@@ -287,7 +287,7 @@ impl Cursor<'_> {
287287 let terminated = single_quoted_string ( self ) ;
288288 let suffix_start = self . len_consumed ( ) ;
289289 if terminated {
290- self . eat_literal_suffix ( ) ;
290+ eat_literal_suffix ( self ) ;
291291 }
292292 let kind = LiteralKind :: Byte { terminated } ;
293293 Literal { kind, suffix_start }
@@ -297,7 +297,7 @@ impl Cursor<'_> {
297297 let terminated = double_quoted_string ( self ) ;
298298 let suffix_start = self . len_consumed ( ) ;
299299 if terminated {
300- self . eat_literal_suffix ( ) ;
300+ eat_literal_suffix ( self ) ;
301301 }
302302 let kind = LiteralKind :: ByteStr { terminated } ;
303303 Literal { kind, suffix_start }
@@ -307,7 +307,7 @@ impl Cursor<'_> {
307307 let ( n_hashes, err) = raw_double_quoted_string ( self , 2 ) ;
308308 let suffix_start = self . len_consumed ( ) ;
309309 if err. is_none ( ) {
310- self . eat_literal_suffix ( ) ;
310+ eat_literal_suffix ( self ) ;
311311 }
312312 let kind = LiteralKind :: RawByteStr { n_hashes, err } ;
313313 Literal { kind, suffix_start }
@@ -323,7 +323,7 @@ impl Cursor<'_> {
323323 c @ '0' ..='9' => {
324324 let literal_kind = number ( self , c) ;
325325 let suffix_start = self . len_consumed ( ) ;
326- self . eat_literal_suffix ( ) ;
326+ eat_literal_suffix ( self ) ;
327327 TokenKind :: Literal { kind : literal_kind, suffix_start }
328328 }
329329
@@ -363,7 +363,7 @@ impl Cursor<'_> {
363363 let terminated = double_quoted_string ( self ) ;
364364 let suffix_start = self . len_consumed ( ) ;
365365 if terminated {
366- self . eat_literal_suffix ( ) ;
366+ eat_literal_suffix ( self ) ;
367367 }
368368 let kind = LiteralKind :: Str { terminated } ;
369369 Literal { kind, suffix_start }
@@ -448,56 +448,7 @@ impl Cursor<'_> {
448448 Ident
449449 }
450450
451- fn eat_decimal_digits ( & mut self ) -> bool {
452- let mut has_digits = false ;
453- loop {
454- match self . first ( ) {
455- '_' => {
456- self . bump ( ) ;
457- }
458- '0' ..='9' => {
459- has_digits = true ;
460- self . bump ( ) ;
461- }
462- _ => break ,
463- }
464- }
465- has_digits
466- }
467-
468- fn eat_hexadecimal_digits ( & mut self ) -> bool {
469- let mut has_digits = false ;
470- loop {
471- match self . first ( ) {
472- '_' => {
473- self . bump ( ) ;
474- }
475- '0' ..='9' | 'a' ..='f' | 'A' ..='F' => {
476- has_digits = true ;
477- self . bump ( ) ;
478- }
479- _ => break ,
480- }
481- }
482- has_digits
483- }
484-
485- /// Eats the float exponent. Returns true if at least one digit was met,
486- /// and returns false otherwise.
487- fn eat_float_exponent ( & mut self ) -> bool {
488- debug_assert ! ( self . prev( ) == 'e' || self . prev( ) == 'E' ) ;
489- if self . first ( ) == '-' || self . first ( ) == '+' {
490- self . bump ( ) ;
491- }
492- self . eat_decimal_digits ( )
493- }
494-
495- // Eats the suffix of the literal, e.g. "_u8".
496- fn eat_literal_suffix ( & mut self ) {
497- self . eat_identifier ( ) ;
498- }
499-
500- // Eats the identifier.
451+ /// Eats one identifier.
501452 fn eat_identifier ( & mut self ) {
502453 if !is_id_start ( self . first ( ) ) {
503454 return ;
@@ -506,11 +457,4 @@ impl Cursor<'_> {
506457
507458 self . eat_while ( is_id_continue) ;
508459 }
509-
510- /// Eats symbols while predicate returns true or until the end of file is reached.
511- fn eat_while ( & mut self , mut predicate : impl FnMut ( char ) -> bool ) {
512- while predicate ( self . first ( ) ) && !self . is_eof ( ) {
513- self . bump ( ) ;
514- }
515- }
516460}
0 commit comments