Lang registry: registration, resolution, and EDN loading. JVM/Babashka only.
A lang is a map of command functions: :run (fn [source opts] → result) — run a file :repl (fn [opts] → nil) — interactive loop :format (fn [source opts] → text) — format a file :to-clj (fn [source] → clj-text) — convert meme→clj :to-meme (fn [source] → meme-text) — convert clj→meme
Plus optional metadata:
:extension ".ext" — file extension (string or vector)
:extensions [".ext" ".e"] — file extensions (string or vector)
:form-shape registry — lang-owned decomposer map consumed by
the printer/formatter (see
meme-lang.form-shape)
Both extension forms are accepted and normalized to :extensions [...].
Every key is optional. A lang supports exactly the commands it has keys for.
Built-in langs are self-describing: each defines a lang-map in its own namespace. User langs can be registered via register! with EDN-style config maps.
String values in a lang-map (e.g. :run "prelude.meme" in EDN) are
resolved through handlers installed via register-string-handler!. This
keeps the registry lang-agnostic — langs install their own conventions
rather than the registry hardcoding meme's.
Lang registry: registration, resolution, and EDN loading.
JVM/Babashka only.
A lang is a map of command functions:
:run (fn [source opts] → result) — run a file
:repl (fn [opts] → nil) — interactive loop
:format (fn [source opts] → text) — format a file
:to-clj (fn [source] → clj-text) — convert meme→clj
:to-meme (fn [source] → meme-text) — convert clj→meme
Plus optional metadata:
:extension ".ext" — file extension (string or vector)
:extensions [".ext" ".e"] — file extensions (string or vector)
:form-shape registry — lang-owned decomposer map consumed by
the printer/formatter (see
`meme-lang.form-shape`)
Both extension forms are accepted and normalized to :extensions [...].
Every key is optional. A lang supports exactly the commands it has keys for.
Built-in langs are self-describing: each defines a lang-map in its own namespace.
User langs can be registered via register! with EDN-style config maps.
String values in a lang-map (e.g. `:run "prelude.meme"` in EDN) are
resolved through handlers installed via `register-string-handler!`. This
keeps the registry lang-agnostic — langs install their own conventions
rather than the registry hardcoding meme's.(available-langs)Return a set of all available lang names (built-in + user-registered).
Return a set of all available lang names (built-in + user-registered).
(builtin-langs)Return a map of {lang-name lang-map} for all built-in langs.
Return a map of {lang-name lang-map} for all built-in langs.
(check-support lang lang-name command)Assert that the lang supports the given command. Throws if not.
Assert that the lang supports the given command. Throws if not.
The default lang used when none is specified.
The default lang used when none is specified.
(load-edn path)Load a lang from an EDN file. Returns a lang map with functions. H5 WARNING: this function executes code. Symbols in the EDN are resolved via requiring-resolve (loads namespaces from classpath). String values are dispatched through string handlers a lang installed via register-string-handler! (meme installs a :run handler that slurps and runs the string as a prelude file). Only use with trusted EDN files.
Load a lang from an EDN file. Returns a lang map with functions. H5 WARNING: this function executes code. Symbols in the EDN are resolved via requiring-resolve (loads namespaces from classpath). String values are dispatched through string handlers a lang installed via register-string-handler! (meme installs a :run handler that slurps and runs the string as a prelude file). Only use with trusted EDN files.
(register! lang-name config)Register a user lang at runtime. config is an EDN-style map — symbols are resolved via requiring-resolve, strings and keywords follow the same rules as load-edn. Pre-resolved functions are passed through. Rejects attempts to override built-in langs. All conflict checks are atomic — performed inside swap!.
Register a user lang at runtime. config is an EDN-style map — symbols are resolved via requiring-resolve, strings and keywords follow the same rules as load-edn. Pre-resolved functions are passed through. Rejects attempts to override built-in langs. All conflict checks are atomic — performed inside swap!.
(register-builtin! lang-name lang-map)Register a built-in language. Called at ns-load time from each lang's
own api namespace — the registry itself imports no langs. User langs
should use register! instead, which validates and guards against
built-in overrides.
Register a built-in language. Called at ns-load time from each lang's own api namespace — the registry itself imports no langs. User langs should use `register!` instead, which validates and guards against built-in overrides.
(register-string-handler! command handler)Install a handler for resolving string values in the given command slot.
handler is (fn [string-value] → command-fn) and is called once per
register!/load-edn. Later registrations override earlier ones.
Install a handler for resolving string values in the given command slot. `handler` is (fn [string-value] → command-fn) and is called once per register!/load-edn. Later registrations override earlier ones.
(registered-langs)List all registered user language names (excludes built-ins).
List all registered user language names (excludes built-ins).
(resolve-by-extension path)Given a file path, find the lang whose :extensions match. Returns [lang-name lang-map] or nil.
Given a file path, find the lang whose :extensions match. Returns [lang-name lang-map] or nil.
(resolve-lang lang-name)Resolve a lang by keyword name. Returns the lang map. Deprecated name (:classic) is accepted but emits a warning. Throws on unknown name.
Resolve a lang by keyword name. Returns the lang map. Deprecated name (:classic) is accepted but emits a warning. Throws on unknown name.
(supports? lang command)Does the lang support the given command?
Does the lang support the given command?
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |