fn parse_explain(&mut self) -> Result<Statement<Raw>, ParserError> {
        // (TYPED)?
        let typed = self.parse_keyword(TYPED);
        let mut timing = false;

        // options: ( '(' TIMING (true|false) ')' )?
        if let Some(Token::LParen) = self.peek_token() {
            // Check whether a valid option is after the parentheses, since the
            // parentheses may belong to the actual query to be explained.
            match self.peek_nth_token(1) {
                Some(Token::Keyword(TIMING)) => {
                    self.next_token(); // Consume the LParen
                    self.parse_comma_separated(|s| match s.expect_one_of_keywords(&[TIMING])? {
                        TIMING => {
                            timing = s.parse_boolean_value()?;
                            Ok(())
                        }
                        _ => unreachable!(),
                    })?;
                    self.expect_token(&Token::RParen)?;
                }
                _ => {}
            }
        }

        // (RAW | DECORRELATED | OPTIMIZED | PHYSICAL)? PLAN
        let stage = match self.parse_one_of_keywords(&[
            RAW,
            DECORRELATED,
            OPTIMIZED,
            PHYSICAL,
            PLAN,
            QUERY,
            TIMESTAMP,
        ]) {
            Some(RAW) => {
                self.expect_keywords(&[PLAN, FOR])?;
                ExplainStage::RawPlan
            }
            Some(QUERY) => {
                self.expect_keywords(&[GRAPH, FOR])?;
                ExplainStage::QueryGraph
            }
            Some(DECORRELATED) => {
                self.expect_keywords(&[PLAN, FOR])?;
                ExplainStage::DecorrelatedPlan
            }
            Some(OPTIMIZED) => {
                if self.parse_keyword(QUERY) {
                    self.expect_keywords(&[GRAPH, FOR])?;
                    ExplainStage::OptimizedQueryGraph
                } else {
                    self.expect_keywords(&[PLAN, FOR])?;
                    ExplainStage::OptimizedPlan
                }
            }
            Some(PLAN) => {
                self.expect_keyword(FOR)?;
                ExplainStage::OptimizedPlan
            }
            Some(PHYSICAL) => {
                self.expect_keywords(&[PLAN, FOR])?;
                ExplainStage::PhysicalPlan
            }
            Some(TIMESTAMP) => {
                self.expect_keywords(&[FOR])?;
                ExplainStage::Timestamp
            }
            None => ExplainStage::OptimizedPlan,
            _ => unreachable!(),
        };

        // VIEW view_name | query
        let explainee = if self.parse_keyword(VIEW) {
            Explainee::View(self.parse_raw_name()?)
        } else {
            Explainee::Query(self.parse_query()?)
        };

        let options = ExplainOptions { typed, timing };
        Ok(Statement::Explain(ExplainStatement {
            stage,
            explainee,
            options,
        }))
    }
/// Parse an `EXPLAIN` statement, assuming that the `EXPLAIN` token
/// has already been consumed.
Parse an `EXPLAIN` statement, assuming that the `EXPLAIN` token
has already been consumed.
Parse an ` EXPLAIN ` statement assuming that the ` EXPLAIN ` token has already been consumed .
fn parse_explain(&mut self) -> Result<Statement<Raw>, ParserError> {
        // (TYPED)?
        let typed = self.parse_keyword(TYPED);
        let mut timing = false;
        // options: ( '(' TIMING (true|false) ')' )?
        if let Some(Token::LParen) = self.peek_token() {
            // Check whether a valid option is after the parentheses, since the
            // parentheses may belong to the actual query to be explained.
            match self.peek_nth_token(1) {
                Some(Token::Keyword(TIMING)) => {
                    self.next_token(); // Consume the LParen
                    self.parse_comma_separated(|s| match s.expect_one_of_keywords(&[TIMING])? {
                        TIMING => {
                            timing = s.parse_boolean_value()?;
                            Ok(())
                        }
                        _ => unreachable!(),
                    })?;
                    self.expect_token(&Token::RParen)?;
                }
                _ => {}
            }
        }
        // (RAW | DECORRELATED | OPTIMIZED | PHYSICAL)? PLAN
        let stage = match self.parse_one_of_keywords(&[
            RAW,
            DECORRELATED,
            OPTIMIZED,
            PHYSICAL,
            PLAN,
            QUERY,
            TIMESTAMP,
        ]) {
            Some(RAW) => {
                self.expect_keywords(&[PLAN, FOR])?;
                ExplainStage::RawPlan
            }
            Some(QUERY) => {
                self.expect_keywords(&[GRAPH, FOR])?;
                ExplainStage::QueryGraph
            }
            Some(DECORRELATED) => {
                self.expect_keywords(&[PLAN, FOR])?;
                ExplainStage::DecorrelatedPlan
            }
            Some(OPTIMIZED) => {
                if self.parse_keyword(QUERY) {
                    self.expect_keywords(&[GRAPH, FOR])?;
                    ExplainStage::OptimizedQueryGraph
                } else {
                    self.expect_keywords(&[PLAN, FOR])?;
                    ExplainStage::OptimizedPlan
                }
            }
            Some(PLAN) => {
                self.expect_keyword(FOR)?;
                ExplainStage::OptimizedPlan
            }
            Some(PHYSICAL) => {
                self.expect_keywords(&[PLAN, FOR])?;
                ExplainStage::PhysicalPlan
            }
            Some(TIMESTAMP) => {
                self.expect_keywords(&[FOR])?;
                ExplainStage::Timestamp
            }
            None => ExplainStage::OptimizedPlan,
            _ => unreachable!(),
        };
        // VIEW view_name | query
        let explainee = if self.parse_keyword(VIEW) {
            Explainee::View(self.parse_raw_name()?)
        } else {
            Explainee::Query(self.parse_query()?)
        };
        let options = ExplainOptions { typed, timing };
        Ok(Statement::Explain(ExplainStatement {
            stage,
            explainee,
            options,
        }))
    }
fn parse_explain ( & mut self ) -> Result < Statement < Raw > , ParserError > { // (TYPED)? let typed = self . parse_keyword ( TYPED ) ; let mut timing = false ; // options: ( '(' TIMING (true|false) ')' )? if let Some ( Token :: LParen ) = self . peek_token ( ) { // Check whether a valid option is after the parentheses, since the // parentheses may belong to the actual query to be explained. match self . peek_nth_token ( 1 ) { Some ( Token :: Keyword ( TIMING ) ) => { self . next_token ( ) ; // Consume the LParen self . parse_comma_separated ( | s | match s . expect_one_of_keywords ( & [ TIMING ] ) ? { TIMING => { timing = s . parse_boolean_value ( ) ? ; Ok ( ( ) ) } _ => unreachable ! ( ) , } ) ? ; self . expect_token ( & Token :: RParen ) ? ; } _ => { } } } // (RAW | DECORRELATED | OPTIMIZED | PHYSICAL)? PLAN let stage = match self . parse_one_of_keywords ( & [ RAW , DECORRELATED , OPTIMIZED , PHYSICAL , PLAN , QUERY , TIMESTAMP , ] ) { Some ( RAW ) => { self . expect_keywords ( & [ PLAN , FOR ] ) ? ; ExplainStage :: RawPlan } Some ( QUERY ) => { self . expect_keywords ( & [ GRAPH , FOR ] ) ? ; ExplainStage :: QueryGraph } Some ( DECORRELATED ) => { self . expect_keywords ( & [ PLAN , FOR ] ) ? ; ExplainStage :: DecorrelatedPlan } Some ( OPTIMIZED ) => { if self . parse_keyword ( QUERY ) { self . expect_keywords ( & [ GRAPH , FOR ] ) ? ; ExplainStage :: OptimizedQueryGraph } else { self . expect_keywords ( & [ PLAN , FOR ] ) ? ; ExplainStage :: OptimizedPlan } } Some ( PLAN ) => { self . expect_keyword ( FOR ) ? ; ExplainStage :: OptimizedPlan } Some ( PHYSICAL ) => { self . expect_keywords ( & [ PLAN , FOR ] ) ? ; ExplainStage :: PhysicalPlan } Some ( TIMESTAMP ) => { self . expect_keywords ( & [ FOR ] ) ? ; ExplainStage :: Timestamp } None => ExplainStage :: OptimizedPlan , _ => unreachable ! ( ) , } ; // VIEW view_name | query let explainee = if self . parse_keyword ( VIEW ) { Explainee :: View ( self . parse_raw_name ( ) ? ) } else { Explainee :: Query ( self . parse_query ( ) ? ) } ; let options = ExplainOptions { typed , timing } ; Ok ( Statement :: Explain ( ExplainStatement { stage , explainee , options , } ) ) }
Parse an `EXPLAIN` statement, assuming that the `EXPLAIN` token
has already been consumed.
Parse an ` EXPLAIN ` statement assuming that the ` EXPLAIN ` token has already been consumed .
&mut self
&mut self