Oak Bash Parser
High-performance incremental Bash parser for the oak ecosystem with flexible configuration, optimized for script analysis and automation.
🎯 Overview
Oak Bash is a robust parser for Bash, designed to handle complete Bash syntax including modern features like conditionals, loops, and functions. Built on the solid foundation of oak-core, it provides both high-level convenience and detailed AST generation for script analysis and automation.
✨ Features
- Complete Bash Syntax: Supports all Bash 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
Script Parsing
use ;
let parser = new;
let source = new;
let result = parser.parse;
println!;
Command 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;
// Token information is available in the parse result
Error Handling
use ;
let parser = new;
let source = new;
let result = parser.parse;
if let Err = result.result
🏗️ AST Structure
The parser generates a comprehensive AST with the following main structures:
- Script: Root container for Bash scripts
- Command: Simple commands, pipelines, conditionals, loops
- Expression: Arithmetic, string, file test expressions
- Word: Literal words, variables, command substitutions
📊 Performance
- Streaming: Parse large Bash 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 Bash integrates seamlessly with:
- Shell Scripting Tools: Integration with linters, formatters
- Automation: Parsing scripts for automated tasks
- IDE Support: Language server protocol compatibility
- Security Analysis: Analyzing scripts for vulnerabilities
📚 Examples
Check out the examples directory for comprehensive examples:
- Complete Bash script parsing
- Command and expression analysis
- Code transformation
- Integration with development workflows
🤝 Contributing
Contributions are welcome!
Please feel free to submit pull requests at the project repository or open issues.