Liking cljdoc? Tell your friends :D

meme.lang

Lang registry, resolution, and EDN loading.

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 (self-contained) :to-meme (fn [source] → meme-text) — convert clj→meme (JVM only, self-contained)

Plus optional metadata: :extension ".ext" — file extension for auto-detection

Every key is optional. A lang supports exactly the commands it has keys for. The CLI dispatches by looking up the command key in the lang map.

All lang definitions — built-in and user-defined — are EDN: {:run meme.runtime.run/run-string :format meme.lang.meme-classic/format-meme :to-clj meme.lang.meme-classic/to-clj :to-meme meme.lang.meme-classic/to-meme}

User langs can also use: {:extension ".calc" ;; file extension for auto-detection :run "core.meme" ;; string → .meme file to eval before user file :rules "rules.meme" ;; string → .meme file returning rewrite rules :parser my.ns/parser-fn ;; symbol → custom parser function :format :meme-classic} ;; keyword → inherit command from built-in lang

Built-in langs (resources/meme/lang/): :meme-classic (default), :meme-rewrite, :meme-trs

Lang registry, resolution, and EDN loading.

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 (self-contained)
  :to-meme  (fn [source] → meme-text)    — convert clj→meme (JVM only, self-contained)

Plus optional metadata:
  :extension  ".ext"   — file extension for auto-detection

Every key is optional. A lang supports exactly the commands it has keys for.
The CLI dispatches by looking up the command key in the lang map.

All lang definitions — built-in and user-defined — are EDN:
  {:run      meme.runtime.run/run-string
   :format   meme.lang.meme-classic/format-meme
   :to-clj   meme.lang.meme-classic/to-clj
   :to-meme  meme.lang.meme-classic/to-meme}

User langs can also use:
  {:extension ".calc"        ;; file extension for auto-detection
   :run "core.meme"          ;; string → .meme file to eval before user file
   :rules "rules.meme"       ;; string → .meme file returning rewrite rules
   :parser my.ns/parser-fn    ;; symbol → custom parser function
   :format :meme-classic}     ;; keyword → inherit command from built-in lang

Built-in langs (resources/meme/lang/):
  :meme-classic (default), :meme-rewrite, :meme-trs
raw docstring

builtinclj/s

Built-in lang maps, keyed by :meme-classic, :meme-rewrite, :meme-trs. JVM: delay of EDN-loaded maps. CLJS: plain map with portable functions only.

Built-in lang maps, keyed by :meme-classic, :meme-rewrite, :meme-trs.
JVM: delay of EDN-loaded maps. CLJS: plain map with portable functions only.
sourceraw docstring

check-support!clj/s

(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.
sourceraw docstring

clear-user-langs!clj

(clear-user-langs!)

Clear all registered user languages. For testing.

Clear all registered user languages. For testing.
sourceraw docstring

default-langclj/s

The default lang used when none is specified.

The default lang used when none is specified.
sourceraw docstring

load-ednclj

(load-edn path)

Load a lang from an EDN file. Returns a lang map with functions.

Load a lang from an EDN file. Returns a lang map with functions.
sourceraw docstring

register!clj

(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.

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.
sourceraw docstring

registered-langsclj

(registered-langs)

List all registered user language names.

List all registered user language names.
sourceraw docstring

resolve-by-extensionclj

(resolve-by-extension path)

Given a file path, find the lang whose :extension matches. Returns [lang-name lang-map] or nil. Checks user langs only (built-in langs don't have :extension).

Given a file path, find the lang whose :extension matches.
Returns [lang-name lang-map] or nil. Checks user langs only
(built-in langs don't have :extension).
sourceraw docstring

resolve-langclj/s

(resolve-lang lang-name)

Resolve a lang by keyword name. Returns the lang map. Deprecated names (:classic, :rewrite, :ts-trs) are accepted but emit a warning. Checks user-registered langs first, then built-ins. Throws on unknown name.

Resolve a lang by keyword name. Returns the lang map.
Deprecated names (:classic, :rewrite, :ts-trs) are accepted but emit a warning.
Checks user-registered langs first, then built-ins. Throws on unknown name.
sourceraw docstring

supports?clj/s

(supports? lang command)

Does the lang support the given command?

Does the lang support the given command?
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close