Skip to main content

quilt/langs/
omni.rs

1//! `Multi`s containing all languages enabled by Rust features.
2//!
3//! All the per-language boilerplate is generated by [`define_omni!`]; adding a
4//! language means adding one line to the `languages` section of the invocation
5//! at the bottom of this file (plus a `metas` line if it can act as a host).
6
7#[cfg(feature = "bash")]
8use super::bash::lang::{BashLanguage, DynBashLanguage};
9#[cfg(feature = "html")]
10use super::html::{
11    lang::{DynHtmlLanguage, HtmlLanguage},
12    meta::HtmlMetaLanguage,
13};
14#[cfg(feature = "lean")]
15use super::lean::{
16    lang::{DynLeanLanguage, LeanLanguage},
17    meta::LeanMetaLanguage,
18};
19#[cfg(feature = "nix")]
20use super::nix::{
21    lang::{DynNixLanguage, NixLanguage},
22    meta::NixMetaLanguage,
23};
24#[cfg(feature = "python")]
25use super::python::{
26    lang::{DynPythonLanguage, PythonLanguage},
27    meta::PythonMetaLanguage,
28};
29#[cfg(feature = "rust")]
30use super::rust::{
31    lang::{DynRustLanguage, RustLanguage},
32    meta::RustMetaLanguage,
33};
34#[cfg(feature = "bash")]
35use super::shell::meta::BashMetaLanguage;
36#[cfg(feature = "zsh")]
37use super::shell::meta::ZshMetaLanguage;
38#[cfg(feature = "sql")]
39use super::sql::lang::{DynSqlLanguage, SqlLanguage};
40#[cfg(feature = "text")]
41use super::text::lang::{DynTextLanguage, TextLanguage};
42#[cfg(feature = "typescript")]
43use super::typescript::{
44    lang::{DynTypeScriptLanguage, TypeScriptLanguage},
45    meta::TypeScriptMetaLanguage,
46};
47#[cfg(feature = "wgsl")]
48use super::wgsl::lang::{DynWgslLanguage, WgslLanguage};
49#[cfg(feature = "zsh")]
50use super::zsh::lang::{DynZshLanguage, ZshLanguage};
51use crate::lang::{Arity, FlatNode, Hole, InnerKind, Language, LanguagePost};
52use crate::meta::{MetaLanguage, OuterKind};
53use crate::multi::{DictMulti, Languages, MetaLanguages, Multi};
54use crate::prelude::*;
55use crate::qterm::QTerm;
56use crate::term::CmdOrHole;
57use miette::miette;
58
59/**************************************************************/
60
61/// Generates the entire Omni language surface from one table:
62/// `OmniLanguages`/`OmniMetaLanguages` (the registries), `OmniLanguage`/
63/// `OmniLanguagePost`/`OmniMetaLanguage` (the enum-dispatch wrappers), the
64/// `DynOmni*` registries, and [`dict_omni_language`].
65///
66/// Each `languages` entry reads:
67///
68/// ```text
69/// field if "feature" => Variant(LanguageTy, DynLanguageTy): ["canonical", "alias", ...];
70/// ```
71///
72/// The `metas` section lists the subset of languages that can act as hosts
73/// (drive expansion); languages absent from it are target-only.
74macro_rules! define_omni {
75    (
76        languages {
77            $( $field:ident if $feat:literal => $variant:ident($lang:ty, $dyn_lang:ty):
78                [$canon:literal $(, $alias:literal)* $(,)?] );* $(;)?
79        }
80        metas {
81            $( $mfield:ident if $mfeat:literal => $mvariant:ident($meta:ty):
82                [$mcanon:literal $(, $malias:literal)* $(,)?] );* $(;)?
83        }
84    ) => {
85        /// An "Omni"-language using enums.
86        pub struct OmniLanguages {
87            $(
88                #[cfg(feature = $feat)]
89                $field: OmniLanguage,
90            )*
91        }
92
93        impl Default for OmniLanguages {
94            #[allow(clippy::default_constructed_unit_structs)]
95            fn default() -> Self {
96                Self {
97                    $(
98                        #[cfg(feature = $feat)]
99                        $field: OmniLanguage::$variant(<$lang>::default()),
100                    )*
101                }
102            }
103        }
104
105        impl Languages for OmniLanguages {
106            type Language = OmniLanguage;
107
108            fn get(&self, lang: &str) -> Result<&Self::Language> {
109                match lang {
110                    $(
111                        #[cfg(feature = $feat)]
112                        $canon $(| $alias)* => Ok(&self.$field),
113                    )*
114                    _ => Err(miette!("{lang:?} can't be used as Language")),
115                }
116            }
117            fn get_mut(&mut self, lang: &str) -> Result<&mut Self::Language> {
118                match lang {
119                    $(
120                        #[cfg(feature = $feat)]
121                        $canon $(| $alias)* => Ok(&mut self.$field),
122                    )*
123                    _ => Err(miette!("{lang:?} can't be used as Language")),
124                }
125            }
126
127            fn canonical<'a>(&'a self, lang: &'a str) -> &'a str {
128                match lang {
129                    $(
130                        #[cfg(feature = $feat)]
131                        $canon $(| $alias)* => $canon,
132                    )*
133                    _ => lang,
134                }
135            }
136        }
137
138        pub struct OmniMetaLanguages {
139            $(
140                #[cfg(feature = $mfeat)]
141                $mfield: OmniMetaLanguage,
142            )*
143        }
144
145        impl Default for OmniMetaLanguages {
146            #[allow(clippy::default_constructed_unit_structs)]
147            fn default() -> Self {
148                Self {
149                    $(
150                        #[cfg(feature = $mfeat)]
151                        $mfield: OmniMetaLanguage::$mvariant(<$meta>::default()),
152                    )*
153                }
154            }
155        }
156
157        impl MetaLanguages for OmniMetaLanguages {
158            type MetaLanguage = OmniMetaLanguage;
159
160            fn get(&self, lang: &str) -> Result<&Self::MetaLanguage> {
161                match lang {
162                    $(
163                        #[cfg(feature = $mfeat)]
164                        $mcanon $(| $malias)* => Ok(&self.$mfield),
165                    )*
166                    _ => Err(miette!("{lang:?} can't be used as MetaLanguage")),
167                }
168            }
169            fn get_mut(&mut self, lang: &str) -> Result<&mut Self::MetaLanguage> {
170                match lang {
171                    $(
172                        #[cfg(feature = $mfeat)]
173                        $mcanon $(| $malias)* => Ok(&mut self.$mfield),
174                    )*
175                    _ => Err(miette!("{lang:?} can't be used as MetaLanguage")),
176                }
177            }
178        }
179
180        /// A `Language` used by `Omni`.
181        pub enum OmniLanguage {
182            $(
183                #[cfg(feature = $feat)]
184                $variant($lang),
185            )*
186        }
187
188        impl Language for OmniLanguage {
189            type Post = OmniLanguagePost;
190
191            #[allow(unused_variables)]
192            fn parse_pre(
193                &mut self,
194                ikind: Option<InnerKind>,
195                code: &[FlatNode],
196            ) -> Result<Self::Post> {
197                match self {
198                    $(
199                        #[cfg(feature = $feat)]
200                        OmniLanguage::$variant(lang) => {
201                            lang.parse_pre(ikind, code).map(OmniLanguagePost::$variant)
202                        }
203                    )*
204                    #[allow(unreachable_patterns)]
205                    _ => unreachable!(),
206                }
207            }
208
209            fn hashbang(&self) -> Option<&'static str> {
210                match self {
211                    $(
212                        #[cfg(feature = $feat)]
213                        OmniLanguage::$variant(lang) => lang.hashbang(),
214                    )*
215                    #[allow(unreachable_patterns)]
216                    _ => None,
217                }
218            }
219
220            fn machine_spec(&self) -> Option<crate::machine::MachineSpec> {
221                match self {
222                    $(
223                        #[cfg(feature = $feat)]
224                        OmniLanguage::$variant(lang) => lang.machine_spec(),
225                    )*
226                    #[allow(unreachable_patterns)]
227                    _ => None,
228                }
229            }
230
231            fn repl_spec(&self) -> Option<crate::machine::ReplSpec> {
232                match self {
233                    $(
234                        #[cfg(feature = $feat)]
235                        OmniLanguage::$variant(lang) => lang.repl_spec(),
236                    )*
237                    #[allow(unreachable_patterns)]
238                    _ => None,
239                }
240            }
241
242            fn native_machine(&self) -> Option<Box<dyn crate::machine::Machine>> {
243                match self {
244                    $(
245                        #[cfg(feature = $feat)]
246                        OmniLanguage::$variant(lang) => lang.native_machine(),
247                    )*
248                    #[allow(unreachable_patterns)]
249                    _ => None,
250                }
251            }
252
253            fn ident_tag(&self) -> &'static str {
254                match self {
255                    $(
256                        #[cfg(feature = $feat)]
257                        OmniLanguage::$variant(lang) => lang.ident_tag(),
258                    )*
259                    #[allow(unreachable_patterns)]
260                    _ => "identifier",
261                }
262            }
263
264            #[allow(unused_variables)]
265            fn arity(&self, tag: &str) -> Arity {
266                match self {
267                    $(
268                        #[cfg(feature = $feat)]
269                        OmniLanguage::$variant(lang) => lang.arity(tag),
270                    )*
271                    #[allow(unreachable_patterns)]
272                    _ => Default::default(),
273                }
274            }
275
276            #[allow(unused_variables)]
277            fn separator(&self, tag: &str) -> Option<&'static str> {
278                match self {
279                    $(
280                        #[cfg(feature = $feat)]
281                        OmniLanguage::$variant(lang) => lang.separator(tag),
282                    )*
283                    #[allow(unreachable_patterns)]
284                    _ => None,
285                }
286            }
287
288            #[allow(unused_variables)]
289            fn typ(&self, tag: &str) -> InnerKind {
290                match self {
291                    $(
292                        #[cfg(feature = $feat)]
293                        OmniLanguage::$variant(lang) => lang.typ(tag),
294                    )*
295                    #[allow(unreachable_patterns)]
296                    _ => Default::default(),
297                }
298            }
299
300            #[allow(unused_variables)]
301            fn classify_term(&self, term: &QTerm) -> InnerKind {
302                match self {
303                    $(
304                        #[cfg(feature = $feat)]
305                        OmniLanguage::$variant(lang) => lang.classify_term(term),
306                    )*
307                    #[allow(unreachable_patterns)]
308                    _ => Default::default(),
309                }
310            }
311        }
312
313        /// A `LanguagePost` used by `Omni`.
314        #[derive(Debug)]
315        pub enum OmniLanguagePost {
316            $(
317                #[cfg(feature = $feat)]
318                $variant(<$lang as Language>::Post),
319            )*
320        }
321
322        impl LanguagePost for OmniLanguagePost {
323            fn holes(&self) -> &[Hole] {
324                match self {
325                    $(
326                        #[cfg(feature = $feat)]
327                        OmniLanguagePost::$variant(post) => post.holes(),
328                    )*
329                    #[allow(unreachable_patterns)]
330                    _ => unreachable!(),
331                }
332            }
333
334            #[allow(unused_variables)]
335            fn parse_post(&self, plugs: &[Arc<QTerm>]) -> Result<Arc<QTerm>> {
336                match self {
337                    $(
338                        #[cfg(feature = $feat)]
339                        OmniLanguagePost::$variant(post) => post.parse_post(plugs),
340                    )*
341                    #[allow(unreachable_patterns)]
342                    _ => unreachable!(),
343                }
344            }
345        }
346
347        /// A `MetaLanguage` used by `Omni`.
348        pub enum OmniMetaLanguage {
349            $(
350                #[cfg(feature = $mfeat)]
351                $mvariant($meta),
352            )*
353        }
354
355        impl OmniMetaLanguage {
356            fn inner(&self) -> &dyn MetaLanguage {
357                match self {
358                    $(
359                        #[cfg(feature = $mfeat)]
360                        OmniMetaLanguage::$mvariant(lang) => lang,
361                    )*
362                    #[allow(unreachable_patterns)]
363                    _ => unreachable!(),
364                }
365            }
366        }
367
368        /// A `MultiLanguage` using `Box<dyn>`s.
369        #[derive(Default)]
370        pub struct DynOmniLanguages {
371            $(
372                #[cfg(feature = $feat)]
373                $field: $dyn_lang,
374            )*
375        }
376
377        impl Languages for DynOmniLanguages {
378            type Language = dyn Language<Post = Box<dyn LanguagePost>>;
379
380            fn get(&self, lang: &str) -> Result<&Self::Language> {
381                match lang {
382                    $(
383                        #[cfg(feature = $feat)]
384                        $canon $(| $alias)* => Ok(&self.$field),
385                    )*
386                    _ => Err(miette!("{lang:?} can't be used as Language")),
387                }
388            }
389            fn get_mut(&mut self, lang: &str) -> Result<&mut Self::Language> {
390                match lang {
391                    $(
392                        #[cfg(feature = $feat)]
393                        $canon $(| $alias)* => Ok(&mut self.$field),
394                    )*
395                    _ => Err(miette!("{lang:?} can't be used as Language")),
396                }
397            }
398
399            fn canonical<'a>(&'a self, lang: &'a str) -> &'a str {
400                match lang {
401                    $(
402                        #[cfg(feature = $feat)]
403                        $canon $(| $alias)* => $canon,
404                    )*
405                    _ => lang,
406                }
407            }
408        }
409
410        /// A `MultiLanguage` using `Box<dyn>`s.
411        #[derive(Default)]
412        pub struct DynOmniMetaLanguages {
413            $(
414                #[cfg(feature = $mfeat)]
415                $mfield: $meta,
416            )*
417        }
418
419        impl MetaLanguages for DynOmniMetaLanguages {
420            type MetaLanguage = dyn MetaLanguage;
421
422            fn get(&self, lang: &str) -> Result<&Self::MetaLanguage> {
423                match lang {
424                    $(
425                        #[cfg(feature = $mfeat)]
426                        $mcanon $(| $malias)* => Ok(&self.$mfield),
427                    )*
428                    _ => Err(miette!("{lang:?} can't be used as MetaLanguage")),
429                }
430            }
431
432            fn get_mut(&mut self, lang: &str) -> Result<&mut Self::MetaLanguage> {
433                match lang {
434                    $(
435                        #[cfg(feature = $mfeat)]
436                        $mcanon $(| $malias)* => Ok(&mut self.$mfield),
437                    )*
438                    _ => Err(miette!("{lang:?} can't be used as MetaLanguage")),
439                }
440            }
441        }
442
443        /// A `DictMulti` over all enabled languages. Each language is
444        /// registered once under its canonical name; aliases resolve to that
445        /// single instance through the alias registry.
446        #[allow(clippy::default_constructed_unit_structs)]
447        pub fn dict_omni_language() -> DictMulti {
448            #[allow(unused_mut)]
449            let mut ret = DictMulti::default();
450            $(
451                #[cfg(feature = $feat)]
452                {
453                    ret.add_lang($canon, bx(<$dyn_lang>::default()));
454                    $( ret.add_alias($alias, $canon); )*
455                }
456            )*
457            $(
458                #[cfg(feature = $mfeat)]
459                {
460                    ret.add_meta($mcanon, bx(<$meta>::default()));
461                    $( ret.add_alias($malias, $mcanon); )*
462                }
463            )*
464            ret
465        }
466
467        /// The line-comment introducer for `lang`, by canonical name or alias —
468        /// [`Comments::LINE`] of the language that name registers.
469        ///
470        /// Generated from the registry table, so a language's aliases cannot
471        /// disagree about it and adding a language cannot forget it: every
472        /// entry here has to implement [`Comments`] for the table to compile.
473        ///
474        /// `None` for a name no enabled feature registers, and for a language
475        /// whose comments a *prefix* cannot express (HTML, plain text) — the
476        /// caller decides the fallback.
477        #[must_use]
478        pub fn line_comment(lang: &str) -> Option<&'static str> {
479            match lang {
480                $(
481                    #[cfg(feature = $feat)]
482                    $canon $(| $alias)* => <$lang as crate::lang::Comments>::LINE,
483                )*
484                _ => None,
485            }
486        }
487
488        /// The comment introducer for the `DO NOT EDIT` header the CLI writes
489        /// onto a generated file of `lang` — [`Comments::HEADER`], which is
490        /// [`line_comment`] for every language but Rust.
491        ///
492        /// The header has to be a comment *in the language just generated*
493        /// (issue #136, where every language got Rust's `//!`); resolving it
494        /// through the registry rather than a table of its own is issue #194.
495        #[must_use]
496        pub fn header_comment(lang: &str) -> Option<&'static str> {
497            match lang {
498                $(
499                    #[cfg(feature = $feat)]
500                    $canon $(| $alias)* => <$lang as crate::lang::Comments>::HEADER,
501                )*
502                _ => None,
503            }
504        }
505    };
506}
507
508impl MetaLanguage for OmniMetaLanguage {
509    fn expand_quote(
510        &self,
511        lang1: &str,
512        tag: &str,
513        i: Index,
514        lang2: &str,
515        qterm: &Arc<QTerm>,
516        cmds: &[CmdOrHole],
517    ) -> Result<Arc<QTerm>> {
518        self.inner().expand_quote(lang1, tag, i, lang2, qterm, cmds)
519    }
520
521    fn expand_unquote(
522        &self,
523        lang1: &str,
524        tag: &str,
525        i: Index,
526        lang2: &str,
527        qterm: &Arc<QTerm>,
528        cmds: &[CmdOrHole],
529    ) -> Result<Arc<QTerm>> {
530        self.inner()
531            .expand_unquote(lang1, tag, i, lang2, qterm, cmds)
532    }
533
534    fn expand_tuple(
535        &self,
536        lang1: &str,
537        tag: &str,
538        qterms: &[Arc<QTerm>],
539        cmds: &[CmdOrHole],
540        arity: Arity,
541    ) -> Result<Arc<QTerm>> {
542        self.inner().expand_tuple(lang1, tag, qterms, cmds, arity)
543    }
544
545    fn wrap_child(&self, qterm: Arc<QTerm>, okind: OuterKind) -> Result<Arc<QTerm>> {
546        self.inner().wrap_child(qterm, okind)
547    }
548
549    fn wrap_separated(&self, qterm: Arc<QTerm>, sep: &str) -> Result<Arc<QTerm>> {
550        self.inner().wrap_separated(qterm, sep)
551    }
552
553    fn pattern_tag(&self) -> Option<&'static str> {
554        self.inner().pattern_tag()
555    }
556
557    fn pattern_binding(&self, terms: &[Arc<QTerm>]) -> Option<(usize, usize)> {
558        self.inner().pattern_binding(terms)
559    }
560
561    fn pattern_var(&self, name: &str) -> Result<Arc<QTerm>> {
562        self.inner().pattern_var(name)
563    }
564
565    fn pattern_let(
566        &self,
567        names: &[Box<str>],
568        pattern: &Arc<QTerm>,
569        value: &Arc<QTerm>,
570    ) -> Result<(Arc<QTerm>, Arc<QTerm>)> {
571        self.inner().pattern_let(names, pattern, value)
572    }
573
574    fn lift_str(&self, target: &str) -> Result<&'static str> {
575        self.inner().lift_str(target)
576    }
577
578    fn reduce_str(&self, target: &str) -> Result<&'static str> {
579        self.inner().reduce_str(target)
580    }
581
582    fn reduce_method_str(&self, target: &str) -> Result<&'static str> {
583        self.inner().reduce_method_str(target)
584    }
585
586    fn emit_str(&self) -> Result<&'static str> {
587        self.inner().emit_str()
588    }
589
590    fn lift_str_in(&self, target: &str, repr: crate::qterm::Repr) -> Result<&'static str> {
591        self.inner().lift_str_in(target, repr)
592    }
593
594    fn emit_str_in(&self, repr: crate::qterm::Repr) -> Result<&'static str> {
595        self.inner().emit_str_in(repr)
596    }
597
598    fn expand_flat(
599        &self,
600        repr: crate::qterm::Repr,
601        lang2: &str,
602        pieces: &[crate::meta::Piece],
603    ) -> Result<Arc<QTerm>> {
604        self.inner().expand_flat(repr, lang2, pieces)
605    }
606
607    fn type_str(&self) -> Result<&'static str> {
608        self.inner().type_str()
609    }
610
611    fn name_str(&self) -> Result<&'static str> {
612        self.inner().name_str()
613    }
614
615    fn type_method_str(&self) -> Result<&'static str> {
616        self.inner().type_method_str()
617    }
618
619    fn spawn_str(&self, lang: &str) -> Result<String> {
620        self.inner().spawn_str(lang)
621    }
622
623    fn prelude(&self, targets: &[&str]) -> Option<crate::meta::Prelude> {
624        self.inner().prelude(targets)
625    }
626}
627
628pub type Omni = Multi<OmniLanguages, OmniMetaLanguages>;
629
630#[cfg(test)]
631mod tests {
632    use super::*;
633
634    /// Aliases resolve through the registry to the canonical entry instead of
635    /// owning a second instance.
636    #[test]
637    fn dict_aliases_resolve() {
638        let dict = dict_omni_language();
639        #[cfg(feature = "python")]
640        {
641            assert!(dict.get_lang("python").is_ok());
642            assert!(dict.get_lang("py").is_ok());
643            assert!(dict.get_meta("py").is_ok());
644        }
645        #[cfg(feature = "rust")]
646        {
647            assert!(dict.get_lang("rs").is_ok());
648            assert!(dict.get_meta("rs").is_ok());
649        }
650        #[cfg(feature = "text")]
651        {
652            assert!(dict.get_lang("txt").is_ok());
653            // text is target-only: the alias exists but has no meta entry
654            assert!(dict.get_meta("txt").is_err());
655        }
656        #[cfg(feature = "html")]
657        {
658            // html is a quotable target *and* an identity host (notebooks)
659            assert!(dict.get_lang("html").is_ok());
660            assert!(dict.get_meta("html").is_ok());
661        }
662        #[cfg(feature = "lean")]
663        {
664            // Lean is both a target and a (string-based) host, under either
665            // spelling.
666            assert!(dict.get_lang("lean").is_ok());
667            assert!(dict.get_lang("lean4").is_ok());
668            assert!(dict.get_meta("lean").is_ok());
669            assert!(dict.get_meta("lean4").is_ok());
670        }
671        assert!(dict.get_lang("nope").is_err());
672    }
673
674    /// Every registered language's comment spellings, pinned so that changing
675    /// one is a deliberate edit here rather than a surprise in generated code.
676    ///
677    /// The header half is pinned again by the conformance battery, against the
678    /// claim in `conformance/spec/<lang>.toml`. The line half has no spec claim
679    /// — it is not a support-matrix axis, it feeds quilt-lsp's `CommentSyntax`
680    /// — so this is where it is held, together with `quilt-lsp`'s
681    /// `comment_syntax_comes_from_quilt`, which holds the server to it.
682    #[test]
683    fn comment_spellings() {
684        // (name, line, header). Only Rust's two differ.
685        let cases: &[(&str, Option<&str>, Option<&str>)] = &[
686            #[cfg(feature = "bash")]
687            ("bash", Some("#"), Some("#")),
688            #[cfg(feature = "html")]
689            ("html", None, None),
690            #[cfg(feature = "lean")]
691            ("lean", Some("--"), Some("--")),
692            #[cfg(feature = "lean")]
693            ("lean4", Some("--"), Some("--")),
694            #[cfg(feature = "nix")]
695            ("nix", Some("#"), Some("#")),
696            #[cfg(feature = "python")]
697            ("python", Some("#"), Some("#")),
698            #[cfg(feature = "python")]
699            ("py", Some("#"), Some("#")),
700            #[cfg(feature = "rust")]
701            ("rust", Some("//"), Some("//!")),
702            #[cfg(feature = "rust")]
703            ("rs", Some("//"), Some("//!")),
704            #[cfg(feature = "sql")]
705            ("sql", Some("--"), Some("--")),
706            #[cfg(feature = "sql")]
707            ("mysql", Some("--"), Some("--")),
708            #[cfg(feature = "text")]
709            ("text", None, None),
710            #[cfg(feature = "typescript")]
711            ("typescript", Some("//"), Some("//")),
712            #[cfg(feature = "wgsl")]
713            ("wgsl", Some("//"), Some("//")),
714            #[cfg(feature = "zsh")]
715            ("zsh", Some("#"), Some("#")),
716        ];
717        for (name, line, header) in cases {
718            assert_eq!(line_comment(name), *line, "line_comment({name:?})");
719            assert_eq!(header_comment(name), *header, "header_comment({name:?})");
720        }
721        // A name no language registers gets no answer, so callers can tell
722        // "this language has no line comment" from "no such language".
723        assert_eq!(line_comment("nope"), None);
724        assert_eq!(header_comment("nope"), None);
725    }
726}
727
728// Languages absent from `metas` (text, wgsl, sql) are target languages only —
729// the host's MetaLanguage drives expansion. Nix, Lean and the two shells are
730// both: quotable targets *and* string-based hosts (their metas generate code as
731// strings, see `langs::nix::meta` / `langs::lean::meta` /
732// `langs::shell::meta`). HTML is a quotable target *and* an identity host: an
733// `.html.quilt` file expands to itself with its cells held, so `quilt check`
734// validates a notebook's cells without running them (`langs::html::meta`).
735define_omni! {
736    languages {
737        bash if "bash"   => Bash(BashLanguage, DynBashLanguage):       ["bash"];
738        html if "html"   => Html(HtmlLanguage, DynHtmlLanguage):       ["html"];
739        lean if "lean"   => Lean(LeanLanguage, DynLeanLanguage):       ["lean", "lean4"];
740        nix  if "nix"    => Nix(NixLanguage, DynNixLanguage):          ["nix"];
741        py   if "python" => Python(PythonLanguage, DynPythonLanguage): ["python", "py"];
742        rs   if "rust"   => Rust(RustLanguage, DynRustLanguage):       ["rust", "rs"];
743        sql  if "sql"    => Sql(SqlLanguage, DynSqlLanguage):          ["sql", "mysql", "mariadb"];
744        txt  if "text"   => Text(TextLanguage, DynTextLanguage):       ["text", "txt"];
745        ts   if "typescript" => TypeScript(TypeScriptLanguage, DynTypeScriptLanguage): ["typescript", "ts"];
746        wgsl if "wgsl"   => Wgsl(WgslLanguage, DynWgslLanguage):       ["wgsl"];
747        zsh  if "zsh"    => Zsh(ZshLanguage, DynZshLanguage):          ["zsh"];
748    }
749    metas {
750        bash if "bash"   => Bash(BashMetaLanguage):                    ["bash"];
751        html if "html"   => Html(HtmlMetaLanguage):                    ["html"];
752        lean if "lean"   => Lean(LeanMetaLanguage):                    ["lean", "lean4"];
753        nix  if "nix"    => Nix(NixMetaLanguage):                      ["nix"];
754        py   if "python" => Python(PythonMetaLanguage):                ["python", "py"];
755        rs   if "rust"   => Rust(RustMetaLanguage):                    ["rust", "rs"];
756        ts   if "typescript" => TypeScript(TypeScriptMetaLanguage):    ["typescript", "ts"];
757        zsh  if "zsh"    => Zsh(ZshMetaLanguage):                      ["zsh"];
758    }
759}