fn word(&mut self) -> Result<(Token<'input>, usize), InternalError> {
        let start = self.at;

        match self.word_re.find(&self.input[start..]) {
            Some(m) => {
                // the regex does not know where we really are in the string.
                let end = start + m.end();

                self.drop_n(end - start - 1);

                match m.as_str() {
                    // actual keywords
                    "cap" => Ok((Token::Cap, end)),
                    "as" => Ok((Token::As, end)),
                    "let" => Ok((Token::Let, end)),
                    "fn" => Ok((Token::FnKeyword, end)),
                    "return" => Ok((Token::Return, end)),

                    // Reserved Keywords
                    //
                    // "structured" is for a "structured typeof <expr>"
                    // expression which returns a more complicated
                    // description of types than the simple string from typeof.
                    "match" | "enum" | "typeof" | "structured" | "struct" => {
                        Err(self.error(
                            LexicalErrorKind::ReservedButNotUsedKeyword {
                                word: String::from(m.as_str()),
                                end: end,
                            },
                        ))
                    }

                    id => Ok((Token::Id(id), end)),
                }
            }
            None => Err(self.error(LexicalErrorKind::BadIdentifier)),
        }
    }
// either a keyword or an identifier
either a keyword or an identifier
either a keyword or an identifier
fn word(&mut self) -> Result<(Token<'input>, usize), InternalError> {
        let start = self.at;
        match self.word_re.find(&self.input[start..]) {
            Some(m) => {
                // the regex does not know where we really are in the string.
                let end = start + m.end();
                self.drop_n(end - start - 1);
                match m.as_str() {
                    // actual keywords
                    "cap" => Ok((Token::Cap, end)),
                    "as" => Ok((Token::As, end)),
                    "let" => Ok((Token::Let, end)),
                    "fn" => Ok((Token::FnKeyword, end)),
                    "return" => Ok((Token::Return, end)),
                    // Reserved Keywords
                    //
                    // "structured" is for a "structured typeof <expr>"
                    // expression which returns a more complicated
                    // description of types than the simple string from typeof.
                    "match" | "enum" | "typeof" | "structured" | "struct" => {
                        Err(self.error(
                            LexicalErrorKind::ReservedButNotUsedKeyword {
                                word: String::from(m.as_str()),
                                end: end,
                            },
                        ))
                    }
                    id => Ok((Token::Id(id), end)),
                }
            }
            None => Err(self.error(LexicalErrorKind::BadIdentifier)),
        }
    }
fn word ( & mut self ) -> Result < ( Token < ' input > , usize ) , InternalError > { let start = self . at ; match self . word_re . find ( & self . input [ start .. ] ) { Some ( m ) => { // the regex does not know where we really are in the string. let end = start + m . end ( ) ; self . drop_n ( end - start - 1 ) ; match m . as_str ( ) { // actual keywords " " => Ok ( ( Token :: Cap , end ) ) , " " => Ok ( ( Token :: As , end ) ) , " " => Ok ( ( Token :: Let , end ) ) , " " => Ok ( ( Token :: FnKeyword , end ) ) , " " => Ok ( ( Token :: Return , end ) ) , // Reserved Keywords // // "structured" is for a "structured typeof <expr>" // expression which returns a more complicated // description of types than the simple string from typeof. " " | " " | " " | " " | " " => { Err ( self . error ( LexicalErrorKind :: ReservedButNotUsedKeyword { word : String :: from ( m . as_str ( ) ) , end : end , } , ) ) } id => Ok ( ( Token :: Id ( id ) , end ) ) , } } None => Err ( self . error ( LexicalErrorKind :: BadIdentifier ) ) , } }
either a keyword or an identifier
either a keyword or an identifier
&mut self