fn read_number<Chars: Iterator<Item=char>>(buffer: &mut TokenReadBuffer<Chars>, location: FileLocation) -> (Token, String, FileLocation) {
    loop {
        let next_char = buffer.read_next();

        match next_char {
            Some(chr)       => {
                if chr >= '0' && chr <= '9' {

                } else {
                    buffer.push_back();
                    break;
                }
            }
            None            => break,
        }
    }

    match buffer.read_next() {
        Some('b') => {
            // Might be a bitnumber (number followed by 'b<bits>')
            let mut num_bits = 0;
            loop {
                let bit_count   = buffer.read_next();
                match bit_count {
                    Some(num) => {
                        if num >= '0' && num <= '9' {
                        } else {
                            buffer.push_back();
                            break;
                        }
                    }
                    None => { 
                        break;
                    }
                }

                num_bits += 1;
            }

            // Should be at least one bit character (up to 2 is sensible, though we use 128-bit numbers everywhere, so 3 is also possible)
            if num_bits == 0 {
                buffer.push_back();
                (Token::IntNumber, buffer.read_characters(), buffer.update_location(location))
            } else {
                (Token::BitNumber, buffer.read_characters(), buffer.update_location(location))
            }
        }

        Some(_) => {
            // Not a bitnumber
            buffer.push_back();
            read_number_suffix(Token::IntNumber, Token::IntNumber, buffer, location)
        },

        None => {
            // No suffix
            (Token::IntNumber, buffer.read_characters(), buffer.update_location(location))
        }
    }
}
///
/// After reading a numeric value, reads the rest of the number
///
After reading a numeric value, reads the rest of the number
After reading a numeric value reads the rest of the number
fn read_number<Chars: Iterator<Item=char>>(buffer: &mut TokenReadBuffer<Chars>, location: FileLocation) -> (Token, String, FileLocation) {
    loop {
        let next_char = buffer.read_next();
        match next_char {
            Some(chr)       => {
                if chr >= '0' && chr <= '9' {
                } else {
                    buffer.push_back();
                    break;
                }
            }
            None            => break,
        }
    }
    match buffer.read_next() {
        Some('b') => {
            // Might be a bitnumber (number followed by 'b<bits>')
            let mut num_bits = 0;
            loop {
                let bit_count   = buffer.read_next();
                match bit_count {
                    Some(num) => {
                        if num >= '0' && num <= '9' {
                        } else {
                            buffer.push_back();
                            break;
                        }
                    }
                    None => { 
                        break;
                    }
                }
                num_bits += 1;
            }
            // Should be at least one bit character (up to 2 is sensible, though we use 128-bit numbers everywhere, so 3 is also possible)
            if num_bits == 0 {
                buffer.push_back();
                (Token::IntNumber, buffer.read_characters(), buffer.update_location(location))
            } else {
                (Token::BitNumber, buffer.read_characters(), buffer.update_location(location))
            }
        }
        Some(_) => {
            // Not a bitnumber
            buffer.push_back();
            read_number_suffix(Token::IntNumber, Token::IntNumber, buffer, location)
        },
        None => {
            // No suffix
            (Token::IntNumber, buffer.read_characters(), buffer.update_location(location))
        }
    }
}
fn read_number < Chars : Iterator < Item = char > > ( buffer : & mut TokenReadBuffer < Chars > , location : FileLocation ) -> ( Token , String , FileLocation ) { loop { let next_char = buffer . read_next ( ) ; match next_char { Some ( chr ) => { if chr >= '0' && chr <= '9' { } else { buffer . push_back ( ) ; break ; } } None => break , } } match buffer . read_next ( ) { Some ( 'b' ) => { // Might be a bitnumber (number followed by 'b<bits>') let mut num_bits = 0 ; loop { let bit_count = buffer . read_next ( ) ; match bit_count { Some ( num ) => { if num >= '0' && num <= '9' { } else { buffer . push_back ( ) ; break ; } } None => { break ; } } num_bits += 1 ; } // Should be at least one bit character (up to 2 is sensible, though we use 128-bit numbers everywhere, so 3 is also possible) if num_bits == 0 { buffer . push_back ( ) ; ( Token :: IntNumber , buffer . read_characters ( ) , buffer . update_location ( location ) ) } else { ( Token :: BitNumber , buffer . read_characters ( ) , buffer . update_location ( location ) ) } } Some ( _ ) => { // Not a bitnumber buffer . push_back ( ) ; read_number_suffix ( Token :: IntNumber , Token :: IntNumber , buffer , location ) } , None => { // No suffix ( Token :: IntNumber , buffer . read_characters ( ) , buffer . update_location ( location ) ) } } }
After reading a numeric value, reads the rest of the number
After reading a numeric value reads the rest of the number
buffer
&mut TokenReadBuffer<Chars>
location
FileLocation
buffer
&mut TokenReadBuffer<Chars>
location
FileLocation