| Crates.io | oak-wit |
| lib.rs | oak-wit |
| version | 0.0.1 |
| created_at | 2025-10-21 17:40:36.659379+00 |
| updated_at | 2026-01-23 05:22:42.255514+00 |
| description | WebAssembly Interface Types (WIT) component parser with support for interface definitions and component model. |
| homepage | https://github.com/ygg-lang/oaks |
| repository | https://github.com/ygg-lang/oaks |
| max_upload_size | |
| id | 1894197 |
| size | 49,040 |
High-performance incremental WIT Component parser for the oak ecosystem with flexible configuration, optimized for WebAssembly Interface Types processing.
Oak WIT Component is a robust parser for WIT (WebAssembly Interface Types) components, designed to handle complete WIT syntax including modern specifications. Built on the solid foundation of oak-core, it provides both high-level convenience and detailed AST generation for WebAssembly component analysis and code generation.
Basic example:
use oak_wit_component::{Parser, WitComponentLanguage, SourceText};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let parser = Parser::new();
let source = SourceText::new(r#"
package example:calculator;
interface calculator {
add: func(a: f32, b: f32) -> f32;
subtract: func(a: f32, b: f32) -> f32;
}
world calculator-world {
import calculator;
}
"#);
let result = parser.parse(&source);
println!("Parsed WIT Component successfully.");
Ok(())
}
use oak_wit_component::{Parser, WitComponentLanguage, SourceText};
let parser = Parser::new();
let source = SourceText::new(r#"
interface math {
add: func(a: f64, b: f64) -> f64;
multiply: func(a: f64, b: f64) -> f64;
}
"#);
let result = parser.parse(&source);
println!("Interface parsed successfully.");
use oak_wit_component::{Parser, WitComponentLanguage, SourceText};
let parser = Parser::new();
let source = SourceText::new(r#"
world example {
import wasi:clocks/monotonic-clock@0.2.0;
export example:interface;
}
"#);
let result = parser.parse(&source);
println!("World parsed successfully.");
use oak_wit_component::{Parser, WitComponentLanguage, SourceText};
let parser = Parser::new();
let source = SourceText::new("interface test { func: func(); }");
let result = parser.parse(&source);
println!("Token parsing completed.");
use oak_wit_component::{Parser, WitComponentLanguage, SourceText};
let parser = Parser::new();
let source = SourceText::new(r#"
interface invalid {
func: func(a: f32
// Missing closing parenthesis
"#);
let result = parser.parse(&source);
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 WIT Component 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.