]>
luflow.net public git repositories - flow-web.git/blob - static/highlight/languages/clojure.js
1 /*! `clojure` grammar compiled for Highlight.js 11.11.1 */
3 var hljsGrammar
= (function () {
8 Description: Clojure syntax (based on lisp.js)
10 Website: https://clojure.org
14 /** @type LanguageFn */
15 function clojure(hljs
) {
16 const SYMBOLSTART
= 'a-zA-Z_\\-!.?+*=<>&\'';
17 const SYMBOL_RE
= '[#]?[' + SYMBOLSTART
+ '][' + SYMBOLSTART
+ '0-9/;:$#]*';
18 const globals
= 'def defonce defprotocol defstruct defmulti defmethod defn- defn defmacro deftype defrecord';
24 + 'cond apply if-not if-let if not not= =|0 <|0 >|0 <=|0 >=|0 ==|0 +|0 /|0 *|0 -|0 rem '
25 + 'quot neg? pos? delay? symbol? keyword? true? false? integer? empty? coll? list? '
26 + 'set? ifn? fn? associative? sequential? sorted? counted? reversible? number? decimal? '
27 + 'class? distinct? isa? float? rational? reduced? ratio? odd? even? char? seq? vector? '
28 + 'string? map? nil? contains? zero? instance? not-every? not-any? libspec? -> ->> .. . '
29 + 'inc compare do dotimes mapcat take remove take-while drop letfn drop-last take-last '
30 + 'drop-while while intern condp case reduced cycle split-at split-with repeat replicate '
31 + 'iterate range merge zipmap declare line-seq sort comparator sort-by dorun doall nthnext '
32 + 'nthrest partition eval doseq await await-for let agent atom send send-off release-pending-sends '
33 + 'add-watch mapv filterv remove-watch agent-error restart-agent set-error-handler error-handler '
34 + 'set-error-mode! error-mode shutdown-agents quote var fn loop recur throw try monitor-enter '
35 + 'monitor-exit macroexpand macroexpand-1 for dosync and or '
36 + 'when when-not when-let comp juxt partial sequence memoize constantly complement identity assert '
37 + 'peek pop doto proxy first rest cons cast coll last butlast '
38 + 'sigs reify second ffirst fnext nfirst nnext meta with-meta ns in-ns create-ns import '
39 + 'refer keys select-keys vals key val rseq name namespace promise into transient persistent! conj! '
40 + 'assoc! dissoc! pop! disj! use class type num float double short byte boolean bigint biginteger '
41 + 'bigdec print-method print-dup throw-if printf format load compile get-in update-in pr pr-on newline '
42 + 'flush read slurp read-line subvec with-open memfn time re-find re-groups rand-int rand mod locking '
43 + 'assert-valid-fdecl alias resolve ref deref refset swap! reset! set-validator! compare-and-set! alter-meta! '
44 + 'reset-meta! commute get-validator alter ref-set ref-history-count ref-min-history ref-max-history ensure sync io! '
45 + 'new next conj set! to-array future future-call into-array aset gen-class reduce map filter find empty '
46 + 'hash-map hash-set sorted-map sorted-map-by sorted-set sorted-set-by vec vector seq flatten reverse assoc dissoc list '
47 + 'disj get union difference intersection extend extend-type extend-protocol int nth delay count concat chunk chunk-buffer '
48 + 'chunk-append chunk-first chunk-rest max min dec unchecked-inc-int unchecked-inc unchecked-dec-inc unchecked-dec unchecked-negate '
49 + 'unchecked-add-int unchecked-add unchecked-subtract-int unchecked-subtract chunk-next chunk-cons chunked-seq? prn vary-meta '
50 + 'lazy-seq spread list* str find-keyword keyword symbol gensym force rationalize'
61 { match: /[-+]?0[xX][0-9a-fA-F]+N?/ }, // hexadecimal // 0x2a
62 { match: /[-+]?0[0-7]+N?/ }, // octal // 052
63 { match: /[-+]?[1-9][0-9]?[rR][0-9a-zA-Z]+N?/ }, // variable radix from 2 to 36 // 2r101010, 8r52, 36r16
64 { match: /[-+]?[0-9]+\/[0-9]+N?/ }, // ratio // 1/2
65 { match: /[-+]?[0-9]+((\.[0-9]*([eE][+-]?[0-9]+)?M?)|([eE][+-]?[0-9]+M?|M))/ }, // float // 0.42 4.2E-1M 42E1 42M
66 { match: /[-+]?([1-9][0-9]*|0)N?/ }, // int (don't match leading 0) // 42 42N
72 { match: /\\o[0-3]?[0-7]{1,2}/ }, // Unicode Octal 0 - 377
73 { match: /\\u[0-9a-fA-F]{4}/ }, // Unicode Hex 0000 - FFFF
74 { match: /\\(newline|space|tab|formfeed|backspace|return)/ }, // special characters
78 } // any non-whitespace char
85 contains: [ hljs.BACKSLASH_ESCAPE ]
87 const STRING = hljs.inherit(hljs.QUOTE_STRING_MODE, { illegal: null });
93 const COMMENT = hljs.COMMENT(
100 begin: /\b(true|false|nil)\b/
103 begin: "\\[|(#::?" + SYMBOL_RE + ")?\\{",
109 begin: '[:]{1,2}' + SYMBOL_RE
116 endsWithParent: true,
126 const DEFAULT_CONTAINS = [
141 beginKeywords: globals,
146 end: '(\\[|#|\\d|"|:|\\{|\\)|\\(|$)',
153 // we can only have a single title
156 ].concat(DEFAULT_CONTAINS)
164 BODY.contains = DEFAULT_CONTAINS;
165 COLLECTION.contains = DEFAULT_CONTAINS;
193 hljs.registerLanguage('clojure
', hljsGrammar);