]>
luflow.net public git repositories - flow-web.git/blob - static/highlight/languages/julia.js
1 /*! `julia` grammar compiled for Highlight.js 11.11.1 */
3 var hljsGrammar
= (function () {
8 Description: Julia is a high-level, high-performance, dynamic programming language.
9 Author: Kenta Sato <bicycle1885@gmail.com>
10 Contributors: Alex Arslan <ararslan@comcast.net>, Fredrik Ekre <ekrefredrik@gmail.com>
11 Website: https://julialang.org
15 function julia(hljs
) {
16 // Since there are numerous special names in Julia, it is too much trouble
17 // to maintain them by hand. Hence these names (i.e. keywords, literals and
18 // built-ins) are automatically generated from Julia 1.5.2 itself through
19 // the following scripts for each.
21 // ref: https://docs.julialang.org/en/v1/manual/variables/#Allowed-Variable-Names
22 const VARIABLE_NAME_RE
= '[A-Za-z_\\u00A1-\\uFFFF][A-Za-z_0-9\\u00A1-\\uFFFF]*';
24 // # keyword generator, multi-word keywords handled manually below (Julia 1.5.2)
25 // import REPL.REPLCompletions
26 // res = String["in", "isa", "where"]
27 // for kw in collect(x.keyword for x in REPLCompletions.complete_keyword(""))
28 // if !(contains(kw, " ") || kw == "struct")
32 // sort!(unique!(res))
33 // foreach(x -> println("\'", x, "\',"), res)
34 const KEYWORD_LIST
= [
69 // # literal generator (Julia 1.5.2)
70 // import REPL.REPLCompletions
71 // res = String["true", "false"]
72 // for compl in filter!(x -> isa(x, REPLCompletions.ModuleCompletion) && (x.parent === Base || x.parent === Core),
73 // REPLCompletions.completions("", 0)[1])
75 // v = eval(Symbol(compl.mod))
76 // if !(v isa Function || v isa Type || v isa TypeVar || v isa Module || v isa Colon)
77 // push!(res, compl.mod)
82 // sort!(unique!(res))
83 // foreach(x -> println("\'", x, "\',"), res)
84 const LITERAL_LIST
= [
106 'RoundNearestTiesAway',
107 'RoundNearestTiesUp',
126 // # built_in generator (Julia 1.5.2)
127 // import REPL.REPLCompletions
129 // for compl in filter!(x -> isa(x, REPLCompletions.ModuleCompletion) && (x.parent === Base || x.parent === Core),
130 // REPLCompletions.completions("", 0)[1])
132 // v = eval(Symbol(compl.mod))
133 // if (v isa Type || v isa TypeVar) && (compl.mod != "=>")
134 // push!(res, compl.mod)
139 // sort!(unique!(res))
140 // foreach(x -> println("\'", x, "\',"), res)
141 const BUILT_IN_LIST
= [
148 'AbstractIrrational',
186 'CompositeException',
216 'ExponentialBackOff',
241 'InterruptException',
242 'InvalidStateException',
267 'ProcessFailedException',
272 'ReadOnlyMemoryError',
283 'StackOverflowError',
294 'SubstitutionString',
298 'TaskFailedException',
331 $pattern: VARIABLE_NAME_RE
,
332 keyword: KEYWORD_LIST
,
333 literal: LITERAL_LIST
,
334 built_in: BUILT_IN_LIST
,
337 // placeholder for recursive self-reference
343 // ref: https://docs.julialang.org/en/v1/manual/integers-and-floating-point-numbers/
346 // supported numeric literals:
347 // * binary literal (e.g. 0x10)
348 // * octal literal (e.g. 0o76543210)
349 // * hexadecimal literal (e.g. 0xfedcba876543210)
350 // * hexadecimal floating point literal (e.g. 0x1p0, 0x1.2p2)
351 // * decimal literal (e.g. 9876543210, 100_000_000)
352 // * floating pointe literal (e.g. 1.2, 1.2f, .2, 1., 1.2e10, 1.2e-10)
353 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+)?/,
359 begin: /'(.|\\[xXuU][a-zA-Z0-9]+)'/
362 const INTERPOLATION
= {
369 const INTERPOLATED_VARIABLE
= {
370 className: 'variable',
371 begin: '\\$' + VARIABLE_NAME_RE
374 // TODO: neatly escape normal code in string literal
378 hljs
.BACKSLASH_ESCAPE
,
380 INTERPOLATED_VARIABLE
398 hljs
.BACKSLASH_ESCAPE
,
400 INTERPOLATED_VARIABLE
408 begin: '@' + VARIABLE_NAME_RE
412 className: 'comment',
426 DEFAULT
.name
= 'Julia';
434 hljs
.HASH_COMMENT_MODE
,
436 className: 'keyword',
438 '\\b(((abstract|primitive)\\s+)type|(mutable\\s+)?struct)\\b'
440 { begin: /<:/ } // relevance booster
442 INTERPOLATION
.contains
= DEFAULT
.contains
;
451 hljs
.registerLanguage('julia', hljsGrammar
);