Expand description
The grammar-extension guest world (PH7.7b).
A grammar plugin implements the grammar-plugin world: it imports the
grammar register API (host-provided) and exports register-grammar
(the host calls it once to drive registration) + the grammar-callbacks
behaviors (apply-* / parse-ex-args, dispatched by callback-id). This
module holds the fourth bindgen! (after plugin, picker-source-plugin,
completion-source-plugin) for that world — the two-bindgen-with-shared-types
trick (with: points types at the plugin world’s generated module so a
crossed value is the SAME Rust type WitBoundary round-trips, the PH7.3d
precedent).
Fully synchronous (the PH7.7 fork). Unlike picker/completion, a grammar
apply resolves on the keystroke path — a motion must return inline to
compose with its operator (async would break operator∘motion atomicity +
dot-repeat/macros). So the bindgen! sets no exports: { default: async }:
the register-grammar + grammar-callbacks exports are sync-callable from the
dispatch thread, bounded by fuel + epoch (a Reflex-class budget, PH7.7c). No
actor task — the sync trampoline calls the guest directly (PH7.7c).
Registration flow: the host calls the guest’s register-grammar export; the
guest calls the imported register-* host functions; those record into the
Store’s GrammarContributions (via the grammar::Host impl on
PluginState, lib.rs); after the export returns, the host drains the
contributions and builds native *Specs with trampoline applys (PH7.7c).
Structs§
- Grammar
Contributions - The per-plugin accumulator the
grammar::Hostimpl records into duringregister-grammar(lib.rs). Held inPluginState; drained by the host after the registration export returns (PH7.7c). Therecord_*methods are the sync host-func bodies (they only push — they cannot trap), factored here (thehost_services::walk_within_grantprecedent) so the recording logic is unit-testable without aPluginState/ guest.
Enums§
- Recorded
Contribution - One grammar contribution a plugin declared through the
register-*API, recorded verbatim (name + doc + WIT spec metadata + the guest’s callback id). The host drains these afterregister-grammarreturns and builds a native*Specwith a trampolineapply/parse_argsstampedSourceLayer::Plugin(PH7.7c). The WIT spec is held as-is — its scalar fields convert at drain time viaboundary_grammar(LatencyClass/SurfaceForm) + the existingArgSpecmirror; the native*Speccannot be built until the trampoline closure exists.