Oak JASM Parser
High-performance incremental JASM parser for the oak ecosystem with flexible configuration, optimized for assembly language analysis and JVM bytecode generation.
🎯 Overview
Oak JASM is a robust parser for Java ASseMbler (JASM), designed to handle complete JASM syntax including modern assembly features and JVM bytecode instructions. Built on the solid foundation of oak-core, it provides both high-level convenience and detailed AST generation for JASM analysis and tooling.
✨ Features
- Complete JASM Syntax: Supports all JASM features including class definitions, methods, and bytecode instructions
- JVM Bytecode Support: Handles all JVM bytecode instructions and type descriptors
- 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
Class Definition Parsing
use ;
use ;
let mut session = default;
let parser = new;
let source = new;
let result = parser.parse;
println!;
Method with Control Flow
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:
- Class: JASM class definitions with access modifiers and inheritance
- Field: Field definitions with types and access modifiers
- Method: Method definitions with signatures and bytecode instructions
- Instruction: JVM bytecode instructions with operands
- Constant: Constant pool entries for strings, numbers, and references
📊 Performance
- Streaming: Parse large JASM 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-jasm integrates seamlessly with:
- Bytecode Analysis: Security analysis and optimization of JVM bytecode
- Code Generation: Generating bytecode from high-level languages
- IDE Support: Language server protocol compatibility for assembly languages
- Debugging Tools: Debuggers and profilers for JVM applications
- Documentation: Generating documentation from assembly code
📚 Examples
Check out the examples directory for comprehensive examples:
- Complete JASM class parsing
- Method and instruction analysis
- Control flow and exception handling
- Integration with development workflows
🤝 Contributing
Contributions are welcome!
Please feel free to submit pull requests at the project repository or open issues.