1 | Prism.languages.vala = Prism.languages.extend('clike', {
|
2 |
|
3 | 'class-name': [
|
4 | {
|
5 |
|
6 | pattern: /\b[A-Z]\w*(?:\.\w+)*\b(?=(?:\?\s+|\*?\s+\*?)\w+)/,
|
7 | inside: {
|
8 | punctuation: /\./
|
9 | }
|
10 | },
|
11 | {
|
12 |
|
13 | pattern: /(\[)[A-Z]\w*(?:\.\w+)*\b/,
|
14 | lookbehind: true,
|
15 | inside: {
|
16 | punctuation: /\./
|
17 | }
|
18 | },
|
19 | {
|
20 |
|
21 | pattern: /(\b(?:class|interface)\s+[A-Z]\w*(?:\.\w+)*\s*:\s*)[A-Z]\w*(?:\.\w+)*\b/,
|
22 | lookbehind: true,
|
23 | inside: {
|
24 | punctuation: /\./
|
25 | }
|
26 | },
|
27 | {
|
28 |
|
29 | pattern: /((?:\b(?:class|interface|new|struct|enum)\s+)|(?:catch\s+\())[A-Z]\w*(?:\.\w+)*\b/,
|
30 | lookbehind: true,
|
31 | inside: {
|
32 | punctuation: /\./
|
33 | }
|
34 | }
|
35 | ],
|
36 | 'keyword': /\b(?:bool|char|double|float|null|size_t|ssize_t|string|unichar|void|int|int8|int16|int32|int64|long|short|uchar|uint|uint8|uint16|uint32|uint64|ulong|ushort|class|delegate|enum|errordomain|interface|namespace|struct|break|continue|do|for|foreach|return|while|else|if|switch|assert|case|default|abstract|const|dynamic|ensures|extern|inline|internal|override|private|protected|public|requires|signal|static|virtual|volatile|weak|async|owned|unowned|try|catch|finally|throw|as|base|construct|delete|get|in|is|lock|new|out|params|ref|sizeof|set|this|throws|typeof|using|value|var|yield)\b/i,
|
37 | 'function': /\w+(?=\s*\()/,
|
38 | 'number': /(?:\b0x[\da-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?)(?:f|u?l?)?/i,
|
39 | 'operator': /\+\+|--|&&|\|\||<<=?|>>=?|=>|->|~|[+\-*\/%&^|=!<>]=?|\?\??|\.\.\./,
|
40 | 'punctuation': /[{}[\];(),.:]/,
|
41 | 'constant': /\b[A-Z0-9_]+\b/
|
42 | });
|
43 |
|
44 | Prism.languages.insertBefore('vala','string', {
|
45 | 'raw-string': {
|
46 | pattern: /"""[\s\S]*?"""/,
|
47 | greedy: true,
|
48 | alias: 'string'
|
49 | },
|
50 | 'template-string': {
|
51 | pattern: /@"[\s\S]*?"/,
|
52 | greedy: true,
|
53 | inside: {
|
54 | 'interpolation': {
|
55 | pattern: /\$(?:\([^)]*\)|[a-zA-Z]\w*)/,
|
56 | inside: {
|
57 | 'delimiter': {
|
58 | pattern: /^\$\(?|\)$/,
|
59 | alias: 'punctuation'
|
60 | },
|
61 | rest: Prism.languages.vala
|
62 | }
|
63 | },
|
64 | 'string': /[\s\S]+/
|
65 | }
|
66 | }
|
67 | });
|
68 |
|
69 | Prism.languages.insertBefore('vala', 'keyword', {
|
70 | 'regex': {
|
71 | pattern: /\/(?:\[(?:[^\]\\\r\n]|\\.)*]|\\.|[^/\\\[\r\n])+\/[imsx]{0,4}(?=\s*(?:$|[\r\n,.;})\]]))/,
|
72 | greedy: true,
|
73 | inside: {
|
74 | 'regex-source': {
|
75 | pattern: /^(\/)[\s\S]+(?=\/[a-z]*$)/,
|
76 | lookbehind: true,
|
77 | alias: 'language-regex',
|
78 | inside: Prism.languages.regex
|
79 | },
|
80 | 'regex-flags': /[a-z]+$/,
|
81 | 'regex-delimiter': /^\/|\/$/
|
82 | }
|
83 | }
|
84 | });
|