forked from binford2k/showoff
-
Notifications
You must be signed in to change notification settings - Fork 0
/
clojure.lang
67 lines (45 loc) · 6.91 KB
/
clojure.lang
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
(comment) = `(;=>)`
comment delim "#\|" "\|#" multiline nested
comment start ";"
vardef SPECIALCHAR = '\\.'
environment string delim "\"" "\"" begin
specialchar = $SPECIALCHAR
end
# broken:
#environment comment delim "(comment" ")" begin
# specialchar = $SPECIALCHAR
#end
# also broken:
environment cbracket delim "^{" "}" begin
specialchar = $SPECIALCHAR
end
# intPat:
number = '([-+]?)(?:(0)|([1-9][0-9]*)|0[xX]([0-9A-Fa-f]+)|0([0-7]+)|([1-9][0-9]?)[rR]([0-9A-Za-z]+)|0[0-9]+)(N)?'
# ratioPat:
number = '([-+]?[0-9]+)/([0-9]+)'
# floatPat:
number = '([-+]?[0-9]+(\\.[0-9]*)?([eE][-+]?[0-9]+)?)(M)?'
#type = '#?\'(\b|\/|\+|\?|\*|\-)[[:alnum:]_\/\-\+\*\?:]+(\+|\?|\*|\-|\/|\b)'
keyword = '~@|~|`|\''
symbol = '::?[[:alnum:]\-/]+'
variable = '(\+|\*)[[:alnum:]_\-\+\*\?:]+(\+|\*)'
normal = '(\b|\+|\?|\*|\-)[[:alnum:]_\-\+\*\?:]+(\+|\?|\*|\-|\b)'
# def
# special forms:
(cbracket,label,cbracket) = `(\( *)(if|do|let|quote|var|fn|loop|recur|throw|try|catch|finally|monitor-enter|monitor-exit|\.|new|set!)((?![[:alnum:]\-]))`
# (clojure.string/join "|" (sort (map first (filter #(:macro (meta (second %))) (ns-publics 'clojure.core)))))
# macros:
(cbracket,keyword,cbracket) = `(\( *)(->|->>|\.\.|amap|and|areduce|assert|binding|bound-fn|case|comment|cond|condp|declare|delay|doc|doseq|dosync|dotimes|doto|extend-protocol|extend-type|fn|for|future|gen-class|gen-interface|if-let|if-not|import|io!|lazy-cat|lazy-seq|let|letfn|locking|loop|memfn|ns|or|proxy|proxy-super|pvalues|refer-clojure|reify|sync|time|when|when-first|when-let|when-not|while|with-bindings|with-in-str|with-loading-context|with-local-vars|with-open|with-out-str|with-precision)((?![[:alnum:]\-]))`
# definline|definterface|defmacro|defmethod|defmulti|defn|defn-|defonce|defprotocol|defrecord|defstruct|deftype|
# (clojure.string/join "|" (sort (map first (filter #(and (not (:macro (meta (second %)))) (bound? (second %)) (fn? @(second %))) (ns-publics 'clojure.core)))))
# core functions:
#(cbracket,keyword,cbracket) = `(\( *)(\*|\*'|\+|\+'|-|-'|-cache-protocol-fn|-reset-methods|/|<|<=|=|==|>|>=|accessor|aclone|add-classpath|add-watch|agent|agent-error|agent-errors|aget|alength|alias|all-ns|alter|alter-meta!|alter-var-root|ancestors|apply|array-map|aset|aset-boolean|aset-byte|aset-char|aset-double|aset-float|aset-int|aset-long|aset-short|assoc|assoc!|assoc-in|associative\?|atom|await|await-for|await1|bases|bean|bigdec|bigint|biginteger|bit-and|bit-and-not|bit-clear|bit-flip|bit-not|bit-or|bit-set|bit-shift-left|bit-shift-right|bit-test|bit-xor|boolean|boolean-array|booleans|bound-fn\*|bound\?|butlast|byte|byte-array|bytes|cast|char|char-array|char\?|chars|chunk|chunk-append|chunk-buffer|chunk-cons|chunk-first|chunk-next|chunk-rest|chunked-seq\?|class|class\?|clear-agent-errors|clojure-version|coll\?|commute|comp|comparator|compare|compare-and-set!|compile|complement|concat|conj|conj!|cons|constantly|construct-proxy|contains\?|count|counted\?|create-ns|create-struct|cycle|dec|dec'|decimal\?|delay\?|deliver|denominator|deref|derive|descendants|destructure|disj|disj!|dissoc|dissoc!|distinct|distinct\?|doall|dorun|double|double-array|doubles|drop|drop-last|drop-while|empty|empty\?|ensure|enumeration-seq|error-handler|error-mode|eval|even\?|every\?|extend|extenders|extends\?|false\?|ffirst|file-seq|filter|find|find-doc|find-ns|find-protocol-impl|find-protocol-method|find-var|first|flatten|float|float-array|float\?|floats|flush|fn\?|fnext|fnil|force|format|frequencies|future-call|future-cancel|future-cancelled\?|future-done\?|future\?|gensym|get|get-in|get-method|get-proxy-class|get-thread-bindings|get-validator|group-by|hash|hash-combine|hash-map|hash-set|identical\?|identity|ifn\?|inc|inc'|init-proxy|instance\?|int|int-array|integer\?|interleave|intern|interpose|into|into-array|ints|isa\?|iterate|iterator-seq|juxt|keep|keep-indexed|key|keys|keyword|keyword\?|last|line-seq|list|list\*|list\?|load|load-reader|load-string|loaded-libs|long|long-array|longs|macroexpand|macroexpand-1|make-array|make-hierarchy|map|map-indexed|map\?|mapcat|max|max-key|memoize|merge|merge-with|meta|method-sig|methods|min|min-key|mod|munge|name|namespace|namespace-munge|neg\?|newline|next|nfirst|nil\?|nnext|not|not-any\?|not-empty|not-every\?|not=|ns-aliases|ns-imports|ns-interns|ns-map|ns-name|ns-publics|ns-refers|ns-resolve|ns-unalias|ns-unmap|nth|nthnext|num|number\?|numerator|object-array|odd\?|parents|partial|partition|partition-all|partition-by|pcalls|peek|persistent!|pmap|pop|pop!|pop-thread-bindings|pos\?|pr|pr-str|prefer-method|prefers|print|print-ctor|print-doc|print-namespace-doc|print-simple|print-special-doc|print-str|printf|println|println-str|prn|prn-str|promise|proxy-call-with-super|proxy-mappings|proxy-name|push-thread-bindings|quot|rand|rand-int|rand-nth|range|ratio\?|rational\?|rationalize|re-find|re-groups|re-matcher|re-matches|re-pattern|re-seq|read|read-line|read-string|reduce|reductions|ref|ref-history-count|ref-max-history|ref-min-history|ref-set|refer|release-pending-sends|rem|remove|remove-all-methods|remove-method|remove-ns|remove-watch|repeat|repeatedly|replace|replicate|require|reset!|reset-meta!|resolve|rest|restart-agent|resultset-seq|reverse|reversible\?|rseq|rsubseq|satisfies\?|second|select-keys|send|send-off|seq|seq\?|seque|sequence|sequential\?|set|set-error-handler!|set-error-mode!|set-validator!|set\?|short|short-array|shorts|shuffle|shutdown-agents|slurp|some|sort|sort-by|sorted-map|sorted-map-by|sorted-set|sorted-set-by|sorted\?|special-form-anchor|special-symbol\?|spit|split-at|split-with|str|string\?|struct|struct-map|subs|subseq|subvec|supers|swap!|symbol|symbol\?|syntax-symbol-anchor|take|take-last|take-nth|take-while|test|the-ns|thread-bound\?|to-array|to-array-2d|trampoline|transient|tree-seq|true\?|type|unchecked-add-int|unchecked-add-long|unchecked-dec-int|unchecked-dec-long|unchecked-divide-int|unchecked-divide-long|unchecked-inc-int|unchecked-inc-long|unchecked-multiply-int|unchecked-multiply-long|unchecked-negate-int|unchecked-negate-long|unchecked-remainder-int|unchecked-remainder-long|unchecked-subtract-int|unchecked-subtract-long|underive|update-in|update-proxy|use|val|vals|var-get|var-set|var\?|vary-meta|vec|vector|vector-of|vector\?|with-bindings\*|with-meta|xml-seq|zero\?|zipmap|\*1|\*2|\*3|\*agent\*|\*allow-unresolved-vars\*|\*assert\*|\*clojure-version\*|\*command-line-args\*|\*compile-files\*|\*compile-path\*|\*e|\*err\*|\*file\*|\*flush-on-newline\*|\*in\*|\*math-context\*|\*ns\*|\*out\*|\*print-dup\*|\*print-length\*|\*print-level\*|\*print-meta\*|\*print-readably\*|\*read-eval\*|\*source-path\*|\*use-context-classloader\*|\*warn-on-reflection\*|EMPTY-NODE|char-escape-string|char-name-string|in-ns|load-file|primitives-classnames|print-dup|print-method|unquote|unquote-splicing)((?![[:alnum:]\-]))`
(cbracket,keyword,function) = `(\( *)(def.*? *)([[:alnum:]\-]*)`
# things in function-call position:
#(cbracket,function) = `(\( *)([[:alnum:]\-]*)`
cbracket = "(|)"
cbracket = "#(|)"
cbracket = "[|]"
cbracket = "{|}"
cbracket = "#{|}"
number = '(%&|%[1-9]?)'