fn scan_digits(&mut self, radix: u32) -> Result<String, ()> {
        // We possibly scan more digits to report smart errors
        let scan_radix = if radix <= 10 { 10 } else { radix };

        // Prepare report for reporting possible radix errors
        let mut rep = diag::Report {
            kind: diag::ReportKind::Error,
            span: None,
            remarks: vec![],
        };

        let mut s = String::new();
        loop {
            match self.curr.unwrap_or('\0') {
                // skip underscores
                '_' => {
                    self.bump();
                    continue;
                },
                c if c.to_digit(scan_radix).is_some() => {
                    // check if the digit is valid in the given radix
                    // TODO: Maybe stop lexing here
                    if c.to_digit(radix).is_none() {
                        rep.remarks.push(diag::Remark::error(
                            format!("Invalid digit for base{} literal", radix),
                            diag::Snippet::Orig(Span::single(self.curr_pos)),
                        ));
                    }
                    s.push(c);
                    self.bump();
                }
                _ => break,
            }
        }
        if rep.remarks.len() > 0 {
            // Set span for main "Report"
            // We can unwrap everywhere, because the span is always set and we
            // know that we have at least one remark.
            let lo = rep.remarks.iter().map(|rem|
                rem.snippet.span().unwrap().lo
            ).min();
            let hi = rep.remarks.iter().map(|rem|
                rem.snippet.span().unwrap().hi
            ).min();
            rep.span = Some(Span::new(lo.unwrap(), hi.unwrap()));

            Err(Error {
                report: rep,
                poison: None,
            })
        } else {
            Ok(s)
        }
    }
/// Scans digits with the given radix and returns the scanned string.
///
/// The parsing will skip underscores and will stop when a character is
/// found, that is no digit in the given radix. However, if the radix is
/// less than 10, all digits from 0 to 9 are scanned and an error is
/// printed for each digit that is too high for the given radix.
Scans digits with the given radix and returns the scanned string.
The parsing will skip underscores and will stop when a character is
found, that is no digit in the given radix. However, if the radix is
less than 10, all digits from 0 to 9 are scanned and an error is
printed for each digit that is too high for the given radix.
Scans digits with the given radix and returns the scanned string . The parsing will skip underscores and will stop when a character is found that is no digit in the given radix . However if the radix is less than 10 all digits from 0 to 9 are scanned and an error is printed for each digit that is too high for the given radix .
fn scan_digits(&mut self, radix: u32) -> Result<String, ()> {
        // We possibly scan more digits to report smart errors
        let scan_radix = if radix <= 10 { 10 } else { radix };
        // Prepare report for reporting possible radix errors
        let mut rep = diag::Report {
            kind: diag::ReportKind::Error,
            span: None,
            remarks: vec![],
        };
        let mut s = String::new();
        loop {
            match self.curr.unwrap_or('\0') {
                // skip underscores
                '_' => {
                    self.bump();
                    continue;
                },
                c if c.to_digit(scan_radix).is_some() => {
                    // check if the digit is valid in the given radix
                    // TODO: Maybe stop lexing here
                    if c.to_digit(radix).is_none() {
                        rep.remarks.push(diag::Remark::error(
                            format!("Invalid digit for base{} literal", radix),
                            diag::Snippet::Orig(Span::single(self.curr_pos)),
                        ));
                    }
                    s.push(c);
                    self.bump();
                }
                _ => break,
            }
        }
        if rep.remarks.len() > 0 {
            // Set span for main "Report"
            // We can unwrap everywhere, because the span is always set and we
            // know that we have at least one remark.
            let lo = rep.remarks.iter().map(|rem|
                rem.snippet.span().unwrap().lo
            ).min();
            let hi = rep.remarks.iter().map(|rem|
                rem.snippet.span().unwrap().hi
            ).min();
            rep.span = Some(Span::new(lo.unwrap(), hi.unwrap()));
            Err(Error {
                report: rep,
                poison: None,
            })
        } else {
            Ok(s)
        }
    }
fn scan_digits ( & mut self , radix : u32 ) -> Result < String , ( ) > { // We possibly scan more digits to report smart errors let scan_radix = if radix <= 10 { 10 } else { radix } ; // Prepare report for reporting possible radix errors let mut rep = diag :: Report { kind : diag :: ReportKind :: Error , span : None , remarks : vec ! [ ] , } ; let mut s = String :: new ( ) ; loop { match self . curr . unwrap_or ( '\0' ) { // skip underscores '_' => { self . bump ( ) ; continue ; } , c if c . to_digit ( scan_radix ) . is_some ( ) => { // check if the digit is valid in the given radix // TODO: Maybe stop lexing here if c . to_digit ( radix ) . is_none ( ) { rep . remarks . push ( diag :: Remark :: error ( format ! ( " " radix ) , diag :: Snippet :: Orig ( Span :: single ( self . curr_pos ) ) , ) ) ; } s . push ( c ) ; self . bump ( ) ; } _ => break , } } if rep . remarks . len ( ) > 0 { // Set span for main "Report" // We can unwrap everywhere, because the span is always set and we // know that we have at least one remark. let lo = rep . remarks . iter ( ) . map ( | rem | rem . snippet . span ( ) . unwrap ( ) . lo ) . min ( ) ; let hi = rep . remarks . iter ( ) . map ( | rem | rem . snippet . span ( ) . unwrap ( ) . hi ) . min ( ) ; rep . span = Some ( Span :: new ( lo . unwrap ( ) , hi . unwrap ( ) ) ) ; Err ( Error { report : rep , poison : None , } ) } else { Ok ( s ) } }
Scans digits with the given radix and returns the scanned string.
Scans digits with the given radix and returns the scanned string .
&mut self
radix
u32
&mut self
radix
u32