pub fn expect_select<'t>(tokens: &'t [Token]) -> ExpectResult<'t, SelectStatement> {
    let ExpectOk {
        rest,
        tokens_consumed_count: tokens_consumed_columns,
        outcome: columns,
    } = expect_comma_separated(tokens, expect_select_column)?;
    let ExpectOk { rest, .. } = expect_token_value(rest, &TokenValue::Const(Keyword::From))?;
    let ExpectOk {
        rest,
        tokens_consumed_count: tokens_consumed_count_table_name,
        outcome: table_name,
    } = expect_identifier(rest)?;
    let ExpectOk {
        rest,
        tokens_consumed_count: tokens_consumed_count_where_clause,
        outcome: maybe_where_clause,
    } = detect(
        rest,
        |tokens| expect_token_value(tokens, &TokenValue::Const(Keyword::Where)),
        expect_expression,
        &"WHERE conditions",
    )?;
    Ok(ExpectOk {
        rest,
        tokens_consumed_count: 1 // +1 to account for FROM
            + tokens_consumed_columns
            + tokens_consumed_count_table_name + tokens_consumed_count_where_clause,
        outcome: SelectStatement {
            columns,
            source: table_name,
            where_clause: maybe_where_clause.and_then(|(_, where_clause)| Some(where_clause)),
        },
    })
}
/// Conjure an SelectStatement from tokens following SELECT.
Conjure an SelectStatement from tokens following SELECT.
Conjure an SelectStatement from tokens following SELECT .
pub fn expect_select<'t>(tokens: &'t [Token]) -> ExpectResult<'t, SelectStatement> {
    let ExpectOk {
        rest,
        tokens_consumed_count: tokens_consumed_columns,
        outcome: columns,
    } = expect_comma_separated(tokens, expect_select_column)?;
    let ExpectOk { rest, .. } = expect_token_value(rest, &TokenValue::Const(Keyword::From))?;
    let ExpectOk {
        rest,
        tokens_consumed_count: tokens_consumed_count_table_name,
        outcome: table_name,
    } = expect_identifier(rest)?;
    let ExpectOk {
        rest,
        tokens_consumed_count: tokens_consumed_count_where_clause,
        outcome: maybe_where_clause,
    } = detect(
        rest,
        |tokens| expect_token_value(tokens, &TokenValue::Const(Keyword::Where)),
        expect_expression,
        &"WHERE conditions",
    )?;
    Ok(ExpectOk {
        rest,
        tokens_consumed_count: 1 // +1 to account for FROM
            + tokens_consumed_columns
            + tokens_consumed_count_table_name + tokens_consumed_count_where_clause,
        outcome: SelectStatement {
            columns,
            source: table_name,
            where_clause: maybe_where_clause.and_then(|(_, where_clause)| Some(where_clause)),
        },
    })
}
pub fn expect_select < ' t > ( tokens : & ' t [ Token ] ) -> ExpectResult < ' t , SelectStatement > { let ExpectOk { rest , tokens_consumed_count : tokens_consumed_columns , outcome : columns , } = expect_comma_separated ( tokens , expect_select_column ) ? ; let ExpectOk { rest , .. } = expect_token_value ( rest , & TokenValue :: Const ( Keyword :: From ) ) ? ; let ExpectOk { rest , tokens_consumed_count : tokens_consumed_count_table_name , outcome : table_name , } = expect_identifier ( rest ) ? ; let ExpectOk { rest , tokens_consumed_count : tokens_consumed_count_where_clause , outcome : maybe_where_clause , } = detect ( rest , | tokens | expect_token_value ( tokens , & TokenValue :: Const ( Keyword :: Where ) ) , expect_expression , & " " , ) ? ; Ok ( ExpectOk { rest , tokens_consumed_count : 1 // +1 to account for FROM + tokens_consumed_columns + tokens_consumed_count_table_name + tokens_consumed_count_where_clause , outcome : SelectStatement { columns , source : table_name , where_clause : maybe_where_clause . and_then ( | ( _ , where_clause ) | Some ( where_clause ) ) , } , } ) }
Conjure an SelectStatement from tokens following SELECT.
Conjure an SelectStatement from tokens following SELECT .
tokens
&'t [Token]