Oak Regex Parser
High-performance incremental regular expression parser for the oak ecosystem with flexible configuration, optimized for pattern matching and text processing.
🎯 Overview
Oak Regex is a robust parser for regular expressions, designed to handle complete regex syntax including modern features. Built on the solid foundation of oak-core, it provides both high-level convenience and detailed AST generation for pattern matching and text processing.
✨ Features
- Complete Regex Syntax: Supports all regex features including modern specifications
- Full AST Generation: Generates comprehensive Abstract Syntax Trees
- Lexer Support: Built-in tokenization with proper span information
- Error Recovery: Graceful handling of syntax errors with detailed diagnostics
🚀 Quick Start
Basic example:
use ;
📋 Parsing Examples
Email Pattern Parsing
use ;
let parser = new;
let source = new;
let result = parser.parse;
println!;
Complex Pattern Parsing
use ;
let parser = new;
let source = new;
let result = parser.parse;
println!;
Group and Alternation Parsing
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:
- RegexRoot: Root container for regular expressions
- Alternation: Alternation expressions (|)
- Group: Grouping expressions (capturing and non-capturing)
- Quantifier: Quantifiers (?, *, +, {n,m})
- CharacterClass: Character classes and ranges
- Assertion: Assertions (^, $, \b, \B, lookaround)
- Literal: Literal characters and escaped sequences
📊 Performance
- Streaming: Parse large regex patterns 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 Regex integrates seamlessly with:
- Text Processing: Pattern matching and text extraction
- Validation: Input validation and sanitization
- IDE Support: Syntax highlighting and autocompletion for regex
- Code Generation: Generating code from regex patterns
- Static Analysis: Analyzing regex patterns for optimization
📚 Examples
Check out the examples directory for comprehensive examples:
- Complete regex pattern parsing
- Complex pattern analysis
- Pattern optimization
- Integration with text processing workflows
🤝 Contributing
Contributions are welcome!
Please feel free to submit pull requests at the project repository or open issues.