pub struct Multi<LS: Languages, MS: MetaLanguages> {
pub langs: LS,
pub metas: MS,
pub machines: Park,
}Fields§
§langs: LS§metas: MS§machines: ParkLive default machines, one per language, spawned on first use by
machine — so successive reduces share definitions
for as long as this Multi lives. See docs/design/machines.md.
Implementations§
Source§impl<LS: Languages, MS: MetaLanguages> Multi<LS, MS>
impl<LS: Languages, MS: MetaLanguages> Multi<LS, MS>
pub fn get_lang(&self, lang: &str) -> Result<&LS::Language>
pub fn get_lang_mut(&mut self, lang: &str) -> Result<&mut LS::Language>
pub fn get_meta(&self, lang: &str) -> Result<&MS::MetaLanguage>
pub fn get_meta_mut(&mut self, lang: &str) -> Result<&mut MS::MetaLanguage>
pub fn lift_str(&self, lang: &str, target: &str) -> Result<&'static str>
pub fn reduce_str(&self, lang: &str, target: &str) -> Result<&'static str>
pub fn reduce_method_str( &self, lang: &str, target: &str, ) -> Result<&'static str>
pub fn emit_str(&self, lang: &str) -> Result<&'static str>
Sourcepub fn prelude(&self, lang: &str, targets: &[&str]) -> Result<Option<Prelude>>
pub fn prelude(&self, lang: &str, targets: &[&str]) -> Result<Option<Prelude>>
The runtime import a file expanded with lang’s meta must open with
(issue #274), given the object languages it may lift into. See
MetaLanguage::prelude.
Sourcepub fn prelude_for(&self, chain: &[&str], input: &str) -> Option<Prelude>
pub fn prelude_for(&self, chain: &[&str], input: &str) -> Option<Prelude>
The runtime import the file expanded from input under chain (ground
language first) should open with, or None (issue #274). Paired with
with_prelude, this is what quilt expand
writes, and what the in-browser expander (quilt-expand-wasm) writes
too, so a generated module is runnable whichever of them produced it.
None for a host whose meta needs none (nix, lean and text generate no
runtime calls at all), and by the two rules that keep the injection from
becoming a footgun:
- The source uses no Quilt construct.
examples/hello.rs.quiltexpands to itself and must stay import-free: Rust tolerates an unused glob silently, but a Python or TypeScript linter will not. - The author already imported the runtime. Two identical globs are
harmless in Rust and Python, but a doubled named import is a hard
error in TypeScript — so this is checked rather than assumed. See
Prelude::present_in.
The targets the meta is asked about — which only a target-directed host
like TypeScript reads — are the language chain plus every annotation the
source’s quotes name, so that a sql↖…↗ inside a .rs.quilt counts even
though the chain never mentions SQL. It over-approximates: a language
listed but never lifted into costs an unused name, one missing costs a
name that is not in scope.
pub fn type_str(&self, lang: &str) -> Result<&'static str>
pub fn name_str(&self, lang: &str) -> Result<&'static str>
pub fn type_method_str(&self, lang: &str) -> Result<&'static str>
pub fn spawn_str(&self, lang: &str, target: &str) -> Result<String>
Sourcepub fn spawn_machine(&self, lang: &str) -> Result<Box<dyn Machine>>
pub fn spawn_machine(&self, lang: &str) -> Result<Box<dyn Machine>>
Spawn a fresh machine for lang: the persistent
ReplMachine when the language
declares a repl_spec, else the replay-based
ScriptMachine from its
machine_spec. The caller owns it: nothing
is parked, so it shares state with no other machine.
Sourcepub fn machine(&mut self, lang: &str) -> Result<&mut dyn Machine>
pub fn machine(&mut self, lang: &str) -> Result<&mut dyn Machine>
The default machine for lang: parked in
machines, spawned on first use, shared by every
caller of this Multi — which is what lets one reduce see the
definitions another fed. Keyed by the canonical language name, so
aliases (py / python) share one machine.
Sourcepub fn feed_on(
&mut self,
lang: &str,
kind: InnerKind,
src: &str,
) -> Result<Answer>
pub fn feed_on( &mut self, lang: &str, kind: InnerKind, src: &str, ) -> Result<Answer>
The end-user text door (tenet 2’s actual subject): parse src as
kind with lang’s Language — validating it — then feed the term
to the default machine. Machines themselves traffic only in terms;
raw text is turned into a term here, where the parser lives.
Sourcepub fn eval_on(&mut self, lang: &str, term: &QTerm) -> Result<Arc<QTerm>>
pub fn eval_on(&mut self, lang: &str, term: &QTerm) -> Result<Arc<QTerm>>
Evaluate a term on lang’s default machine and parse the answered
literal back into a term of lang — machines answer with the
value’s own syntax, and the Language re-reads it here, where it
lives.
Sourcepub fn classify_for_feed(&self, lang: &str, term: &QTerm) -> Result<InnerKind>
pub fn classify_for_feed(&self, lang: &str, term: &QTerm) -> Result<InnerKind>
Classify a term for feeding a machine — which message sort it is —
seeing through the tagless root wrapper parse_chain builds around a
parsed fragment (whose tag would otherwise classify by the language’s
default). The REPL and the notebook both route feeds through this.
pub fn parse(&mut self, s: &str) -> Result<Arc<QTerm>>
pub fn parse_lang(&mut self, lang: &str, s: &str) -> Result<Arc<QTerm>>
Sourcepub fn parse_chain(&mut self, chain: &[&str], s: &str) -> Result<Arc<QTerm>>
pub fn parse_chain(&mut self, chain: &[&str], s: &str) -> Result<Arc<QTerm>>
Parse s whose language is given by a chain of file extensions: the
host (ground) language first, then the default language for successively
nested un-annotated ↖…↗ quotes. This comes from a file name like
shaders.wgsl.rs.quilt (chain ["rs", "wgsl"]): Rust is the host and a
bare ↖…↗ defaults to WGSL. A single-element chain (["rs"]) is the
plain foo.rs.quilt case where bare quotes default to the host.
Sourcepub fn build_nodes(
&mut self,
builder: QTermBuilder,
hole: &Hole,
nodes: &[Arc<Node>],
zipper: &Zipper<Box<str>>,
splice_target: Option<&str>,
enclosing: Option<(&str, Repr)>,
bracketed: bool,
sky_depth: usize,
) -> Result<QTermBuilder>
pub fn build_nodes( &mut self, builder: QTermBuilder, hole: &Hole, nodes: &[Arc<Node>], zipper: &Zipper<Box<str>>, splice_target: Option<&str>, enclosing: Option<(&str, Repr)>, bracketed: bool, sky_depth: usize, ) -> Result<QTermBuilder>
Build a QTerm from quilt Nodes. splice_target is the language the
fragment’s value will be spliced into: Some only for unquote bodies
(the lang of the enclosing quote), None otherwise. It directs ↑ —
a lift inside wgsl↖ … ↙x.↑↘ … ↗ targets WGSL; elsewhere a lift is
homogeneous (targets the fragment’s own language). bracketed is true
when nodes is the body of a ↖…↗/↙…↘ pair and false at the top
level: only bracketed bodies get their boundary newlines trimmed.
sky_depth is the net quote nesting (quotes minus unquotes) at this
level: 0 at ground, +1 per enclosing quote, −1 per enclosing unquote.
An operator (↑/↓/←) at sky depth > 0 runs at a later stage, so
it is deferred (emitted as the glyph) rather than spelled out now.
enclosing is the language and Repr of the nearest quote around
nodes (None at the top): a bare quote inside its unquotes inherits
its representation, and a ↑/← there spells that representation’s.
pub fn expand(&mut self, qterm: &QTerm) -> Result<Arc<QTerm>>
pub fn expand_lang(&mut self, lang: &str, qterm: &QTerm) -> Result<Arc<QTerm>>
Source§impl Multi<DictLanguages, DictMetaLanguages>
impl Multi<DictLanguages, DictMetaLanguages>
pub fn add_lang( &mut self, lang: &str, language: <DictLanguages as Languages>::Language, )
pub fn add_meta( &mut self, lang: &str, meta: <DictMetaLanguages as MetaLanguages>::MetaLanguage, )
Trait Implementations§
Auto Trait Implementations§
impl<LS, MS> !RefUnwindSafe for Multi<LS, MS>
impl<LS, MS> !Sync for Multi<LS, MS>
impl<LS, MS> !UnwindSafe for Multi<LS, MS>
impl<LS, MS> Forget for Multi<LS, MS>
impl<LS, MS> Freeze for Multi<LS, MS>
impl<LS, MS> Move for Multi<LS, MS>
impl<LS, MS> Send for Multi<LS, MS>
impl<LS, MS> Unpin for Multi<LS, MS>
impl<LS, MS> UnsafeUnpin for Multi<LS, MS>where
LS: UnsafeUnpin,
MS: UnsafeUnpin,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<D> OwoColorize for D
impl<D> OwoColorize for D
Source§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
Source§fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
Source§fn black(&self) -> FgColorDisplay<'_, Black, Self>
fn black(&self) -> FgColorDisplay<'_, Black, Self>
Source§fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
Source§fn red(&self) -> FgColorDisplay<'_, Red, Self>
fn red(&self) -> FgColorDisplay<'_, Red, Self>
Source§fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
Source§fn green(&self) -> FgColorDisplay<'_, Green, Self>
fn green(&self) -> FgColorDisplay<'_, Green, Self>
Source§fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
Source§fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
Source§fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
Source§fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
Source§fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
Source§fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
Source§fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
Source§fn white(&self) -> FgColorDisplay<'_, White, Self>
fn white(&self) -> FgColorDisplay<'_, White, Self>
Source§fn on_white(&self) -> BgColorDisplay<'_, White, Self>
fn on_white(&self) -> BgColorDisplay<'_, White, Self>
Source§fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
Source§fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
Source§fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
Source§fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
Source§fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
Source§fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
Source§fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
Source§fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
Source§fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
Source§fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
Source§fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
Source§fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
Source§fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
Source§fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
Source§fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
Source§fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
Source§fn bold(&self) -> BoldDisplay<'_, Self>
fn bold(&self) -> BoldDisplay<'_, Self>
Source§fn dimmed(&self) -> DimDisplay<'_, Self>
fn dimmed(&self) -> DimDisplay<'_, Self>
Source§fn italic(&self) -> ItalicDisplay<'_, Self>
fn italic(&self) -> ItalicDisplay<'_, Self>
Source§fn underline(&self) -> UnderlineDisplay<'_, Self>
fn underline(&self) -> UnderlineDisplay<'_, Self>
Source§fn blink(&self) -> BlinkDisplay<'_, Self>
fn blink(&self) -> BlinkDisplay<'_, Self>
Source§fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
Source§fn reversed(&self) -> ReversedDisplay<'_, Self>
fn reversed(&self) -> ReversedDisplay<'_, Self>
Source§fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
Source§fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::fg or
a color-specific method, such as OwoColorize::green, Read moreSource§fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::bg or
a color-specific method, such as OwoColorize::on_yellow, Read more