Oak Lean Parser
High-performance incremental Lean parser for the oak ecosystem with flexible configuration, optimized for theorem proving and formal verification.
🎯 Overview
Oak Lean is a robust parser for Lean theorem prover, designed to handle complete Lean syntax including modern features. Built on the solid foundation of oak-core, it provides both high-level convenience and detailed AST generation for theorem proving and formal verification.
✨ Features
- Complete Lean Syntax: Supports all Lean 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
Definition Parsing
use ;
let parser = new;
let source = new;
let result = parser.parse;
println!;
Inductive Type 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:
- LeanProgram: Root container for Lean programs
- Definition: Lean function and constant definitions
- Theorem: Lean theorem statements and proofs
- Inductive: Lean inductive type definitions
- Structure: Lean structure/record definitions
- Expression: Lean expressions and terms
- TacticBlock: Lean tactic proof blocks
📊 Performance
- Streaming: Parse large Lean 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 Lean integrates seamlessly with:
- Theorem Proving: Lean code analysis and verification
- Formal Verification: Processing and transforming Lean proofs
- IDE Support: Language server protocol compatibility
- Code Generation: Generating code from Lean AST
- Documentation: Generating documentation from Lean code
📚 Examples
Check out the examples directory for comprehensive examples:
- Complete Lean program parsing
- Definition and theorem analysis
- Proof transformation
- Integration with development workflows
🤝 Contributing
Contributions are welcome!
Please feel free to submit pull requests at the project repository or open issues.