-
-
Notifications
You must be signed in to change notification settings - Fork 36
/
julia.js
47 lines (46 loc) · 2.08 KB
/
julia.js
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
// @ts-nocheck
julia.displayName = 'julia'
julia.aliases = []
/** @type {import('../core.js').Syntax} */
export default function julia(Prism) {
Prism.languages.julia = {
comment: {
// support one level of nested comments
// https://github.com/JuliaLang/julia/pull/6128
pattern:
/(^|[^\\])(?:#=(?:[^#=]|=(?!#)|#(?!=)|#=(?:[^#=]|=(?!#)|#(?!=))*=#)*=#|#.*)/,
lookbehind: true
},
regex: {
// https://docs.julialang.org/en/v1/manual/strings/#Regular-Expressions-1
pattern: /r"(?:\\.|[^"\\\r\n])*"[imsx]{0,4}/,
greedy: true
},
string: {
// https://docs.julialang.org/en/v1/manual/strings/#String-Basics-1
// https://docs.julialang.org/en/v1/manual/strings/#non-standard-string-literals-1
// https://docs.julialang.org/en/v1/manual/running-external-programs/#Running-External-Programs-1
pattern:
/"""[\s\S]+?"""|(?:\b\w+)?"(?:\\.|[^"\\\r\n])*"|`(?:[^\\`\r\n]|\\.)*`/,
greedy: true
},
char: {
// https://docs.julialang.org/en/v1/manual/strings/#man-characters-1
pattern: /(^|[^\w'])'(?:\\[^\r\n][^'\r\n]*|[^\\\r\n])'/,
lookbehind: true,
greedy: true
},
keyword:
/\b(?:abstract|baremodule|begin|bitstype|break|catch|ccall|const|continue|do|else|elseif|end|export|finally|for|function|global|if|immutable|import|importall|in|let|local|macro|module|print|println|quote|return|struct|try|type|typealias|using|while)\b/,
boolean: /\b(?:false|true)\b/,
number:
/(?:\b(?=\d)|\B(?=\.))(?:0[box])?(?:[\da-f]+(?:_[\da-f]+)*(?:\.(?:\d+(?:_\d+)*)?)?|\.\d+(?:_\d+)*)(?:[efp][+-]?\d+(?:_\d+)*)?j?/i,
// https://docs.julialang.org/en/v1/manual/mathematical-operations/
// https://docs.julialang.org/en/v1/manual/mathematical-operations/#Operator-Precedence-and-Associativity-1
operator:
/&&|\|\||[-+*^%÷⊻&$\\]=?|\/[\/=]?|!=?=?|\|[=>]?|<(?:<=?|[=:|])?|>(?:=|>>?=?)?|==?=?|[~≠≤≥'√∛]/,
punctuation: /::?|[{}[\]();,.?]/,
// https://docs.julialang.org/en/v1/base/numbers/#Base.im
constant: /\b(?:(?:Inf|NaN)(?:16|32|64)?|im|pi)\b|[πℯ]/
}
}