Oak RBQ Parser
High-performance incremental RBQ (Rusty Brief Query) parser for the oak ecosystem with flexible configuration, optimized for data modeling and query analysis.
🎯 Overview
Oak RBQ is a robust parser for RBQ, a declarative data modeling and query language designed for the Rust ecosystem. Built on the solid foundation of oak-core, it provides both high-level convenience and detailed AST generation for domain-driven design and database schema management.
✨ Features
- Declarative Modeling: Support for
namespace,struct, andenumdefinitions. - Annotation System: Built-in support for
@table,@primary_key,@relation, etc. - Type Safety: Strong typing with support for
List<T>,Option<T>, and domain-specific types. - Full AST Generation: Generates comprehensive Abstract Syntax Trees.
- Error Recovery: Graceful handling of syntax errors with detailed diagnostics.
🚀 Quick Start
Basic example:
use ;
📋 Modeling Examples
Struct and Enum Definitions
use ;
let parser = new;
let source = new;
let result = parser.parse;
println!;
🔧 Advanced Features
Token-Level Parsing
use ;
let parser = new;
let source = new;
let result = parser.parse;
println!;
Error Handling
use ;
let parser = new;
let source = new;
let result = parser.parse;
if let Some = result.result.err else
🏗️ AST Structure
The parser generates a comprehensive AST with the following main structures:
- SelectStatement: SELECT queries with columns, tables, conditions
- InsertStatement: INSERT statements with table and values
- UpdateStatement: UPDATE statements with table, sets, and conditions
- DeleteStatement: DELETE statements with table and conditions
- CreateTableStatement: CREATE TABLE statements with schema definitions
- Expression: Various expression types (comparison, logical, arithmetic)
📊 Performance
- Streaming: Parse large SQL files without loading entirely into memory
- Incremental: Re-parse only changed sections
- Memory Efficient: Smart AST node allocation
- Fast Recovery: Quick error recovery for better IDE integration
🔗 Integration
Oak SQL integrates seamlessly with:
- Database Tools: Build SQL query analyzers and optimizers
- IDE Support: Language server protocol compatibility for SQL
- Migration Tools: Analyze and transform database schemas
- Query Builders: Generate SQL from AST representations
- Data Analysis: Extract information from SQL queries
📚 Examples
Check out the examples directory for comprehensive examples:
- Complete SQL statement parsing
- Query analysis and optimization
- Schema extraction and validation
- Integration with development workflows
🤝 Contributing
Contributions are welcome!
Please feel free to submit pull requests at the project repository or open issues.