Oak Scala Parser
High-performance incremental Scala parser for the oak ecosystem with flexible configuration, optimized for static analysis and code generation.
🎯 Overview
Oak Scala is a robust parser for Scala, designed to handle complete Scala syntax including modern features. Built on the solid foundation of oak-core, it provides both high-level convenience and detailed AST generation for static analysis and code generation.
✨ Features
- Complete Scala Syntax: Supports all Scala 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 ;
use ;
📋 Parsing Examples
Object Parsing
use ;
use ;
let mut session = default;
let parser = new;
let source = new;
let result = parser.parse;
println!;
Class Parsing
use ;
use ;
let mut session = default;
let parser = new;
let source = new;
let result = parser.parse;
println!;
🔧 Advanced Features
Token-Level Parsing
use ;
use ;
let mut session = default;
let parser = new;
let source = new;
let result = parser.parse;
println!;
Error Handling
use ;
use ;
let mut session = default;
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:
- ScalaProgram: Root container for Scala programs
- Object: Scala object definitions
- Class: Scala class definitions
- Method: Scala methods and functions
- Statement: Various statement types including control flow
- Expression: Various expression types including operators
- Type: Scala type system constructs
📊 Performance
- Streaming: Parse large Scala 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 Scala integrates seamlessly with:
- Static Analysis: Code quality and security analysis
- Code Generation: Generating code from Scala AST
- IDE Support: Language server protocol compatibility
- Refactoring: Automated code refactoring
- Documentation: Generating documentation from Scala code
📚 Examples
Check out the examples directory for comprehensive examples:
- Complete Scala program parsing
- Object and class 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.