fn parse_token(&mut self) -> Token {
        // Skip over (and record) any invalid tokens until either a valid token or an EOF is encountered
        loop {
            let kind = self.lexer.next().unwrap_or(TokenKind::EndOfFile);
            match kind {
                TokenKind::Error => {
                    if let Some(error_token_kind) = self.lexer.extras.error_token {
                        // Reset the error token
                        self.lexer.extras.error_token = None;
                        // If error_token is set, return that error token
                        // instead of a generic error.
                        self.end_index = self.current.span.end;
                        return std::mem::replace(
                            &mut self.current,
                            Token {
                                kind: error_token_kind,
                                span: self.lexer.span().into(),
                            },
                        );
                    } else {
                        // Record and skip over unknown character errors
                        let error = Diagnostic::error(
                            SyntaxError::UnsupportedCharacter,
                            Location::new(self.source_location, self.lexer.span().into()),
                        );
                        self.record_error(error);
                    }
                }
                _ => {
                    self.end_index = self.current.span.end;
                    return std::mem::replace(
                        &mut self.current,
                        Token {
                            kind,
                            span: self.lexer.span().into(),
                        },
                    );
                }
            }
        }
    }
/// Get the next token (and advance)
Get the next token (and advance)
Get the next token ( and advance )
fn parse_token(&mut self) -> Token {
        // Skip over (and record) any invalid tokens until either a valid token or an EOF is encountered
        loop {
            let kind = self.lexer.next().unwrap_or(TokenKind::EndOfFile);
            match kind {
                TokenKind::Error => {
                    if let Some(error_token_kind) = self.lexer.extras.error_token {
                        // Reset the error token
                        self.lexer.extras.error_token = None;
                        // If error_token is set, return that error token
                        // instead of a generic error.
                        self.end_index = self.current.span.end;
                        return std::mem::replace(
                            &mut self.current,
                            Token {
                                kind: error_token_kind,
                                span: self.lexer.span().into(),
                            },
                        );
                    } else {
                        // Record and skip over unknown character errors
                        let error = Diagnostic::error(
                            SyntaxError::UnsupportedCharacter,
                            Location::new(self.source_location, self.lexer.span().into()),
                        );
                        self.record_error(error);
                    }
                }
                _ => {
                    self.end_index = self.current.span.end;
                    return std::mem::replace(
                        &mut self.current,
                        Token {
                            kind,
                            span: self.lexer.span().into(),
                        },
                    );
                }
            }
        }
    }
fn parse_token ( & mut self ) -> Token { // Skip over (and record) any invalid tokens until either a valid token or an EOF is encountered loop { let kind = self . lexer . next ( ) . unwrap_or ( TokenKind :: EndOfFile ) ; match kind { TokenKind :: Error => { if let Some ( error_token_kind ) = self . lexer . extras . error_token { // Reset the error token self . lexer . extras . error_token = None ; // If error_token is set, return that error token // instead of a generic error. self . end_index = self . current . span . end ; return std :: mem :: replace ( & mut self . current , Token { kind : error_token_kind , span : self . lexer . span ( ) . into ( ) , } , ) ; } else { // Record and skip over unknown character errors let error = Diagnostic :: error ( SyntaxError :: UnsupportedCharacter , Location :: new ( self . source_location , self . lexer . span ( ) . into ( ) ) , ) ; self . record_error ( error ) ; } } _ => { self . end_index = self . current . span . end ; return std :: mem :: replace ( & mut self . current , Token { kind , span : self . lexer . span ( ) . into ( ) , } , ) ; } } } }
Get the next token (and advance)
Get the next token ( and advance )
&mut self
&mut self