Oak Pascal Parser
High-performance incremental Pascal parser for the oak ecosystem with flexible configuration, optimized for legacy code analysis and educational purposes.
🎯 Overview
Oak Pascal is a robust parser for Pascal, designed to handle complete Pascal syntax including legacy and modern features. Built on the solid foundation of oak-core, it provides both high-level convenience and detailed AST generation for code analysis and educational purposes.
✨ Features
- Complete Pascal Syntax: Supports all Pascal features including legacy 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!;
Procedure 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:
- PascalProgram: Root container for Pascal programs
- Procedure: Procedure declarations
- Function: Function declarations
- Variable: Variable declarations with types
- Statement: Various statement types (assignment, if, while, for, etc.)
- Expression: Arithmetic, logical, and relational expressions
📊 Performance
- Streaming: Parse large Pascal 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 Pascal integrates seamlessly with:
- Legacy Code Analysis: Analyze and understand legacy Pascal codebases
- Educational Tools: Build programming language learning platforms
- IDE Support: Language server protocol compatibility
- Documentation Tools: Extract documentation from Pascal source code
- Migration Tools: Convert Pascal code to other languages
📚 Examples
Check out the examples directory for comprehensive examples:
- Complete Pascal program parsing
- Procedure and function analysis
- Variable and type extraction
- Integration with development workflows
🤝 Contributing
Contributions are welcome!
Please feel free to submit pull requests at the project repository or open issues.