fn parse_word(&mut self) -> Result<Token> {
        let mut word = String::new();

        while let Some(res) = self.input.next() {
            match res.chain_err(|| {
                                    ErrorKind::Lexer("could not read lexer input".into(), self.line)
                                })? {
                letter @ b'A'...b'Z' |
                letter @ b'a'...b'z' |
                letter @ b'0'...b'9' => word.push(letter as char),
                other => {
                    self.input.put_back(Ok(other));
                    break;
                }
            }
        }

        // Check to see if we have a keyword
        Ok(match word.as_str() {
               "const" => Token::Keyword(Keyword::Const),
               "int" => Token::Keyword(Keyword::Int),
               "void" => Token::Keyword(Keyword::Void),
               _ => Token::Ident(Ident(word)),
           })
    }
/// Helper method for parsing a word (identfier or keyword).
Helper method for parsing a word (identfier or keyword).
Helper method for parsing a word ( identfier or keyword ) .
fn parse_word(&mut self) -> Result<Token> {
        let mut word = String::new();
        while let Some(res) = self.input.next() {
            match res.chain_err(|| {
                                    ErrorKind::Lexer("could not read lexer input".into(), self.line)
                                })? {
                letter @ b'A'...b'Z' |
                letter @ b'a'...b'z' |
                letter @ b'0'...b'9' => word.push(letter as char),
                other => {
                    self.input.put_back(Ok(other));
                    break;
                }
            }
        }
        // Check to see if we have a keyword
        Ok(match word.as_str() {
               "const" => Token::Keyword(Keyword::Const),
               "int" => Token::Keyword(Keyword::Int),
               "void" => Token::Keyword(Keyword::Void),
               _ => Token::Ident(Ident(word)),
           })
    }
fn parse_word ( & mut self ) -> Result < Token > { let mut word = String :: new ( ) ; while let Some ( res ) = self . input . next ( ) { match res . chain_err ( | | { ErrorKind :: Lexer ( " " . into ( ) , self . line ) } ) ? { letter @ b'A' ... b'Z' | letter @ b'a' ... b'z' | letter @ b'0' ... b'9' => word . push ( letter as char ) , other => { self . input . put_back ( Ok ( other ) ) ; break ; } } } // Check to see if we have a keyword Ok ( match word . as_str ( ) { " " => Token :: Keyword ( Keyword :: Const ) , " " => Token :: Keyword ( Keyword :: Int ) , " " => Token :: Keyword ( Keyword :: Void ) , _ => Token :: Ident ( Ident ( word ) ) , } ) }
Helper method for parsing a word (identfier or keyword).
Helper method for parsing a word ( identfier or keyword ) .
&mut self
&mut self