Oak Fortran Parser
High-performance incremental Fortran parser for the oak ecosystem with flexible configuration, optimized for code analysis and compilation.
🎯 Overview
Oak Fortran is a robust parser for Fortran, designed to handle complete Fortran 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 Fortran Syntax: Supports all Fortran 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
Program Parsing
use ;
let parser = new;
let source = new;
let result = parser.parse;
println!;
Subroutine Parsing
use ;
let parser = new;
let source = new;
let result = parser.parse;
println!;
Function 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:
- Program: Root container for Fortran programs
- Subroutine: Subroutine definitions
- Function: Function definitions
- Module: Module definitions
- Statement: Various statement types including control flow
- Expression: Various expression types including operators
📊 Performance
- Streaming: Parse large Fortran 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 Fortran integrates seamlessly with:
- Compilers: Front-end for Fortran compilers
- Static Analysis Tools: Code quality and security analysis
- IDE Support: Language server protocol compatibility
- Code Generation: Generating code from AST
📚 Examples
Check out the examples directory for comprehensive examples:
- Complete Fortran program parsing
- Subroutine and function 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.