| Crates.io | oak-jasm |
| lib.rs | oak-jasm |
| version | 0.0.1 |
| created_at | 2025-10-21 01:31:26.68492+00 |
| updated_at | 2026-01-23 04:29:46.64526+00 |
| description | JASM assembly language parser with support for modern assembly syntax and features. |
| homepage | https://github.com/ygg-lang/oaks |
| repository | https://github.com/ygg-lang/oaks |
| max_upload_size | |
| id | 1893101 |
| size | 136,838 |
High-performance incremental JASM parser for the oak ecosystem with flexible configuration, optimized for assembly language analysis and JVM bytecode generation.
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.
Basic example:
use oak_core::{Parser, SourceText, parser::session::ParseSession};
use oak_jasm::{JasmParser, JasmLanguage};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut session = ParseSession::<JasmLanguage>::default();
let parser = JasmParser::new();
let source = SourceText::new(r#"
.class public Hello
.super java/lang/Object
.method public <init>()V
aload_0
invokespecial java/lang/Object/<init>()V
return
.end method
.method public static main([Ljava/lang/String;)V
.limit stack 2
getstatic java/lang/System/out Ljava/io/PrintStream;
ldc "Hello, JASM!"
invokevirtual java/io/PrintStream/println(Ljava/lang/String;)V
return
.end method
.end class
"#);
let result = parser.parse(&source, &[], &mut session);
println!("Parsed JASM class successfully.");
Ok(())
}
use oak_core::{Parser, SourceText, parser::session::ParseSession};
use oak_jasm::{JasmParser, JasmLanguage};
let mut session = ParseSession::<JasmLanguage>::default();
let parser = JasmParser::new();
let source = SourceText::new(r#"
.class public Calculator
.super java/lang/Object
.field private result I
.method public <init>()V
aload_0
invokespecial java/lang/Object/<init>()V
aload_0
iconst_0
putfield Calculator/result I
return
.end method
.method public add(I)V
aload_0
dup
getfield Calculator/result I
iload_1
iadd
putfield Calculator/result I
return
.end method
.end class
"#);
let result = parser.parse(&source, &[], &mut session);
println!("Parsed JASM class with fields and methods successfully.");
use oak_core::{Parser, SourceText, parser::session::ParseSession};
use oak_jasm::{JasmParser, JasmLanguage};
let mut session = ParseSession::<JasmLanguage>::default();
let parser = JasmParser::new();
let source = SourceText::new(r#"
.class public LoopExample
.super java/lang/Object
.method public static count(I)V
.limit locals 2
iconst_0
istore_1
Loop:
iload_1
iload_0
if_icmpge End
getstatic java/lang/System/out Ljava/io/PrintStream;
iload_1
invokevirtual java/io/PrintStream/println(I)V
iinc 1 1
goto Loop
End:
return
.end method
.end class
"#);
let result = parser.parse(&source, &[], &mut session);
println!("Parsed JASM with control flow successfully.");
use oak_core::{Parser, SourceText, parser::session::ParseSession};
use oak_jasm::{JasmParser, JasmLanguage};
let mut session = ParseSession::<JasmLanguage>::default();
let parser = JasmParser::new();
let source = SourceText::new(".class public MyClass");
let result = parser.parse(&source, &[], &mut session);
println!("Token parsing completed.");
use oak_core::{Parser, SourceText, parser::session::ParseSession};
use oak_jasm::{JasmParser, JasmLanguage};
let mut session = ParseSession::<JasmLanguage>::default();
let parser = JasmParser::new();
let source = SourceText::new(r#"
.class public Broken
# Missing super class or methods
"#);
let result = parser.parse(&source, &[], &mut session);
if let Some(errors) = result.result.err() {
println!("Parse errors found: {:?}", errors);
} else {
println!("Parsed successfully.");
}
The parser generates a comprehensive AST with the following main structures:
Oak-jasm integrates seamlessly with:
Check out the examples directory for comprehensive examples:
Contributions are welcome!
Please feel free to submit pull requests at the project repository or open issues.