orql 0.1.0

A toy SQL parser for a subset of the Oracle dialect.
Documentation
use std::ops::Deref;

use super::{Node, Select};

/// A parsed SQL statement
#[derive(Debug)]
pub struct Statement<'s, ID> {
    /// the statement itself
    pub statement: StatementType<'s, ID>,
    /// the terminating semicolong, if any. e.g. `;` or end-of-file
    // XXX may need to include the type of the terminal in future, e.g. `;` or `/`
    pub terminator: Option<Node<(), ID>>,
}

impl<'s, ID> Deref for Statement<'s, ID> {
    type Target = StatementType<'s, ID>;

    fn deref(&self) -> &Self::Target {
        &self.statement
    }
}

/// A SQL statement
#[derive(Debug)]
pub enum StatementType<'s, ID> {
    /// An empty statements, e.g. a single `;` on its own,
    /// possibly associated with comments
    Empty,

    /// A query statement, e.g. `SELECT * FROM dual`
    ///
    /// See <https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/SELECT.html>
    // XXX consider putting into a `Box<...>`
    Select(Box<Select<'s, ID>>),
    // XXX Insert
    // XXX Update
    // XXX Delete
    // XXX Merge
}