]>
luflow.net public git repositories - flow-web.git/blob - static/highlight/es/languages/julia.js
1 /*! `julia` grammar compiled for Highlight.js 11.11.1 */
2 var hljsGrammar
= (function () {
7 Description: Julia is a high-level, high-performance, dynamic programming language.
8 Author: Kenta Sato <bicycle1885@gmail.com>
9 Contributors: Alex Arslan <ararslan@comcast.net>, Fredrik Ekre <ekrefredrik@gmail.com>
10 Website: https://julialang.org
14 function julia(hljs
) {
15 // Since there are numerous special names in Julia, it is too much trouble
16 // to maintain them by hand. Hence these names (i.e. keywords, literals and
17 // built-ins) are automatically generated from Julia 1.5.2 itself through
18 // the following scripts for each.
20 // ref: https://docs.julialang.org/en/v1/manual/variables/#Allowed-Variable-Names
21 const VARIABLE_NAME_RE
= '[A-Za-z_\\u00A1-\\uFFFF][A-Za-z_0-9\\u00A1-\\uFFFF]*';
23 // # keyword generator, multi-word keywords handled manually below (Julia 1.5.2)
24 // import REPL.REPLCompletions
25 // res = String["in", "isa", "where"]
26 // for kw in collect(x.keyword for x in REPLCompletions.complete_keyword(""))
27 // if !(contains(kw, " ") || kw == "struct")
31 // sort!(unique!(res))
32 // foreach(x -> println("\'", x, "\',"), res)
33 const KEYWORD_LIST
= [
68 // # literal generator (Julia 1.5.2)
69 // import REPL.REPLCompletions
70 // res = String["true", "false"]
71 // for compl in filter!(x -> isa(x, REPLCompletions.ModuleCompletion) && (x.parent === Base || x.parent === Core),
72 // REPLCompletions.completions("", 0)[1])
74 // v = eval(Symbol(compl.mod))
75 // if !(v isa Function || v isa Type || v isa TypeVar || v isa Module || v isa Colon)
76 // push!(res, compl.mod)
81 // sort!(unique!(res))
82 // foreach(x -> println("\'", x, "\',"), res)
83 const LITERAL_LIST
= [
105 'RoundNearestTiesAway',
106 'RoundNearestTiesUp',
125 // # built_in generator (Julia 1.5.2)
126 // import REPL.REPLCompletions
128 // for compl in filter!(x -> isa(x, REPLCompletions.ModuleCompletion) && (x.parent === Base || x.parent === Core),
129 // REPLCompletions.completions("", 0)[1])
131 // v = eval(Symbol(compl.mod))
132 // if (v isa Type || v isa TypeVar) && (compl.mod != "=>")
133 // push!(res, compl.mod)
138 // sort!(unique!(res))
139 // foreach(x -> println("\'", x, "\',"), res)
140 const BUILT_IN_LIST
= [
147 'AbstractIrrational',
185 'CompositeException',
215 'ExponentialBackOff',
240 'InterruptException',
241 'InvalidStateException',
266 'ProcessFailedException',
271 'ReadOnlyMemoryError',
282 'StackOverflowError',
293 'SubstitutionString',
297 'TaskFailedException',
330 $pattern: VARIABLE_NAME_RE
,
331 keyword: KEYWORD_LIST
,
332 literal: LITERAL_LIST
,
333 built_in: BUILT_IN_LIST
,
336 // placeholder for recursive self-reference
342 // ref: https://docs.julialang.org/en/v1/manual/integers-and-floating-point-numbers/
345 // supported numeric literals:
346 // * binary literal (e.g. 0x10)
347 // * octal literal (e.g. 0o76543210)
348 // * hexadecimal literal (e.g. 0xfedcba876543210)
349 // * hexadecimal floating point literal (e.g. 0x1p0, 0x1.2p2)
350 // * decimal literal (e.g. 9876543210, 100_000_000)
351 // * floating pointe literal (e.g. 1.2, 1.2f, .2, 1., 1.2e10, 1.2e-10)
352 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+)?/,
358 begin: /'(.|\\[xXuU][a-zA-Z0-9]+)'/
361 const INTERPOLATION
= {
368 const INTERPOLATED_VARIABLE
= {
369 className: 'variable',
370 begin: '\\$' + VARIABLE_NAME_RE
373 // TODO: neatly escape normal code in string literal
377 hljs
.BACKSLASH_ESCAPE
,
379 INTERPOLATED_VARIABLE
397 hljs
.BACKSLASH_ESCAPE
,
399 INTERPOLATED_VARIABLE
407 begin: '@' + VARIABLE_NAME_RE
411 className: 'comment',
425 DEFAULT
.name
= 'Julia';
433 hljs
.HASH_COMMENT_MODE
,
435 className: 'keyword',
437 '\\b(((abstract|primitive)\\s+)type|(mutable\\s+)?struct)\\b'
439 { begin: /<:/ } // relevance booster
441 INTERPOLATION
.contains
= DEFAULT
.contains
;
450 export default hljsGrammar
;