Skip to content

Commit 2881f58

Browse files
committed
docs: Simplify DSL plugin loading example
The chart plugin uses zrtl_paint internally via Rust crate imports, so users only need to load zrtl_chart - not paint/window separately. Add note explaining the recommended pattern: DSL plugins should encapsulate their dependencies and expose only domain-specific symbols.
1 parent 089bd54 commit 2881f58

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

book/15-building-dsls.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -506,10 +506,11 @@ style {
506506
#### Option A: Via CLI
507507

508508
```bash
509-
# Run a chart program with required plugins
509+
# Run a chart program - only need the chart plugin
510+
# (it uses zrtl_paint internally via Rust imports)
510511
zyntax compile --grammar chart.zyn \
511512
--source sales_report.chart \
512-
--plugins zrtl_chart,zrtl_paint,zrtl_window \
513+
--plugins zrtl_chart \
513514
--run
514515
```
515516

@@ -521,10 +522,8 @@ use zyntax_embed::{ZyntaxRuntime, LanguageGrammar};
521522
fn main() -> Result<(), Box<dyn std::error::Error>> {
522523
let mut runtime = ZyntaxRuntime::new()?;
523524

524-
// Load the chart plugin and its dependencies
525+
// Load only the chart plugin - it handles paint/window internally
525526
runtime.load_plugin("plugins/target/zrtl/zrtl_chart.zrtl")?;
526-
runtime.load_plugin("plugins/target/zrtl/zrtl_paint.zrtl")?;
527-
runtime.load_plugin("plugins/target/zrtl/zrtl_window.zrtl")?;
528527

529528
// Load ChartLang grammar
530529
let grammar = LanguageGrammar::compile_zyn(include_str!("chart.zyn"))?;
@@ -539,6 +538,8 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
539538
}
540539
```
541540

541+
Note: The `zrtl_chart` plugin uses `zrtl_paint` internally via Rust crate dependencies (not runtime symbol lookup). This is the recommended pattern for DSL plugins - they encapsulate their dependencies and expose only domain-specific symbols like `$Chart$set_type`.
542+
542543
The key insight: `zrtl_plugin!` **defines** what symbols a plugin exports. The runtime **loads** plugins at startup using `load_plugin()` or via the CLI `--plugins` flag. Your DSL grammar then calls those symbols (e.g., `$Chart$set_type`).
543544

544545
## Advanced Patterns

0 commit comments

Comments
 (0)