1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 | function julia(hljs) {
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 | var VARIABLE_NAME_RE = '[A-Za-z_\\u00A1-\\uFFFF][A-Za-z_0-9\\u00A1-\\uFFFF]*';
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 | var KEYWORD_LIST = [
|
29 | 'baremodule',
|
30 | 'begin',
|
31 | 'break',
|
32 | 'catch',
|
33 | 'ccall',
|
34 | 'const',
|
35 | 'continue',
|
36 | 'do',
|
37 | 'else',
|
38 | 'elseif',
|
39 | 'end',
|
40 | 'export',
|
41 | 'false',
|
42 | 'finally',
|
43 | 'for',
|
44 | 'function',
|
45 | 'global',
|
46 | 'if',
|
47 | 'import',
|
48 | 'in',
|
49 | 'isa',
|
50 | 'let',
|
51 | 'local',
|
52 | 'macro',
|
53 | 'module',
|
54 | 'quote',
|
55 | 'return',
|
56 | 'true',
|
57 | 'try',
|
58 | 'using',
|
59 | 'where',
|
60 | 'while',
|
61 | ];
|
62 |
|
63 |
|
64 |
|
65 |
|
66 |
|
67 |
|
68 |
|
69 |
|
70 |
|
71 |
|
72 |
|
73 |
|
74 |
|
75 |
|
76 |
|
77 |
|
78 | var LITERAL_LIST = [
|
79 | 'ARGS',
|
80 | 'C_NULL',
|
81 | 'DEPOT_PATH',
|
82 | 'ENDIAN_BOM',
|
83 | 'ENV',
|
84 | 'Inf',
|
85 | 'Inf16',
|
86 | 'Inf32',
|
87 | 'Inf64',
|
88 | 'InsertionSort',
|
89 | 'LOAD_PATH',
|
90 | 'MergeSort',
|
91 | 'NaN',
|
92 | 'NaN16',
|
93 | 'NaN32',
|
94 | 'NaN64',
|
95 | 'PROGRAM_FILE',
|
96 | 'QuickSort',
|
97 | 'RoundDown',
|
98 | 'RoundFromZero',
|
99 | 'RoundNearest',
|
100 | 'RoundNearestTiesAway',
|
101 | 'RoundNearestTiesUp',
|
102 | 'RoundToZero',
|
103 | 'RoundUp',
|
104 | 'VERSION|0',
|
105 | 'devnull',
|
106 | 'false',
|
107 | 'im',
|
108 | 'missing',
|
109 | 'nothing',
|
110 | 'pi',
|
111 | 'stderr',
|
112 | 'stdin',
|
113 | 'stdout',
|
114 | 'true',
|
115 | 'undef',
|
116 | 'π',
|
117 | 'ℯ',
|
118 | ];
|
119 |
|
120 |
|
121 |
|
122 |
|
123 |
|
124 |
|
125 |
|
126 |
|
127 |
|
128 |
|
129 |
|
130 |
|
131 |
|
132 |
|
133 |
|
134 |
|
135 | var BUILT_IN_LIST = [
|
136 | 'AbstractArray',
|
137 | 'AbstractChannel',
|
138 | 'AbstractChar',
|
139 | 'AbstractDict',
|
140 | 'AbstractDisplay',
|
141 | 'AbstractFloat',
|
142 | 'AbstractIrrational',
|
143 | 'AbstractMatrix',
|
144 | 'AbstractRange',
|
145 | 'AbstractSet',
|
146 | 'AbstractString',
|
147 | 'AbstractUnitRange',
|
148 | 'AbstractVecOrMat',
|
149 | 'AbstractVector',
|
150 | 'Any',
|
151 | 'ArgumentError',
|
152 | 'Array',
|
153 | 'AssertionError',
|
154 | 'BigFloat',
|
155 | 'BigInt',
|
156 | 'BitArray',
|
157 | 'BitMatrix',
|
158 | 'BitSet',
|
159 | 'BitVector',
|
160 | 'Bool',
|
161 | 'BoundsError',
|
162 | 'CapturedException',
|
163 | 'CartesianIndex',
|
164 | 'CartesianIndices',
|
165 | 'Cchar',
|
166 | 'Cdouble',
|
167 | 'Cfloat',
|
168 | 'Channel',
|
169 | 'Char',
|
170 | 'Cint',
|
171 | 'Cintmax_t',
|
172 | 'Clong',
|
173 | 'Clonglong',
|
174 | 'Cmd',
|
175 | 'Colon',
|
176 | 'Complex',
|
177 | 'ComplexF16',
|
178 | 'ComplexF32',
|
179 | 'ComplexF64',
|
180 | 'CompositeException',
|
181 | 'Condition',
|
182 | 'Cptrdiff_t',
|
183 | 'Cshort',
|
184 | 'Csize_t',
|
185 | 'Cssize_t',
|
186 | 'Cstring',
|
187 | 'Cuchar',
|
188 | 'Cuint',
|
189 | 'Cuintmax_t',
|
190 | 'Culong',
|
191 | 'Culonglong',
|
192 | 'Cushort',
|
193 | 'Cvoid',
|
194 | 'Cwchar_t',
|
195 | 'Cwstring',
|
196 | 'DataType',
|
197 | 'DenseArray',
|
198 | 'DenseMatrix',
|
199 | 'DenseVecOrMat',
|
200 | 'DenseVector',
|
201 | 'Dict',
|
202 | 'DimensionMismatch',
|
203 | 'Dims',
|
204 | 'DivideError',
|
205 | 'DomainError',
|
206 | 'EOFError',
|
207 | 'Enum',
|
208 | 'ErrorException',
|
209 | 'Exception',
|
210 | 'ExponentialBackOff',
|
211 | 'Expr',
|
212 | 'Float16',
|
213 | 'Float32',
|
214 | 'Float64',
|
215 | 'Function',
|
216 | 'GlobalRef',
|
217 | 'HTML',
|
218 | 'IO',
|
219 | 'IOBuffer',
|
220 | 'IOContext',
|
221 | 'IOStream',
|
222 | 'IdDict',
|
223 | 'IndexCartesian',
|
224 | 'IndexLinear',
|
225 | 'IndexStyle',
|
226 | 'InexactError',
|
227 | 'InitError',
|
228 | 'Int',
|
229 | 'Int128',
|
230 | 'Int16',
|
231 | 'Int32',
|
232 | 'Int64',
|
233 | 'Int8',
|
234 | 'Integer',
|
235 | 'InterruptException',
|
236 | 'InvalidStateException',
|
237 | 'Irrational',
|
238 | 'KeyError',
|
239 | 'LinRange',
|
240 | 'LineNumberNode',
|
241 | 'LinearIndices',
|
242 | 'LoadError',
|
243 | 'MIME',
|
244 | 'Matrix',
|
245 | 'Method',
|
246 | 'MethodError',
|
247 | 'Missing',
|
248 | 'MissingException',
|
249 | 'Module',
|
250 | 'NTuple',
|
251 | 'NamedTuple',
|
252 | 'Nothing',
|
253 | 'Number',
|
254 | 'OrdinalRange',
|
255 | 'OutOfMemoryError',
|
256 | 'OverflowError',
|
257 | 'Pair',
|
258 | 'PartialQuickSort',
|
259 | 'PermutedDimsArray',
|
260 | 'Pipe',
|
261 | 'ProcessFailedException',
|
262 | 'Ptr',
|
263 | 'QuoteNode',
|
264 | 'Rational',
|
265 | 'RawFD',
|
266 | 'ReadOnlyMemoryError',
|
267 | 'Real',
|
268 | 'ReentrantLock',
|
269 | 'Ref',
|
270 | 'Regex',
|
271 | 'RegexMatch',
|
272 | 'RoundingMode',
|
273 | 'SegmentationFault',
|
274 | 'Set',
|
275 | 'Signed',
|
276 | 'Some',
|
277 | 'StackOverflowError',
|
278 | 'StepRange',
|
279 | 'StepRangeLen',
|
280 | 'StridedArray',
|
281 | 'StridedMatrix',
|
282 | 'StridedVecOrMat',
|
283 | 'StridedVector',
|
284 | 'String',
|
285 | 'StringIndexError',
|
286 | 'SubArray',
|
287 | 'SubString',
|
288 | 'SubstitutionString',
|
289 | 'Symbol',
|
290 | 'SystemError',
|
291 | 'Task',
|
292 | 'TaskFailedException',
|
293 | 'Text',
|
294 | 'TextDisplay',
|
295 | 'Timer',
|
296 | 'Tuple',
|
297 | 'Type',
|
298 | 'TypeError',
|
299 | 'TypeVar',
|
300 | 'UInt',
|
301 | 'UInt128',
|
302 | 'UInt16',
|
303 | 'UInt32',
|
304 | 'UInt64',
|
305 | 'UInt8',
|
306 | 'UndefInitializer',
|
307 | 'UndefKeywordError',
|
308 | 'UndefRefError',
|
309 | 'UndefVarError',
|
310 | 'Union',
|
311 | 'UnionAll',
|
312 | 'UnitRange',
|
313 | 'Unsigned',
|
314 | 'Val',
|
315 | 'Vararg',
|
316 | 'VecElement',
|
317 | 'VecOrMat',
|
318 | 'Vector',
|
319 | 'VersionNumber',
|
320 | 'WeakKeyDict',
|
321 | 'WeakRef',
|
322 | ];
|
323 |
|
324 | var KEYWORDS = {
|
325 | $pattern: VARIABLE_NAME_RE,
|
326 | keyword: KEYWORD_LIST,
|
327 | literal: LITERAL_LIST,
|
328 | built_in: BUILT_IN_LIST,
|
329 | };
|
330 |
|
331 |
|
332 | var DEFAULT = {
|
333 | keywords: KEYWORDS, illegal: /<\//
|
334 | };
|
335 |
|
336 |
|
337 | var NUMBER = {
|
338 | className: 'number',
|
339 |
|
340 |
|
341 |
|
342 |
|
343 |
|
344 |
|
345 |
|
346 | begin: /(\b0x[\d_]*(\.[\d_]*)?|0x\.\d[\d_]*)p[-+]?\d+|\b0[box][a-fA-F0-9][a-fA-F0-9_]*|(\b\d[\d_]*(\.[\d_]*)?|\.\d[\d_]*)([eEfF][-+]?\d+)?/,
|
347 | relevance: 0
|
348 | };
|
349 |
|
350 | var CHAR = {
|
351 | className: 'string',
|
352 | begin: /'(.|\\[xXuU][a-zA-Z0-9]+)'/
|
353 | };
|
354 |
|
355 | var INTERPOLATION = {
|
356 | className: 'subst',
|
357 | begin: /\$\(/, end: /\)/,
|
358 | keywords: KEYWORDS
|
359 | };
|
360 |
|
361 | var INTERPOLATED_VARIABLE = {
|
362 | className: 'variable',
|
363 | begin: '\\$' + VARIABLE_NAME_RE
|
364 | };
|
365 |
|
366 |
|
367 | var STRING = {
|
368 | className: 'string',
|
369 | contains: [hljs.BACKSLASH_ESCAPE, INTERPOLATION, INTERPOLATED_VARIABLE],
|
370 | variants: [
|
371 | { begin: /\w*"""/, end: /"""\w*/, relevance: 10 },
|
372 | { begin: /\w*"/, end: /"\w*/ }
|
373 | ]
|
374 | };
|
375 |
|
376 | var COMMAND = {
|
377 | className: 'string',
|
378 | contains: [hljs.BACKSLASH_ESCAPE, INTERPOLATION, INTERPOLATED_VARIABLE],
|
379 | begin: '`', end: '`'
|
380 | };
|
381 |
|
382 | var MACROCALL = {
|
383 | className: 'meta',
|
384 | begin: '@' + VARIABLE_NAME_RE
|
385 | };
|
386 |
|
387 | var COMMENT = {
|
388 | className: 'comment',
|
389 | variants: [
|
390 | { begin: '#=', end: '=#', relevance: 10 },
|
391 | { begin: '#', end: '$' }
|
392 | ]
|
393 | };
|
394 |
|
395 | DEFAULT.name = 'Julia';
|
396 | DEFAULT.contains = [
|
397 | NUMBER,
|
398 | CHAR,
|
399 | STRING,
|
400 | COMMAND,
|
401 | MACROCALL,
|
402 | COMMENT,
|
403 | hljs.HASH_COMMENT_MODE,
|
404 | {
|
405 | className: 'keyword',
|
406 | begin:
|
407 | '\\b(((abstract|primitive)\\s+)type|(mutable\\s+)?struct)\\b'
|
408 | },
|
409 | {begin: /<:/}
|
410 | ];
|
411 | INTERPOLATION.contains = DEFAULT.contains;
|
412 |
|
413 | return DEFAULT;
|
414 | }
|
415 |
|
416 | export { julia as default };
|