Skip to content

Commit e69c33d

Browse files
committed
docs: Add Embedding SDK section to main README
Add section showcasing zyntax_embed usage with: - Basic LanguageGrammar and ZyntaxRuntime example - Native function registration with with_symbols() - Feature highlights (multi-tier JIT, value conversion, plugins) - Link to full documentation
1 parent f6968e5 commit e69c33d

1 file changed

Lines changed: 42 additions & 0 deletions

File tree

README.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,48 @@ assert_eq!(result, 42);
354354

355355
**Status:****Production-ready** - Full SSA-based IR construction with type system integration
356356

357+
### ✅ Embedding SDK - Embed Zyntax in Your Application
358+
359+
Use `zyntax_embed` to embed the Zyntax JIT runtime in Rust applications:
360+
361+
```rust
362+
use zyntax_embed::{ZyntaxRuntime, LanguageGrammar};
363+
364+
// Load a grammar and create runtime
365+
let grammar = LanguageGrammar::compile_zyn_file("grammars/zig.zyn")?;
366+
let mut runtime = ZyntaxRuntime::new()?;
367+
368+
// Compile and run code
369+
runtime.compile_with_grammar(&grammar, r#"
370+
pub fn add(a: i32, b: i32) i32 {
371+
return a + b;
372+
}
373+
"#)?;
374+
375+
let result: i32 = runtime.call("add", &[10.into(), 32.into()])?;
376+
println!("Result: {}", result); // 42
377+
```
378+
379+
**Register native functions:**
380+
381+
```rust
382+
extern "C" fn native_print(x: i32) { println!("{}", x); }
383+
384+
let symbols = &[("native_print", native_print as *const u8)];
385+
let mut runtime = ZyntaxRuntime::with_symbols(symbols)?;
386+
```
387+
388+
**Features:**
389+
- Multi-tier JIT compilation (Cranelift baseline → LLVM optimized)
390+
- Bidirectional Rust ↔ Zyntax value conversion
391+
- External function registration for native interop
392+
- ZRTL plugin loading for runtime libraries
393+
- Async/await with Promise API
394+
395+
**Status:****Production-ready** - Full embedding API with grammar support
396+
397+
See [Embedding SDK Documentation](./book/12-embedding-sdk.md) for complete guide.
398+
357399
### 🔜 Other Integrations
358400

359401
- **Whirlwind** - Direct AST adapter (in progress)

0 commit comments

Comments
 (0)