qail_core/parser/
mod.rs

1//! QAIL Parser using nom.
2//!
3//! Parses QAIL v2 keyword-based syntax into an AST.
4//!
5//! # Syntax Overview
6//!
7//! ```text
8//! get users
9//! fields id, email
10//! where active = true
11//! order by created_at desc
12//! limit 10
13//! ```
14
15pub mod grammar;
16pub mod schema;
17pub mod query_file;
18
19#[cfg(test)]
20mod tests;
21
22use crate::ast::*;
23use crate::error::{QailError, QailResult};
24
25/// Parse a complete QAIL query string (v2 syntax only).
26/// 
27/// Uses keyword-based syntax: `get table fields * where col = value`
28pub fn parse(input: &str) -> QailResult<QailCmd> {
29    let input = input.trim();
30    
31    match grammar::parse_root(input) {
32        Ok(("", cmd)) => Ok(cmd),
33        Ok((remaining, _)) => Err(QailError::parse(
34            input.len() - remaining.len(),
35            format!("Unexpected trailing content: '{}'", remaining),
36        )),
37        Err(e) => Err(QailError::parse(0, format!("Parse failed: {:?}", e))),
38    }
39}
40