-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
prism-odin.js
90 lines (76 loc) · 2.03 KB
/
prism-odin.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
(function (Prism) {
var escapes = /\\(?:["'\\abefnrtv]|0[0-7]{2}|U[\dA-Fa-f]{6}|u[\dA-Fa-f]{4}|x[\dA-Fa-f]{2})/.source;
function withEscapes(pattern, flags) {
return RegExp(pattern.replace(/<escapes>/g, escapes), flags);
}
Prism.languages.odin = {
/**
* The current implementation supports only 1 level of nesting.
*
* @author Michael Schmidt
* @author edukisto
*/
'comment': [
{
pattern: /\/\*(?:[^/*]|\/(?!\*)|\*(?!\/)|\/\*(?:\*(?!\/)|[^*])*(?:\*\/|$))*(?:\*\/|$)/,
greedy: true
},
{
pattern: /#![^\n\r]*/,
greedy: true
},
{
pattern: /\/\/[^\n\r]*/,
greedy: true
}
],
/**
* Should be found before strings because of '"'"- and '`'`-like sequences.
*/
'char': {
pattern: withEscapes(/'(?:<escapes>|[^\n\r'\\])'/.source),
greedy: true,
inside: {
'symbol': withEscapes(/<escapes>/.source)
}
},
'string': [
{
pattern: /`[^`]*`/,
greedy: true
},
{
pattern: withEscapes(/"(?:<escapes>|[^\n\r"\\])*"/.source),
greedy: true,
inside: {
'symbol': withEscapes(/<escapes>/.source)
}
}
],
'directive': {
pattern: /#\w+/,
alias: 'property'
},
'number': /(?:\b0(?:b[01_]+|d[\d_]+|h_*(?:(?:(?:[\dA-Fa-f]_*){8}){1,2}|(?:[\dA-Fa-f]_*){4})|o[0-7_]+|x[\dA-F_a-f]+|z[\dAB_ab]+)\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:[Ee][+-]?\d*)?[ijk]?)/,
'boolean': /\b(?:_|false|nil|true)\b/,
'keyword': /\b(?:asm|auto_cast|bit_set|break|case|cast|context|continue|defer|distinct|do|dynamic|else|enum|fallthrough|for|foreign|if|import|in|map|matrix|not_in|or_else|or_return|package|proc|return|struct|switch|transmute|typeid|union|using|when|where)\b/,
'procedure': {
pattern: /\b\w+(?=[ \t]*\()/,
alias: 'function'
},
'constant-parameter-sign': {
pattern: /\$/,
alias: 'important'
},
'undefined': {
pattern: /---/,
alias: 'operator'
},
'arrow': {
pattern: /->/,
alias: 'punctuation'
},
'operator': /\+\+|--|\.\.[<=]?|(?:&~|[-!*+/=~]|[%&<>|]{1,2})=?|[?^]/,
'punctuation': /[(),.:;@\[\]{}]/
};
}(Prism));