1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 | function hy(hljs) {
|
10 | const SYMBOLSTART = 'a-zA-Z_\\-!.?+*=<>&#\'';
|
11 | const SYMBOL_RE = '[' + SYMBOLSTART + '][' + SYMBOLSTART + '0-9/;:]*';
|
12 | const keywords = {
|
13 | $pattern: SYMBOL_RE,
|
14 | built_in:
|
15 |
|
16 | '!= % %= & &= * ** **= *= *map ' +
|
17 | '+ += , --build-class-- --import-- -= . / // //= ' +
|
18 | '/= < << <<= <= = > >= >> >>= ' +
|
19 | '@ @= ^ ^= abs accumulate all and any ap-compose ' +
|
20 | 'ap-dotimes ap-each ap-each-while ap-filter ap-first ap-if ap-last ap-map ap-map-when ap-pipe ' +
|
21 | 'ap-reduce ap-reject apply as-> ascii assert assoc bin break butlast ' +
|
22 | 'callable calling-module-name car case cdr chain chr coll? combinations compile ' +
|
23 | 'compress cond cons cons? continue count curry cut cycle dec ' +
|
24 | 'def default-method defclass defmacro defmacro-alias defmacro/g! defmain defmethod defmulti defn ' +
|
25 | 'defn-alias defnc defnr defreader defseq del delattr delete-route dict-comp dir ' +
|
26 | 'disassemble dispatch-reader-macro distinct divmod do doto drop drop-last drop-while empty? ' +
|
27 | 'end-sequence eval eval-and-compile eval-when-compile even? every? except exec filter first ' +
|
28 | 'flatten float? fn fnc fnr for for* format fraction genexpr ' +
|
29 | 'gensym get getattr global globals group-by hasattr hash hex id ' +
|
30 | 'identity if if* if-not if-python2 import in inc input instance? ' +
|
31 | 'integer integer-char? integer? interleave interpose is is-coll is-cons is-empty is-even ' +
|
32 | 'is-every is-float is-instance is-integer is-integer-char is-iterable is-iterator is-keyword is-neg is-none ' +
|
33 | 'is-not is-numeric is-odd is-pos is-string is-symbol is-zero isinstance islice issubclass ' +
|
34 | 'iter iterable? iterate iterator? keyword keyword? lambda last len let ' +
|
35 | 'lif lif-not list* list-comp locals loop macro-error macroexpand macroexpand-1 macroexpand-all ' +
|
36 | 'map max merge-with method-decorator min multi-decorator multicombinations name neg? next ' +
|
37 | 'none? nonlocal not not-in not? nth numeric? oct odd? open ' +
|
38 | 'or ord partition permutations pos? post-route postwalk pow prewalk print ' +
|
39 | 'product profile/calls profile/cpu put-route quasiquote quote raise range read read-str ' +
|
40 | 'recursive-replace reduce remove repeat repeatedly repr require rest round route ' +
|
41 | 'route-with-methods rwm second seq set-comp setattr setv some sorted string ' +
|
42 | 'string? sum switch symbol? take take-nth take-while tee try unless ' +
|
43 | 'unquote unquote-splicing vars walk when while with with* with-decorator with-gensyms ' +
|
44 | 'xi xor yield yield-from zero? zip zip-longest | |= ~'
|
45 | };
|
46 |
|
47 | const SIMPLE_NUMBER_RE = '[-+]?\\d+(\\.\\d+)?';
|
48 |
|
49 | const SYMBOL = {
|
50 | begin: SYMBOL_RE,
|
51 | relevance: 0
|
52 | };
|
53 | const NUMBER = {
|
54 | className: 'number',
|
55 | begin: SIMPLE_NUMBER_RE,
|
56 | relevance: 0
|
57 | };
|
58 | const STRING = hljs.inherit(hljs.QUOTE_STRING_MODE, {
|
59 | illegal: null
|
60 | });
|
61 | const COMMENT = hljs.COMMENT(
|
62 | ';',
|
63 | '$',
|
64 | {
|
65 | relevance: 0
|
66 | }
|
67 | );
|
68 | const LITERAL = {
|
69 | className: 'literal',
|
70 | begin: /\b([Tt]rue|[Ff]alse|nil|None)\b/
|
71 | };
|
72 | const COLLECTION = {
|
73 | begin: '[\\[\\{]',
|
74 | end: '[\\]\\}]',
|
75 | relevance: 0
|
76 | };
|
77 | const HINT = {
|
78 | className: 'comment',
|
79 | begin: '\\^' + SYMBOL_RE
|
80 | };
|
81 | const HINT_COL = hljs.COMMENT('\\^\\{', '\\}');
|
82 | const KEY = {
|
83 | className: 'symbol',
|
84 | begin: '[:]{1,2}' + SYMBOL_RE
|
85 | };
|
86 | const LIST = {
|
87 | begin: '\\(',
|
88 | end: '\\)'
|
89 | };
|
90 | const BODY = {
|
91 | endsWithParent: true,
|
92 | relevance: 0
|
93 | };
|
94 | const NAME = {
|
95 | className: 'name',
|
96 | relevance: 0,
|
97 | keywords: keywords,
|
98 | begin: SYMBOL_RE,
|
99 | starts: BODY
|
100 | };
|
101 | const DEFAULT_CONTAINS = [
|
102 | LIST,
|
103 | STRING,
|
104 | HINT,
|
105 | HINT_COL,
|
106 | COMMENT,
|
107 | KEY,
|
108 | COLLECTION,
|
109 | NUMBER,
|
110 | LITERAL,
|
111 | SYMBOL
|
112 | ];
|
113 |
|
114 | LIST.contains = [
|
115 | hljs.COMMENT('comment', ''),
|
116 | NAME,
|
117 | BODY
|
118 | ];
|
119 | BODY.contains = DEFAULT_CONTAINS;
|
120 | COLLECTION.contains = DEFAULT_CONTAINS;
|
121 |
|
122 | return {
|
123 | name: 'Hy',
|
124 | aliases: [ 'hylang' ],
|
125 | illegal: /\S/,
|
126 | contains: [
|
127 | hljs.SHEBANG(),
|
128 | LIST,
|
129 | STRING,
|
130 | HINT,
|
131 | HINT_COL,
|
132 | COMMENT,
|
133 | KEY,
|
134 | COLLECTION,
|
135 | NUMBER,
|
136 | LITERAL
|
137 | ]
|
138 | };
|
139 | }
|
140 |
|
141 | export { hy as default };
|