fn scan_word(&mut self) -> Token {
        // Collect all chars until the first non-ident char or EOF is reached.
        let mut s = String::new();
        loop {
            match self.curr {
                Some(c) if is_java_ident_part(c) => {
                    s.push(c);
                    self.bump();
                },
                _ => break,
            }
        }

        // check if the word is a keyword or literal
        match &s[..] {
            "true" => Token::Literal(Lit::Bool(true)),
            "false" => Token::Literal(Lit::Bool(false)),
            "null" => Token::Literal(Lit::Null),
            _ => match Keyword::from_str(&s) {
                Ok(k) => Token::KeyW(k),
                Err(_) => Token::Ident(s),
            },
        }
    }
/// Scans a word and returns it as a `String`.
///
/// This function scans through the source text as if we expect a Java
/// identifier (Section 3.8). However, it might turn out to be a keyword,
/// a boolean literal or a null literal.
///
/// ## Preconditions
/// `curr` needs to be a Java identifier start.
Scans a word and returns it as a `String`.
This function scans through the source text as if we expect a Java
identifier (Section 3.8). However, it might turn out to be a keyword,
a boolean literal or a null literal.
Scans a word and returns it as a ` String ` . This function scans through the source text as if we expect a Java identifier ( Section 3 . 8 ) . However it might turn out to be a keyword a boolean literal or a null literal .
fn scan_word(&mut self) -> Token {
        // Collect all chars until the first non-ident char or EOF is reached.
        let mut s = String::new();
        loop {
            match self.curr {
                Some(c) if is_java_ident_part(c) => {
                    s.push(c);
                    self.bump();
                },
                _ => break,
            }
        }
        // check if the word is a keyword or literal
        match &s[..] {
            "true" => Token::Literal(Lit::Bool(true)),
            "false" => Token::Literal(Lit::Bool(false)),
            "null" => Token::Literal(Lit::Null),
            _ => match Keyword::from_str(&s) {
                Ok(k) => Token::KeyW(k),
                Err(_) => Token::Ident(s),
            },
        }
    }
fn scan_word ( & mut self ) -> Token { // Collect all chars until the first non-ident char or EOF is reached. let mut s = String :: new ( ) ; loop { match self . curr { Some ( c ) if is_java_ident_part ( c ) => { s . push ( c ) ; self . bump ( ) ; } , _ => break , } } // check if the word is a keyword or literal match & s [ .. ] { " " => Token :: Literal ( Lit :: Bool ( true ) ) , " " => Token :: Literal ( Lit :: Bool ( false ) ) , " " => Token :: Literal ( Lit :: Null ) , _ => match Keyword :: from_str ( & s ) { Ok ( k ) => Token :: KeyW ( k ) , Err ( _ ) => Token :: Ident ( s ) , } , } }
Scans a word and returns it as a `String`.
Scans a word and returns it as a ` String ` .
&mut self
&mut self
preconditions
`curr` needs to be a Java identifier start.
` curr ` needs to be a Java identifier start .