UNPKG

2.16 kBJavaScriptView Raw
1(function (Prism) {
2 var escapes = /\\(?:["'\\abefnrtv]|0[0-7]{2}|U[\dA-Fa-f]{6}|u[\dA-Fa-f]{4}|x[\dA-Fa-f]{2})/;
3
4 Prism.languages.odin = {
5 /**
6 * The current implementation supports only 1 level of nesting.
7 *
8 * @author Michael Schmidt
9 * @author edukisto
10 */
11 'comment': [
12 {
13 pattern: /\/\*(?:[^/*]|\/(?!\*)|\*(?!\/)|\/\*(?:\*(?!\/)|[^*])*(?:\*\/|$))*(?:\*\/|$)/,
14 greedy: true
15 },
16 {
17 pattern: /#![^\n\r]*/,
18 greedy: true
19 },
20 {
21 pattern: /\/\/[^\n\r]*/,
22 greedy: true
23 }
24 ],
25
26 /**
27 * Should be found before strings because of '"'"- and '`'`-like sequences.
28 */
29 'char': {
30 pattern: /'(?:\\(?:.|[0Uux][0-9A-Fa-f]{1,6})|[^\n\r'\\])'/,
31 greedy: true,
32 inside: {
33 'symbol': escapes
34 }
35 },
36
37 'string': [
38 {
39 pattern: /`[^`]*`/,
40 greedy: true
41 },
42 {
43 pattern: /"(?:\\.|[^\n\r"\\])*"/,
44 greedy: true,
45 inside: {
46 'symbol': escapes
47 }
48 }
49 ],
50
51 'directive': {
52 pattern: /#\w+/,
53 alias: 'property'
54 },
55
56 '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]?(?!\w)/,
57
58 'discard': {
59 pattern: /\b_\b/,
60 alias: 'keyword'
61 },
62
63 'procedure-definition': {
64 pattern: /\b\w+(?=[ \t]*(?::\s*){2}proc\b)/,
65 alias: 'function'
66 },
67
68 '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/,
69
70 /**
71 * false, nil, true can be used as procedure names. "_" and keywords can't.
72 */
73 'procedure-name': {
74 pattern: /\b\w+(?=[ \t]*\()/,
75 alias: 'function'
76 },
77
78 'boolean': /\b(?:false|nil|true)\b/,
79
80 'constant-parameter-sign': {
81 pattern: /\$/,
82 alias: 'important'
83 },
84
85 'undefined': {
86 pattern: /---/,
87 alias: 'operator'
88 },
89
90 'arrow': {
91 pattern: /->/,
92 alias: 'punctuation'
93 },
94
95 'operator': /\+\+|--|\.\.[<=]?|(?:&~|[-!*+/=~]|[%&<>|]{1,2})=?|[?^]/,
96
97 'punctuation': /[(),.:;@\[\]{}]/
98 };
99}(Prism));